我的应用程序需要使用名为 Shibboleth 的 SSO 服务。所以我使用了现有的 shibboleth-bundle .事情发生了变化,我们需要为用户添加一个表单例份验证方法。因此,我决定使用新的 Guard 组件实现 Shibboleth 身份验证。 (参见 ShibbolethGuardBundle)
我在开发过程中发现了一个问题。 Symfony 在第一次请求时调用 ShibbolethAuthenticator
方法,创建一个 token 并且从不在以后的请求中调用任何 ShibbolethAuthenticator
方法。这意味着,如果 Shibboleth session 结束,用户仍然使用 Symfony session 进行身份验证。
如果要实现 token 认证,这也是一个问题。用户只需要在第一次请求时发送 token 。任何其他请求都由 session 进行身份验证。
此问题也存在于其他 SSO 服务中。如果您在 Facebook 注销,您希望在任何使用 Facebook 身份验证的网站上注销。但是如果你用 Guard 实现这个,你在 facebook 注销后仍然有一个有效的 session 。
我通过检查每次请求时是否在我的 UserProvider
中设置了 shibboleth header 变量,找到了一个快速解决方案。如果缺少它们,则会调用异常,并且我的 ExceptionListener
会重定向到登录页面。
我认为这不是一个好的解决方案,因为 ShibbolethGuardBundle 应该可以处理这个问题。有谁知道我该如何以更合适的方式解决这个问题?
最佳答案
我的看法是,第一次验证并发送用户数据是创建用户对象或为该网站签名。之后,您将使用来自 SSO 服务的数据与站点 A 进行 session ,我认为这是预期的行为。它不是与 SSO 服务同步登录/注销。
一种解决方法:在 http://romain.pechayre.me/blog/2015/06/26/single-sign-out-problem/ 中它描述了谷歌如何处理这个问题(不确定这是否仍然是最新的,但它仍然与你的问题相关):
When signing out from gmail a few days ago, I noticed my browser visited blogger.com for 0.5 second. I went back to blogger.com and realized I was logged out. Same on youtube.com. [...] The main idea is that the browser actually visits all website from Google on which I have the session and closes the session on all of them. [...] The main reason why signing out from several websites in one click is not well documented is because it is not a very common situation. When this problem arises it is probably fixed using a custom, in-house implementation.
关于php - Symfony Guard 组件和无状态身份验证 (Shibboleth),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40234754/