从Azure AD认证应用程序服务后,如何获取用户和令牌详细信息?
我为App Services中的Azure托管了前端的React应用程序。我还有另一个用于为前端应用创建REST API的NodeJS应用程序。该应用程序托管在另一个应用程序服务上。
现在,我想使用Azure Active Directory集成前端应用程序的AD身份验证,我设法使用Easy Auth Process进行了操作。但是,一旦用户认证,我不知道如何获得(或传递到前端)用户和令牌细节。
查询的第二部分是,我想使用令牌将REST API传递到标题中并在后端验证它来保护我的REST API。我已经浏览了各种Microsoft文档,但我无法弄清楚如何做到这一点。
请帮助我获取用户和令牌详细信息。并请建议如何保护我的休息API。
I have a React Application for the Front end hosted on Azure in App Services. I also have another NodeJS app that I am using to create REST APIs for the front-end App. This App is hosted on another App Service.
Now, I want to integrate AD authentication for the front-end app using Azure Active Directory, which I have managed to do using the Easy Auth process. But I don't know how to get (or pass to the front end) the user and token details once the user is authenticated.
The second part of the query is, that I want to use the token to secure my REST APIs by passing it in the header and validating it in the backend. I have gone through various Microsoft documentation but I am not able to figure out how to do this.
Please help me in getting the user and token details. And please suggest how to secure my REST APIs.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过HTTP标头或端点 /.auth/me获取令牌。更多详细信息: https://learn.microsoft.com/en-us/azure/app-service/configure-authentication-oauth-tokens-tokens#retrieve-tokens-tokens-tokens-tokens-inapp-code
关于验证令牌请看一下: https://github.com/ Azure-Samples/Active-directory-dotnet-webapi-jwt-validation
You can get the tokens via http headers or via an endpoint /.auth/me. More details: https://learn.microsoft.com/en-us/azure/app-service/configure-authentication-oauth-tokens#retrieve-tokens-in-app-code
Regarding validating tokens, take a look at this: https://github.com/Azure-Samples/active-directory-dotnet-webapi-manual-jwt-validation