Skip to content
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

Add dynamic JWT Token expiry time #534

Closed
DoPaNik opened this issue Jan 11, 2024 · 0 comments · Fixed by #539
Closed

Add dynamic JWT Token expiry time #534

DoPaNik opened this issue Jan 11, 2024 · 0 comments · Fixed by #539

Comments

@DoPaNik
Copy link

DoPaNik commented Jan 11, 2024

Currently, the expiration time for JWT tokens is hardcoded to 7 days in the code. To enhance security measures, it is recommended to allow specifying the expiration time in minutes or hours dynamically.

public String createToken(final Principal principal, final List<Permission> permissions, final IdentityProvider identityProvider) {
    final Date today = new Date();
    final JwtBuilder jwtBuilder = Jwts.builder();
    jwtBuilder.setSubject(principal.getName());
    jwtBuilder.setIssuer(ISSUER);
    jwtBuilder.setIssuedAt(today);
    jwtBuilder.setExpiration(addDays(today, 7)); // Hardcoded expiration time

    // ... (additional code)

    // Request: Allow dynamic setting of token expiration time (in minutes or hours)
}

Please consider implementing this enhancement for better flexibility and security in managing JWT token expiration times. Feel free to reach out if further clarification.

Feel free to add specific implementation approaches in the comments, and I will try to create a PR by myself as soon as possible.

Best
DoPaNik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant