简体   繁体   English

Azure AD - 多个选项卡或浏览器 - session 管理

[英]Azure AD - multiple tabs or browsers - session management

I'm trying to determine how to handle session management with multiple tabs and browsers.我正在尝试确定如何使用多个选项卡和浏览器处理 session 管理。 I want my react application to:我希望我的反应应用程序:

  • Only allow one active token, so that if you logged into a new tab or browser, the previous tab's session would end (or at least future requests on it would be invalid).只允许一个活动令牌,因此,如果您登录到新选项卡或浏览器,前一个选项卡的 session 将结束(或者至少将来对其的请求将无效)。 Currently I can log in any number of times in new tabs or different browsers and get a new token every time, the previous ones still work too.目前,我可以在新标签页或不同浏览器中多次登录,每次都获得一个新令牌,以前的令牌仍然有效。

  • If you duplicate tab, the same session / local storage info is there, so the token is the same, that's permissible.如果您复制选项卡,则存在相同的 session / 本地存储信息,因此令牌相同,这是允许的。

  • If you have two tabs via duplication, and you sign out of one, the other should stop working because the token should no longer be valid如果您通过复制有两个选项卡,并且您退出一个,另一个应该停止工作,因为令牌应该不再有效

I'm using the react-adal package and mainly followed This tutorial for session mgmnt but these are the missing requirements I'm trying to fill in. I can't find anything about these configurations in the AAD documentation.我正在使用 react-adal package 并主要遵循本教程 session mgmnt但这些是我试图填写的缺失要求。我在 AAD 文档中找不到关于这些配置的任何信息。 All I've found are timeout options, nothing about simultaneous tabs and different browsers.我发现的只是超时选项,与同时选项卡和不同浏览器无关。

There isn't a boilerplate solution I'm aware of.我知道没有样板解决方案。 However, if you are able to maintain in-process session state, or out-of-process (using Redis, SQL or storage account etc) then you could generate a single use token for each dynamic (state changing) content request. However, if you are able to maintain in-process session state, or out-of-process (using Redis, SQL or storage account etc) then you could generate a single use token for each dynamic (state changing) content request.

You will need to validate this token for each and every request and it must be associated with the user.您需要为每个请求验证此令牌,并且它必须与用户相关联。 If the user doesn't present a token, or there is a token mismatch, redirect them to the logout URL.如果用户没有提供令牌,或者令牌不匹配,请将他们重定向到注销 URL。 Your logic could overwrite the token on a new login thus rendering the old session invalid.您的逻辑可能会在新登录时覆盖令牌,从而使旧的 session 无效。 This is similar to anti-CSRF tokens.这类似于反 CSRF 令牌。

The tutorial you linked explains how you can log the user out.您链接的教程解释了如何注销用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM