[英]Azure easy auth get user role based on AD user Id ASP.net core app WebAPI
I'm following link to make authentication and authorization.我正在关注链接以进行身份验证和授权。
I able to create successfully token based on https://login.microsoftonline.com/{tenantID}/oauth2/token我能够基于https://login.microsoftonline.com/{tenantID}/oauth2/token成功创建令牌
After that I calling GET API using sayhello.之后,我使用 sayhello 调用 GET API。 It's everything fine, but I want based on token and UserId/Password of AD user get user role.一切都很好,但我想根据 AD 用户的令牌和 UserId/Password 获取用户角色。 I search a lot but not getting any concrete solution.我搜索了很多,但没有得到任何具体的解决方案。
To decode the Azure Active Directory JWT token using the tool, you can use this online decode tool JSON Web Tokens - jwt.io . To decode the Azure Active Directory JWT token using the tool, you can use this online decode tool JSON Web Tokens - jwt.io .
Here is an example covered of how to verify and decode Azure Active Directory Token, refer this article .这是一个关于如何验证和解码 Azure Active Directory 令牌的示例,请参阅本文。
If you want to manually decode a bearer token using azure active directory, you can use JwtBearer
or AddAzureADBearer
middleware to validate the access token.如果要使用 azure 活动目录手动解码持有者令牌,可以使用JwtBearer
或AddAzureADBearer
中间件来验证访问令牌。
Please refer this thread which contains code to decode a bearer token.请参考这个线程,其中包含解码承载令牌的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.