这个问题与 passport-azure-ad, does it parse & validate token?
我尝试掌握使用 Passport-azure-ad 模块。我使用 OpenID Connect 成功登录我的用户,获取 access_token 并直接使用我的 REST API,该 API 由 app.get('myapi',passport.authenticate('oath-bearer',
{失败重定向:'/'}),
函数(req,res){});
但是,如果我尝试从 OpenID connect 创建的 session 中注销, token 仍然有效,直到过期(通常为 3600 秒)。
我使用 access_token 来保护我的端点不托管在 Microsoft 的 API 网关后面,因此我猜想撤销 access_token 并不简单。
有什么方法可以检查 access_token 是否已使用 Passport-azure-ad 撤销?最佳实践是什么?
最佳答案
根据Azure Document上的描述:
While directing the user to the
end_session_endpoint
will clear some of the user's single sign-on state with Azure AD B2C, it will not sign the user out of the user's social identity provider (IDP) session. If the user selects the same IDP during a subsequent sign-in, they will be reauthenticated, without entering their credentials. If a user wants to sign out of your B2C application, it does not necessarily mean they want to sign out of their Facebook account entirely. However, in the case of local accounts, the user's session will be ended properly.
因此您可以直接使用end_session_endpoint
。您可以在 b2c_1_sign_in
策略端点的元数据文档中找到它,例如:
就像您在 v1 中使用常见的 Azure AD 应用程序一样,您还可以在元数据文档中找到 end_session_endpoint
,例如:
https://login.microsoftonline.com/fabrikamb2c.onmicrosoft.com/.well-known/openid-configuration
您可以引用Azure Active Directory B2C: Web sign-in with OpenID Connect了解更多信息。
如有任何进一步的疑问,请随时告诉我。
关于node.js - Passport-azure-ad, token 验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41182170/