简体   繁体   English

Keycloak Action Tokens:当用户请求多个(例如重置密码)时如何使用户之前的操作无效

[英]Keycloak Action Tokens: How to invalidate user's previous action when they request multiple (e.g. Reset Password)

I want to be able to invalidate any action token for a user within an authentication flow.我希望能够使身份验证流程中用户的任何操作令牌无效。

The scenario is the user sends a reset password and receives an email with an associated action token.该场景是用户发送重置密码并收到带有关联操作令牌的 email。 The user then sends another reset password and gets another email with a different action token associated.然后,用户发送另一个重置密码并获得另一个 email,其中关联了不同的操作令牌。 For the length of the first action token expiry time the user can utilise the links in both emails - however I'd like to be able to identify within my custom reset password authentication flow that the user is requesting a duplicate action request and invalidate their earlier action token(s) so that only their latest reset password link works.对于第一个操作令牌到期时间的长度,用户可以使用两封电子邮件中的链接 - 但是我希望能够在我的自定义重置密码身份验证流程中识别用户正在请求重复的操作请求并使他们之前的无效操作令牌,以便只有他们最新的重置密码链接有效。

I've been looking at the below objects but had no luck finding an action token store associated with all the user's activity rather than just their current authenticated session.我一直在查看以下对象,但没有找到与所有用户活动关联的操作令牌存储,而不仅仅是他们当前经过身份验证的 session。

AuthenticationFlowContext context;

            List<UserSessionModel> sessions = context.getSession().sessions().getUserSessions(context.getRealm(), user);

            RootAuthenticationSessionModel parentSessions = context.getAuthenticationSession().getParentSession();

            ActionTokenStoreProvider actionTokenStore = session.getProvider(ActionTokenStoreProvider.class);

Thanks in advance.提前致谢。

I've resolved this by maintaining a Table of users and action tokens per flow.我通过为每个流维护一个用户表和操作令牌来解决这个问题。 This means when the user initiates a new action flow I can grab the previous token if still valid and use the ActionTokenStoreProvider to invalidate it replacing it with the new token.这意味着当用户启动一个新的操作流程时,我可以获取之前的令牌(如果仍然有效)并使用 ActionTokenStoreProvider 使其无效并用新令牌替换它。 I am still hoping keycloak has some internal mechanism to manage this rather than my own custom code.我仍然希望 keycloak 有一些内部机制来管理这个而不是我自己的自定义代码。 Drop a solution if you know of this!如果您知道这一点,请放弃解决方案!

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

相关问题 登录后获取servlet用户凭证(密码),例如从j_security_check - Obtain servlet user credentials (password) after login, e.g. from j_security_check 提供凭据作为命令行 arguments 安全吗? (例如 wget --user --password) - Is providing credentials as command line arguments safe? (e.g. wget --user --password) 使以前的令牌无效并检查用户是否有 JWT 令牌 - invalidate previous tokens and check a user has JWT token or not 从github隐藏我的敏感信息(例如密码) - Hiding my sensitive information (e.g. password) from github Laravel隐藏属性。 例如密码 - 安全 - Laravel hidden attributes. e.g. Password - security 对来自多个来源(例如 Cognito 和 Azure)的令牌进行身份验证 - Authenticating tokens from multiple sources (e.g Cognito and Azure) 如何使用AWS SDK v2.4.7通过外部提供商(例如Google)对最终用户进行身份验证? - How to use AWS SDK v2.4.7 to authenticate end user via external provider (e.g., Google)? 如何在 Javascript 的 Keycloak 中获取当前登录用户的密码? - How can I get the current logged in user's password in Keycloak in Javascript? 通过AJP将REMOTE_USER转发给tomcat(例如shibboleth) - Forward REMOTE_USER to tomcat via AJP (e.g. for shibboleth) 使用Django检查每个操作请求的用户身份验证 - check user authentication on every action request with Django
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM