Files

5.7 KiB

ADDED Requirements

Requirement: Login history

The system SHALL record every admin sign-in attempt, sign-out, unlock and own password change, with the time, trimmed username, event, client IP, user agent and, for a known username, the user's company. Events: LOGIN_SUCCESS, LOGIN_FAIL, LOGIN_LOCKED, LOGOUT, UNLOCK_RESET, PASSWORD_CHANGED. Recording SHALL be best-effort and MUST NOT change the sign-in answer. A blank username or password SHALL NOT be recorded.

Scenario: Successful sign-in is recorded

  • WHEN sales1 signs in with the right password
  • THEN a LOGIN_SUCCESS record for sales1 is saved with the time, client IP and user agent

Scenario: Failed sign-in is recorded

  • WHEN someone signs in as sales1 with a wrong password
  • THEN a LOGIN_FAIL record for sales1 is saved

Scenario: Unknown username is recorded

  • WHEN someone signs in as nobody1, which matches no user
  • THEN a LOGIN_FAIL record for nobody1 is saved with no company

Scenario: Sign-out is recorded

  • WHEN sales1 signs out
  • THEN a LOGOUT record for sales1 is saved

Scenario: History write failure does not block sign-in

  • GIVEN the history cannot be written
  • WHEN sales1 signs in with the right password
  • THEN the sign-in succeeds
  • AND the write failure is logged

Requirement: Lockout after repeated failures

The system SHALL lock a username when lockout is on and its LOGIN_FAIL records reach the configured maximum, counting only records inside the configured period and after its latest LOGIN_SUCCESS, UNLOCK_RESET or PASSWORD_CHANGED. The maximum, period, unit and on/off switch SHALL come from settings. Failures SHALL count for unknown usernames too, so a lock does not reveal whether an account exists. The lock SHALL end once the counted failures leave the period.

Scenario: Maximum reached locks the username

  • GIVEN lockout is on with a maximum of 5 in 15 minutes
  • WHEN sales1 fails to sign in 5 times within 15 minutes
  • THEN sales1 is locked

Scenario: Old failures do not count

  • GIVEN lockout is on with a maximum of 5 in 15 minutes
  • WHEN sales1 has 4 failures within the last 15 minutes and 3 older ones
  • THEN sales1 is not locked

Scenario: A success resets the count

  • WHEN sales1 fails 4 times, signs in successfully, then fails 4 more times within 15 minutes
  • THEN sales1 is not locked

Scenario: Lockout switched off

  • GIVEN lockout is off
  • WHEN sales1 fails 10 times within 15 minutes
  • THEN sales1 is not locked

Requirement: Locked username is refused

The system SHALL refuse sign-in for a locked username before checking the password, with the code ACCOUNT_LOCKED and a message telling the user to try later or ask an administrator, and SHALL record LOGIN_LOCKED. When the lock state cannot be read because of an infrastructure error, sign-in SHALL proceed to the normal password check.

Scenario: Right password while locked

  • GIVEN sales1 is locked
  • WHEN sales1 signs in with the right password
  • THEN sign-in is refused with ACCOUNT_LOCKED
  • AND no session is issued
  • AND a LOGIN_LOCKED record is saved

Scenario: Lock check unavailable

  • GIVEN the lock state cannot be read
  • WHEN sales1 signs in with the right password
  • THEN the sign-in succeeds

Scenario: Portal shows the locked message

  • WHEN sign-in is refused with ACCOUNT_LOCKED
  • THEN the login page shows the locked message instead of "Invalid username or password"

Requirement: Unlock

The system SHALL let an admin with BO_LOGIN_SECURITY list the usernames that are locked now, with their failure count, last failure time and when the lock ends, and SHALL let that admin unlock one. Unlocking SHALL save an UNLOCK_RESET record naming the admin who unlocked.

Scenario: Unlock a locked username

  • GIVEN sales1 is locked
  • WHEN an admin with BO_LOGIN_SECURITY unlocks sales1
  • THEN sales1 no longer appears in the locked list
  • AND sales1 can sign in with the right password
  • AND an UNLOCK_RESET record for sales1 names the admin

Requirement: Login history screen

The system SHALL let an admin with BO_LOGIN_SECURITY read the login history, newest first and paged, filtered by username, event and date range.

Scenario: Filter by event

  • WHEN an admin filters the history by event LOGIN_FAIL
  • THEN only LOGIN_FAIL records are listed, newest first

Scenario: Without the module

  • WHEN an admin without BO_LOGIN_SECURITY calls the login-security API
  • THEN the request is refused with 403

Requirement: Lockout and password-rule settings

The system SHALL let an admin with BO_LOGIN_SECURITY read and change the lockout settings (on/off, maximum attempts, period, time unit) and the admin password rules (each rule's on/off status and value). The system SHALL reject a maximum below 1 or above 1000, a period below 1 or above 10000, and a time unit other than S, M, H or D. Password rules SHALL only be edited, never added or removed. Every change SHALL write a log line naming the admin.

Scenario: Change the lockout settings

  • WHEN an admin sets the maximum to 3 and the period to 30 minutes
  • THEN the next lock decision uses 3 attempts in 30 minutes

Scenario: Invalid setting

  • WHEN an admin sets the maximum to 0
  • THEN the change is refused with a validation error and the settings stay as they were

Scenario: Change a password rule

  • WHEN an admin sets the minimum length rule to 10
  • THEN a new password of 9 characters is refused by every admin password check