Skip to content

[OPEN-382] Enable Devise account lockout after failed logins - #630

Open
santostiago wants to merge 1 commit into
developfrom
sec/account-lockout
Open

[OPEN-382] Enable Devise account lockout after failed logins#630
santostiago wants to merge 1 commit into
developfrom
sec/account-lockout

Conversation

@santostiago

Copy link
Copy Markdown
Contributor

Summary

  • Enable Devise :lockable so accounts lock after 10 failed sign-in attempts
  • Unlock via email link or automatically after 1 hour
  • Wire lockout into the API /login endpoint (it previously bypassed Devise) and cover lock, unlock email, and unlock-link flows in specs

Test plan

  • Run bundle exec rspec spec/integration/v1/sessions_spec.rb
  • Confirm failed API logins increment failed_attempts and lock after 10 attempts
  • Confirm unlock instructions email is sent on lock and /admin/unlock?unlock_token=… unlocks the account
  • Confirm successful login resets failed_attempts
  • Confirm ActiveAdmin login is also blocked for locked users

Made with Cursor

Lock accounts after 10 failed attempts and allow unlock via email or after one hour, including the API login path that previously bypassed Devise lockable.

Co-authored-by: Cursor <cursoragent@cursor.com>
@santostiago

Copy link
Copy Markdown
Contributor Author

When my other PR gets merged I'll rebase this one and the brakeman issue should be solved.

@santostiago santostiago changed the title Enable Devise account lockout after failed logins [OPEN-382] Enable Devise account lockout after failed logins Jul 26, 2026
@santostiago
santostiago requested a review from tsubik July 26, 2026 12:08
@santostiago santostiago self-assigned this Jul 26, 2026
@tsubik

tsubik commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

There is a small issue with extra padding on the backoffice login page

image

@tsubik tsubik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good for the back office, only small issues. We also need to customize this for frontend apps. Not sure if in the same way as forgotten password, that is a lot of extra code to customize emails, or maybe there is a better way to keep the email but customize redirect after unlock - to not end up on backoffice log in page when operator account clicked unlock link.

@tsubik

tsubik commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Or maybe we can start with only the time strategy and allow admins to unlock users? Would be good to add some locked? information with a date to the user's show page as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants