MVC-6 vs MVC-5 BearerAuthentication in Web API

China☆狼群 提交于 2019-11-30 18:10:05

TL;DR: you can't.

Authority refers to an OpenID Connect feature that has been added to the bearer middleware in ASP.NET 5: there's no such thing in the OWIN/Katana version.

Note: there's an app.UseJwtBearerAuthentication extension for Katana, but unlike its ASP.NET 5 equivalent, it doesn't use any OpenID Connect feature and must be configured manually: you'll have to provide the issuer name and the certificate used to verify tokens' signatures: https://github.com/jchannon/katanaproject/blob/master/src/Microsoft.Owin.Security.Jwt/JwtBearerAuthenticationExtensions.cs

JavaScript Linq

You can get claims as:

 IAuthenticationManager AuthenticationManager
 {
    get
    {
        return Request.GetOwinContext().Authentication;
    }
}

public IHttpActionResult UserRoles()
{
 return ok(AuthenticationManager.User.Claims.ToList());
}

This code should be in [Authorize] controller.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!