的WebAPI令牌颁发授权 [英] WebAPI Token Issuance Authorization
本文介绍了的WebAPI令牌颁发授权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前使用的会话和覆盖AuthorizeAttribute管理授权的端点的WebAPI,用于通过MVC Web应用程序。我已经告诉发出的令牌是管理用户和角色的最佳途径。我试图理解的是:
- 为什么它比使用Session更好?
- 有人可以提供的如何发出的令牌,当使用的WebAPI端点的用户登录,以及如何使用/它已被发出后跟踪令牌一个很好的(简单)的例子。
我一直在研究OWIN和一堆其他的东西,我有困难的时候找到的是如何工作的一个很好的例子。
解决方案
- 令牌是更安全,内置ASP.Net身份框架。没有必要推出自己的解决方案。
- 看看节获取访问令牌和发送身份验证的请求从这个链接:的 http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api 。端点已经在默认的MVC模板设置。您还可以使用邮递员来测试。
I am currently using Sessions and overriding the AuthorizeAttribute to manage Authorization for a WebAPI endpoint, which is used by an MVC Web Application. I've been told issuing tokens is the best way to manage users and roles. What I'm trying to understand is:
- Why is it better than using the Session?
- Can someone provide a good (simple) example of how to issue tokens, when a user logs in using a WebAPI endpoint, and how to use/track the token after it has been issued.
I've been researching OWIN and a bunch of other stuff and I'm having a difficult time finding a good example of how this works.
解决方案
- Tokens are more secure and built into ASP.Net Identity framework. No need to roll your own solution.
- Look at sections "Get an Access Token" and "Send an Authenticated Request" from this link: http://www.asp.net/web-api/overview/security/individual-accounts-in-web-api. The endpoint is already setup in the default MVC template. You can also use PostMan to test.
这篇关于的WebAPI令牌颁发授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文