Feature Request: tokenExpiration for RegistrationCode instances
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
I have searched through this plugin's documentation and on StackOverflow and haven't found anything providing this functionality.
A potential security issue I've noticed while using the application is that RegistrationCode tokens don't expire by default. The way I've had to force them to expire (I'm only using the forgotPassword workflow) is to override [RegisterController.resetPassword](https://github.com/grails-plugins/grails-spring-security-ui/blob/master/plugin/grails-app/controllers/grails/plugin/springsecurity/ui/RegisterController.groovy#L252). Then I can compare the current server time to the dateCreated attribute of RegistrationCode and, if the duration between is greater than 24 hours for instance, block the password reset attempt.
What would be preferable is if this were a simple configuration item for users of the plugin. I propose something like:
`grails.plugin.springsecurity.ui.forgotPassword.expireAfter = 1d`
Where a default value of `0` would mean no expiration and would provide backward compatibility. The format for defining durations should be based on some common standard / library that's already in use by Grails but I'm personally not too picky.
I would like to see this implemented to make it easier to prevent cases where:
1. User requests a password reset, creating a never-expiring token.
2. User resets their password, never deletes the email, and goes about their business.
3. Some time later (months, years) User's email account is breached. Bad actor clicks on forgotPassword URL and resets User's password.
4. User is locked out of their account while Bad Actor has free access.
Contributor guide
Research direction
Start with RegisterController.resetPassword and the RegistrationCode dateCreated field referenced in the issue. Trace how forgotPassword configuration is loaded and how reset tokens are validated. Done means an expireAfter setting supports a documented duration, defaults to no expiration for compatibility, and prevents expired password-reset attempts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- authentication, security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100