Skip to content

Add support one-time token value customization #16946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

franticticktick
Copy link
Contributor

Closes gh-16939

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 16, 2025
Copy link
Contributor

@evgeniycheban evgeniycheban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, @franticticktick I've left one comment below with some thoughts regarding token value generation.

@Override
public GenerateOneTimeTokenRequest resolve(HttpServletRequest request) {
String username = request.getParameter("username");
if (!StringUtils.hasText(username)) {
return null;
}
return new GenerateOneTimeTokenRequest(username, this.expiresIn);
return new GenerateOneTimeTokenRequest(username, this.expiresIn, this.tokenValueFactory.get());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should not generate token value here, since it breaks the semantic of GenerateOneTimeTokenRequestResolver which is:
"A strategy for resolving a GenerateOneTimeTokenRequest from the HttpServletRequest".

It might also be confusing for users who provide a custom tokenValueFactory and notice that their factory gets called before OneTimeTokenService#generate method call.

So I would consider passing Supplier<String> tokenValueFactory to GenerateOneTimeTokenRequest and call it in the OneTimeTokenService#generate method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support one-time token value customization
3 participants