Class SrpLoginService
- Namespace
- FishMMO.ControlPanel.Services
- Assembly
- FishMMO-ControlPanel.dll
The server half of the panel's SRP-6a login, using the same ServerSrpData and the same 2048-bit SHA-512 parameters the LoginServer uses.
public sealed class SrpLoginService
- Inheritance
-
SrpLoginService
- Inherited Members
Remarks
The panel never sees a password. It answers a challenge with the account's salt and a public ephemeral, then verifies the client's proof; only the proof crosses the wire.
An in-flight exchange has to survive between the two requests, so it is held in memory keyed by an opaque handle the browser echoes back. Memory rather than the database because it is worthless after ten seconds and worthless to anyone but the one browser that started it; the trade is that a panel restart mid-login makes the browser start again.
Lockout. The password step is counted in the database, in the same columns the LoginServer counts into, under AuthLockoutOptions. A locked account is refused before its proof is evaluated, and the refusal is GenericFailure — word for word the answer to a wrong password — so the lock never becomes a way to learn a name exists or a guess was right. The lookup and the count run for unknown and banned names too, so the two paths also cost the same round trips.
Constructors
SrpLoginService(IAccountService, PanelRegistrationOptions, VerificationOptions, AuthLockoutOptions, IServiceScopeFactory, ILogger<SrpLoginService>)
public SrpLoginService(IAccountService accounts, PanelRegistrationOptions options, VerificationOptions verification, AuthLockoutOptions lockout, IServiceScopeFactory scopes, ILogger<SrpLoginService> log)
Parameters
accountsIAccountServiceoptionsPanelRegistrationOptionsverificationVerificationOptionslockoutAuthLockoutOptionsscopesIServiceScopeFactorylogILogger<SrpLoginService>
Fields
GenericFailure
The one answer to every failed password step: wrong password, unknown account, banned account, expired exchange, and a sign-in that is locked.
public const string GenericFailure = "That username and password do not match an account, or sign-in is temporarily locked after repeated failures. Try again later."
Field Value
Methods
ChallengeAsync(string, CancellationToken)
Message one: look the account up and answer with its salt and a server ephemeral.
public Task<SrpLoginService.ChallengeResult> ChallengeAsync(string username, CancellationToken cancellationToken = default)
Parameters
usernamestringcancellationTokenCancellationToken
Returns
Remarks
An account that does not exist, or that is banned, gets a plausible fake salt and a
fake verifier. The exchange proceeds normally and fails at the proof, so the two cases
are indistinguishable in both timing shape and response shape. This is the same
property SrpService.DerivePerUsernameFakeSalt gives the game path.
An unverified account gets its REAL salt and verifier, and is marked. A wrong password still fails exactly as it would for anyone; a right one is told which verification codes it may enter instead of being handed a session. Before this, the unverified account was faked, and a player who had simply not typed their code was told their password was wrong.
There is no grace period. An account used to be let in until its first code had been delivered, which made "the mail relay is down" and "verification is required" the same thing for as long as the relay stayed down. Now an account owes a code from the moment it exists, and a player who never receives one reaches staff through the ticket three wrong codes open.
Proof(string, string, string)
Message two, with no lockout and no verification gate: a proof of the CURRENT password by a session that is already signed in (the password change).
public SrpLoginService.ProofResult Proof(string handle, string clientPublicEphemeral, string clientProof)
Parameters
Returns
Remarks
The exchange is removed before it is evaluated, so a handle is single-use and a wrong proof cannot be retried against the same server ephemeral.
SignInProofAsync(string, string, string, CancellationToken)
Message two for SIGN-IN: the lockout, the proof, the failure count, and the verification gate.
public Task<SrpLoginService.ProofResult> SignInProofAsync(string handle, string clientPublicEphemeral, string clientProof, CancellationToken cancellationToken = default)
Parameters
handlestringclientPublicEphemeralstringclientProofstringcancellationTokenCancellationToken
Returns
Remarks
- The exchange is removed before anything else, so a handle is single-use.
- A locked password step is refused WITHOUT evaluating the proof, with GenericFailure.
- A failed proof is counted; the failure that starts a lock queues one security notice.
- A good proof clears the count.
- A proven, unverified account is issued its Discord code if it is owed one and has none, and is told which codes it may enter.
VerificationRequiredMessage(AccountVerificationChannels)
The one message naming the codes an unverified account may enter.
public static string VerificationRequiredMessage(AccountVerificationChannels outstanding)
Parameters
outstandingAccountVerificationChannels
Returns
Remarks
Names every outstanding channel, because any one of them verifies the account: a player told only about the email may not think to look in Discord, where the code already is.