How to Limit Login Attempts While Letting Account Owners Regain Access
A temporary lockout restricts further login attempts after a set number of failures. When configuring it, check both sides of the rule: the restriction takes effect and expires on schedule, or is removed through an already implemented and separately tested recovery flow according to product policy. This requires measurable acceptance criteria, not just a message saying ‘Try again later.’ We will walk through configuration and testing using an explicitly fictional product called Mayak.
Define three parameters first
A lockout policy includes a failed-attempt threshold N, an observation window W and a restriction duration D. Choose these parameters with security and usability in mind. There are no universal values for every product: the team must document its own rules and expected behavior.
For this educational scenario in the fictional Mayak product, we will choose five failures within ten minutes and a fifteen-minute lockout. These are illustrative settings, not an OWASP recommendation. We will also specify that failures within the preceding ten minutes count, an attempt exactly at the window boundary is excluded, and requests during a lockout do not extend its duration. These details turn a general configuration into a testable requirement.
Associate the restriction with the account
The failed-login counter should be associated with the account rather than the source IP address. In Mayak’s tests, switching test clients must therefore leave the accumulated failures for an account intact. Check another account’s state separately: it must not be considered locked merely because it is used through the same test client.
In this scenario, the trust boundary lies between password entry and granting normal authenticated access. While a lockout is active, even the correct password must not allow a normal login. For the recovery flow that has already been tested, specify separately when it should remove the current restriction.
Test the threshold and window boundaries
All checks described below are an original editorial test plan, not an official procedure. Run them only in your own test environment, using synthetic accounts and a controlled email receiver. Start with a positive control: the correct password for an unlocked account should create a normal authenticated session.
Using separate accounts, check the state after four failures and after the fifth failure within the chosen window. Before the threshold, the correct password should allow login; after the threshold, it should no longer do so. Compare the result with the lockout state and log entry. Separately, place failures around the ten-minute window boundary and verify the agreed counting rule.
Repeat the scenario with two controlled clients using one account. The acceptance criterion is that failures accumulate according to policy regardless of client changes. Use another synthetic account to check that account states remain independent. A single successful HTTP response confirms neither session creation nor enforcement of the restriction.
Verify that the restriction actually expires
Record the lockout start time and its expected expiration fifteen minutes later. Before expiration, verify that a normal login with the correct password is denied; after expiration, verify that an authenticated session is successfully created. Compare the observed result with the account state and logs, rather than relying solely on the notification text.
Requests made during the restriction need a separate scenario. Under Mayak’s agreed policy, they do not shift the expiration time: after the original expiration time, the owner should be able to log in with the correct password. If the expiration unexpectedly moves, fix the expiration calculation or the handling of repeated requests, then rerun this scenario.
Test lockout removal through recovery
Keeping recovery available through the forgot-password feature is one way to reduce the risk of denying the owner access. For Mayak, we will explicitly define this rule: successfully completing the designated recovery flow removes the current temporary lockout. This is a fictional product decision that must be separately adopted and tested.
The prerequisite is that the recovery flow has already been implemented and separately tested. Its procedure is covered in the existing article ‘How to Design a Password Reset: Link Expiration, Single Use and Sessions.’ Here, we test only how that flow interacts with a temporary lockout.
On a synthetic account, reach the threshold of five failures within ten minutes and record the active lockout. Complete the already tested recovery flow before the fifteen minutes expire. The acceptance criterion is that the current restriction is removed at the point specified by policy. Testing before the original expiration time distinguishes removal through recovery from normal expiration.
Check lockout state transitions
Compare the results of the individual scenarios: after N failures within W, the restriction is active; requests during it do not shift its expiration; it expires after D; and successful recovery removes it earlier according to Mayak’s rule. For each scenario, record the expected and actual restriction state.
Lockout events should be logged and analyzed. Use the logs alongside the account state to verify the threshold, the start of the restriction and the time it expires or is removed. If observations differ, identify which transition does not match the policy, fix it and rerun the affected scenario.
Prioritize fixes and assess the limits of testing
First, fix deviations from the agreed rules: an incorrect threshold, a counter tied to the source rather than the account, unexpected extensions of the restriction, and failure to remove the lockout through the already tested recovery flow. Then rerun the affected scenarios, including window boundaries, expiration and early removal of the restriction. Acceptance requires confirmed lockout state transitions using your own test data.
These checks confirm behavior in the selected scenarios, but do not guarantee that access cannot be lost under any circumstances. To assess the implementation, you can start with a free audit of your website or the web portion of your product to review login attempt restrictions and the access recovery flow.