Cha*_*mer 5 asp.net-identity bearer-token asp.net-core-mvc asp.net-core
我正在研究一些MVC 6和ASP.NET 5样本,我在找到有关使用承载令牌来保护API的任何有价值的文档时遇到了问题.我能够使这些样本与VS 2013,MVC 5一起工作,但是我无法将这些示例移植到VS 2015和MVC 6.有没有人知道在MVC 6中实现承载令牌的任何好样本以保护API?
为了使用不记名令牌对请求进行身份验证,您可以下拉Microsoft.AspNet.Security.OAuthBearer包。然后,您可以OAuthBearerAuthenticationMiddleware使用扩展方法将中间件添加到管道中UseOAuthBearerAuthentication。
例子:
public void Configure(IApplicationBuilder app)
{
// ...
app.UseOAuthBearerAuthentication(options =>
{
options.Audience = "Redplace-With-Real-Audience-Info";
options.Authority = "Redplace-With-Real-Authority-Info";
});
}
Run Code Online (Sandbox Code Playgroud)
另外,请查看WebApp-WebAPI-OpenIdConnect-AspNet5示例。
| 归档时间: |
|
| 查看次数: |
1636 次 |
| 最近记录: |