Class AccountHold
LIMIT sign-ins. Until this order an administrator's account was disabled at that point, so a stranger who knew the user name could disable it from one address in about 45 minutes (16 wrong passwords paced by the back-off's waits; order 562's finding, IZ-D-5); any other account waited the longest wait again and again. Now NO account is disabled by failed sign-ins: the account is HELD instead.While held, no sign-in attempt of the account is evaluated - the password is not even checked - and the attempt answers exactly as the back-off's existing wait does (TOO_MANY_INVALID_LOGINS_RETRY_LATER, which the client sees as "wrong user or password", the same as an unknown user). An attempt during the hold is not counted, so an attacker cannot keep the account held by hammering it. The hold ends by itself: the first one lasts FIRST_MS (30 minutes) from the failure that started it; a wrong password after it counts one more failure and starts the next hold, twice as long, up to MAX_MS (24 hours); a valid sign-in after the hold resets the count, as today. The hold is derived from the two columns the back-off already keeps in IZS.USERS (fail_count, last_fail): nothing new is stored, and a server restart changes nothing.
An administrator ends a hold in ServerAdmin's Edit user ("Unlock account" or Enable), the break-glass file (BreakGlassReset) ends the hold of the account it names, and so does a completed password reset or a password an administrator sets: all clear the two columns. The back-off's waits after 3, 4, 6, 10 and 12 failures are unchanged.
The hold number n of an account with failCount failures is failCount-LIMIT+1 (1 at the limit), and its length is min(FIRST_MS*2^(n-1),MAX_MS): 30 min, 1 h, 2 h, 4 h, 8 h, 16 h, then 24 h for every hold after the seventh.
- Author:
- Christopher Mindus
Field Summary
FieldsMethod Summary
Modifier and TypeMethodDescriptionstatic Stringdescribe(int failCount) Describes a hold for the log.static longheldUntil(int failCount, long lastFail, long now) Gets when the hold of an account ends, for display.static longheldUntil(UserInfoBase user, long now) Gets when the hold of an account ends, for display.static booleanisHeld(UserInfoBase user, long now) Checks if an account is held now.static longmillis(int failCount) Gets the length of the hold an account with this many failures is in.static intnumber(int failCount) Gets the number of the hold an account with this many failures is in or starts.static longremaining(int failCount, long lastFail, long now) Gets how much longer an account is held.static longuntil(int failCount, long lastFail) Gets when a hold ends.
Field Details
LIMIT
public static final int LIMITThe failed sign-ins at which the account is held: 15, where the administrator's disable was.- See Also:
FIRST_MS
public static final long FIRST_MSThe first hold, in milliseconds: 30 minutes.- See Also:
MAX_MS
public static final long MAX_MSThe longest hold, in milliseconds: 24 hours.- See Also:
Method Details
number
public static int number(int failCount) Gets the number of the hold an account with this many failures is in or starts.- Parameters:
failCount- The failed sign-ins of the account.- Returns:
- The hold number: 1 at the limit, 2 one failure later, ...; 0 below the limit.
millis
until
public static long until(int failCount, long lastFail) Gets when a hold ends.- Parameters:
failCount- The failed sign-ins of the account.lastFail- The time of the last failure in milliseconds since the epoch, 0 for never.- Returns:
- The end of the hold in milliseconds since the epoch; zero when the account is not at the limit or has no last failure.
remaining
public static long remaining(int failCount, long lastFail, long now) Gets how much longer an account is held.- Parameters:
failCount- The failed sign-ins of the account.lastFail- The time of the last failure in milliseconds since the epoch, 0 for never.now- The current time in milliseconds since the epoch.- Returns:
- The remaining milliseconds, positive while held; zero or negative when the account is not held (below the limit, or the hold is over).
isHeld
Checks if an account is held now.- Parameters:
user- The user.now- The current time in milliseconds since the epoch.- Returns:
- true while held, false otherwise.
heldUntil
Gets when the hold of an account ends, for display.- Parameters:
user- The user.now- The current time in milliseconds since the epoch.- Returns:
- The end of the hold in milliseconds since the epoch while held, zero otherwise.
heldUntil
public static long heldUntil(int failCount, long lastFail, long now) Gets when the hold of an account ends, for display.- Parameters:
failCount- The failed sign-ins of the account.lastFail- The time of the last failure in milliseconds since the epoch, 0 for never.now- The current time in milliseconds since the epoch.- Returns:
- The end of the hold in milliseconds since the epoch while held, zero otherwise.
describe
Describes a hold for the log.- Parameters:
failCount- The failed sign-ins of the account.- Returns:
- E.g. "lock 2 of the account, 1 hour".