简体   繁体   English

如何确定用户是否仍在使用 PingFederate OpenID Connect 隐式客户端流程登录?

[英]How can I determine if a user is still logged in using the PingFederate OpenID Connect Implicit Client flow?

鉴于用户使用隐式客户端流登录到我的应用程序的场景,其中 OP 是 PingFederate,我如何确定用户是否仍然登录,如果他们关闭了应用程序并在有效的时间内返回到它时间段?

Resurrecting an old question since OpenID Connect is still widely used.重新提出一个老问题,因为 OpenID Connect 仍然被广泛使用。 To check if a user is authenticated--either from a previous session with your app, or from a session with another federated application--supply prompt=none in the authentication request.要检查用户是否已通过身份验证——无论是来自与您的应用程序的先前会话,还是来自与另一个联合应用程序的会话——在身份验证请求中提供prompt=none Per the spec , the documentation on prompt=none states:根据规范,关于prompt=none的文档指出:

The Authorization Server MUST NOT display any authentication or consent user interface pages.授权服务器不得显示任何身份验证或同意用户界面页面。 An error is returned if an End-User is not already authenticated or the Client does not have pre-configured consent for the requested Claims or does not fulfill other conditions for processing the request.如果最终用户尚未通过身份验证,或者客户没有对请求的声明预先配置同意或不满足处理请求的其他条件,则会返回错误。 The error code will typically be login_required, interaction_required, or another code defined in Section 3.1.2.6.错误代码通常是 login_required、interaction_required 或第 3.1.2.6 节中定义的其他代码。 This can be used as a method to check for existing authentication and/or consent .这可以用作检查现有身份验证和/或同意的方法

"Silent Authentication" uses this prompt=none parameter inside an iFrame. “静默身份验证”在 iFrame 中使用这个prompt=none参数。 Auth0 has some discussion on it, here . Auth0 对此有一些讨论, 这里 In a nutshell, the authentication request is made in an invisible iFrame so that the user agent's main frame is not redirected.简而言之,身份验证请求是在不可见的 iFrame 中进行的,因此不会重定向用户代理的主框架。 Depending on your identity provider (IdP), this may or may not be a valid option.根据您的身份提供商 (IdP),这可能是也可能不是有效选项。 For security reasons, authorization endpoints often deny requests made in frames using the X-Frame-Options: DENY header.出于安全原因,授权端点通常使用X-Frame-Options: DENY标头拒绝在帧中发出的请求。 Cookie origin policies on the IdP may also prevent silent authentication. IdP 上的 Cookie 源策略也可能会阻止静默身份验证。 That said, the same can be accomplished with eg a popup or a full User Agent redirect on initial load of the SPA.也就是说,同样可以通过在 SPA 的初始加载时使用例如弹出窗口或完整的用户代理重定向来实现。

It's worth pointing out that the Implicit Flow has been deprecated for a long time due to a wide range of security issues, many of which do not have sufficient mitigation strategies.值得指出的是,由于广泛的安全问题,隐式流已被弃用很长时间,其中许多没有足够的缓解策略。 The OAuth 2.0 for Browser-Based Apps describes current best practices. 基于浏览器的应用程序OAuth 2.0描述了当前的最佳实践。 Nowadays the Code Flow with PKCE can be used, but it still has a number of security issues that cannot be sufficiently mitigated (again described in the best practices doc).现在可以使用带有 PKCE 的代码流,但它仍然存在许多无法充分缓解的安全问题(在最佳实践文档中再次描述)。

Code Flow with a back-end session server in an edge device (a server between your SPA and API server) is the best bet security wise.在边缘设备(SPA 和 API 服务器之间的服务器)中使用后端会话服务器的代码流是安全方面的最佳选择。 This approach keeps tokens out of the User Agent altogether, helping to mitigate token leaks through XSS attacks, and if done correctly, CSRF attacks become impotent.这种方法将令牌完全排除在用户代理之外,有助于减轻通过 XSS 攻击造成的令牌泄漏,如果正确完成,CSRF 攻击将变得无能为力。 Pertaining to the question, a long-lived refresh token can be stored in the session server, and can be used to persist authentication across page refreshes or closing the browser.关于这个问题,一个长期存在的刷新令牌可以存储在会话服务器中,并且可以用于跨页面刷新或关闭浏览器来保持身份验证。 Here is a write-up on this approach. 这里有一篇关于这种方法的文章。

Addressing one of the comments above: "Why would a user that closes a website after completing authN expect the AuthN to still be valid after that closure?"解决上述评论之一:“为什么在完成 authN 后关闭网站的用户希望 AuthN 在关闭后仍然有效?” Because it's better user experience, and expected user experience nowadays.因为它是更好的用户体验,并且是当今预期的用户体验。 Think about Google, Atlassian, or even this very site (StackOverflow): A user logs in once and pretty much never has to log in again, provided that user interacts with the site frequently and doesn't raise any security red-flags.想想谷歌、Atlassian 甚至这个网站 (StackOverflow):只要用户经常与网站交互并且不会引发任何安全危险信号,用户登录一次并且几乎不需要再次登录。

Addressing another comment: "If you got to the point of where the application now has an 'ID Token', that's the key. For as long as the token is valid (check expiry time)."解决另一条评论:“如果您到了应用程序现在拥有‘ID 令牌’的地步,那就是关键。只要令牌有效(检查到期时间)。” Both ID Tokens and Access Tokens should expire quickly, while Refresh Tokens should be long-lived. ID Tokens 和 Access Tokens 都应该很快过期,而 Refresh Tokens 应该是长期存在的。 This way, if the IdP revokes access for a user, the revocation will quickly propagate to all Client applications.这样,如果 IdP 撤消用户的访问权限,撤消将迅速传播到所有客户端应用程序。

暂无
暂无

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

相关问题 如何安全地确定用户是否使用客户端会话登录 - How to securely determine if user is logged in using client-session 如何确定我在客户端上的登录状态? [结束] - How can I determine my logged in status on the client? [finished] 如何检查Django用户是否仍然只从客户端登录? - How to check if a Django user is still logged in from the client side only? 使用IE,Jsonp和OpenID,如何获取数据发送服务器以查看客户端已通过身份验证? - Using IE, Jsonp and OpenID how can I get the data sending server to see the client as authenticated? 如何确定用户是否仍在使用基于会话的身份验证登录? - How to find out if user is still logged in using session based authentication? 如何使用javascript确定登录用户的浏览器版本和IP地址 - how to determine the browser version and IP address of logged in user using javascript 如何使用 VueJS、NUXT 和 NODEjs 在客户端计算机上获取当前登录到操作系统的用户 - How do I fetch the user currently logged into the OS on the client computer, using VueJS, NUXT and NODEjs 如何保持用户使用redux登录? - How can I keep a user logged in with redux? 如何知道用户是否已登录? - how can I know if user is logged in 如果用户在 javascript 应用程序在 Z226776F3561A5D33FZ0BAB 中仍然处于活动状态,我如何扩展 Joomla session? - How can i extend Joomla session if user still active on client javascript application in joomla?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM