2

我将Ory Hydra作为 OAuth 2.0 / OpenID 提供者运行。

我想组合一个解决方案,以便中继方可以检查最终用户的 OpenID 会话状态。他们是否登录、注销等。OpenID 规范有一个使用此处指定的 iframe 的解决方案。我在此解决方案中遇到的主要问题在此处的 OpenID Connect 会话管理规范的第 5.1 节中进行了描述:

Note that at the time of this writing, some User Agents (browsers) are starting to block access to third-party content by default to block some mechanisms used to track the End-User's activity across sites. 
Specifically, the third-party content being blocked is website content with an origin different that the origin of the focused User Agent window. 
Site data includes cookies and any web storage APIs (sessionStorage, localStorage, etc.).

This can prevent the ability for notifications from the OP at the RP from being able to access the RP's User Agent state to implement local logout actions. 
In particular, cookies and web storage APIs may not be available in the OP frame loaded in the RP context. The side effect here is that, depending on the used mechanism (cookies or web storage), the data needed to recalculate session_state might not be available. 
Cookie based implementations might then return changed for every single call, resulting in infinite loops of re-authentications. 
Therefore, deployments of this specification are recommended to include defensive code to detect this situation, and if possible, notify the End-User that the requested RP logouts could not be performed. 
The details of the defensive code needed are beyond the scope of this specification; it may vary per User Agent and may vary over time, as the User Agent tracking prevention situation is fluid and continues to evolve.

是否有另一种方法可以在不使用 iframe 实现的情况下查看最终用户是否具有 OpenID 会话?

4

1 回答 1

2

您始终可以使用访问令牌询问令牌自省端点,以查看访问令牌是否仍然有效。使用这种方法可以避免使用 iframe。作为替代方案,您可以使用短期访问令牌并使用刷新令牌来获取新的访问令牌。对于大多数情况,这可能是一个合适的折衷方案。

请参阅此处的令牌自省规范,本教程也是一个很好的起点

在调用此端点的响应中,您应该找到一个活动字段,如果用户仍处于登录状态,则该字段应设置为 true。

规范说:

主动要求。显示的令牌当前是否处于活动状态的布尔指示符。令牌的“活动”状态的细节将根据授权服务器的实现和它保存的有关其令牌的信息而有所不同,但是“活动”属性的“真实”值返回通常表明给定的令牌已经由该授权服务器发布,未被资源所有者撤销,并且在其给定的有效时间窗口内(例如,在其发布时间之后和到期时间之前)。

于 2020-12-27T20:24:43.993 回答