简体   繁体   English

ASP.NET MVC和WebAPI之间的身份验证

[英]Authentication between ASP.NET MVC and WebAPI

I'm currently working on an MVC5 application + WebAPI for some AJAX requests. 我目前正在为某些AJAX请求开发MVC5应用程序+ WebAPI。 For the MVC part I use the standard cookie authentication, and token based authentication for the WebAPI part. 对于MVC部分,我对WebAPI部分使用标准cookie身份验证和基于令牌的身份验证。 I'd like the user to log in using only the MVC site, wthout having to authenticate again with the authorization server to obtain an acess token. 我希望用户仅使用MVC网站登录,而不必再次与授权服务器进行身份验证以获得访问令牌。

Is it safe to get the access token on the server side, put it in a hidden field on the site and use java script to query for it and use it later for the web api requests? 在服务器端获取访问令牌,将其放在网站上的隐藏字段中并使用Java脚本进行查询并稍后将其用于Web api请求是否安全? Assuming the connection will be over HTTPS, for obvious security reasons :) 出于明显的安全原因,假设连接将通过HTTPS :)

您可以将安全性令牌作为api的标头自定义属性传递给api,您可以对其进行预检查并将其缓存为api中的所有后续调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM