Class AuthController
- Namespace
- FishMMO.ControlPanel.Controllers
- Assembly
- FishMMO-ControlPanel.dll
Sign-in, two-factor, step-up, the self-service two-factor reset, and sign-out.
[ApiController]
[Route("api/auth")]
[EnableRateLimiting("Auth")]
public sealed class AuthController : ControllerBase
- Inheritance
-
AuthController
- Inherited Members
Remarks
The password never reaches this controller. The browser runs SRP-6a against the same parameters the game client uses and sends a public ephemeral and a proof; the challenge endpoint takes a username and nothing else.
Nothing here is audited: it is a player (or an operator) authenticating as themselves, on anonymous or TwoFactorPending endpoints the audit filter excludes.
Constructors
AuthController(SrpLoginService, TwoFactorService, TwoFactorResetFlow, TwoFactorResetOptions, PanelSessionManager, IWebHostEnvironment, ILogger<AuthController>)
public AuthController(SrpLoginService srp, TwoFactorService twoFactor, TwoFactorResetFlow reset, TwoFactorResetOptions resetOptions, PanelSessionManager sessions, IWebHostEnvironment environment, ILogger<AuthController> log)
Parameters
srpSrpLoginServicetwoFactorTwoFactorServiceresetTwoFactorResetFlowresetOptionsTwoFactorResetOptionssessionsPanelSessionManagerenvironmentIWebHostEnvironmentlogILogger<AuthController>
Methods
Challenge(ChallengeRequest)
SRP message one.
[HttpPost("srp/challenge")]
[AllowAnonymous]
public Task<IActionResult> Challenge(AuthController.ChallengeRequest request)
Parameters
requestAuthController.ChallengeRequest
Returns
CompleteTwoFactorReset()
Uses an effective reset: the old factor is replaced and the new one handed over. Does NOT sign in.
[HttpPost("2fa/reset/complete")]
[Authorize(Policy = "TwoFactorPending")]
public Task<IActionResult> CompleteTwoFactorReset()
Returns
Remarks
Every panel session on the account is revoked, this one included, and this browser is given a
fresh session that has proven the password only. It becomes a signed-in session through
2fa/reset/confirm with a code from the new authenticator, and not before.
ConfirmTwoFactorReset(CodeRequest)
Finishes a completed reset with a code from the NEW authenticator, and only then signs in.
[HttpPost("2fa/reset/confirm")]
[Authorize(Policy = "TwoFactorPending")]
public Task<IActionResult> ConfirmTwoFactorReset(AuthController.CodeRequest request)
Parameters
requestAuthController.CodeRequest
Returns
Remarks
Recovery codes are refused here: the point of this step is proving the new authenticator was actually saved, and a recovery code shown on the same screen proves nothing about that.
GetTwoFactorReset()
The pending reset for this signed-in-by-password session's account, if any.
[HttpGet("2fa/reset")]
[Authorize(Policy = "TwoFactorPending")]
public Task<IActionResult> GetTwoFactorReset()
Returns
Logout()
Ends this session.
[HttpPost("logout")]
[AllowAnonymous]
public Task<IActionResult> Logout()
Returns
Remarks
The cookie is deleted whatever happens, but "signed out" is only answered once the session row is revoked. Deleting the cookie ends this browser's copy; the row is what ends every other copy of it, and a logout that reported success while the row lived on left a copied cookie working until the idle timeout.
Proof(ProofRequest)
SRP message two.
[HttpPost("srp/proof")]
[AllowAnonymous]
public Task<IActionResult> Proof(AuthController.ProofRequest request)
Parameters
requestAuthController.ProofRequest
Returns
Remarks
A locked account, a wrong password, an unknown account and a banned one all answer 401 with
GenericFailure. The one different answer — 403, stage
verification-required — is given only after a CORRECT proof, so it reveals nothing to
anyone who does not already hold the password.
RequestTwoFactorReset()
Asks for a delayed two-factor reset. Asking again returns the same request; the clock never restarts.
[HttpPost("2fa/reset/request")]
[Authorize(Policy = "TwoFactorPending")]
public Task<IActionResult> RequestTwoFactorReset()
Returns
Session()
Describes the current session, or null when there is none.
[HttpGet("session")]
[AllowAnonymous]
public IActionResult Session()
Returns
StepUp(CodeRequest)
Re-proves the authenticator for a destructive action.
[HttpPost("step-up")]
[Authorize(Policy = "Self")]
public Task<IActionResult> StepUp(AuthController.CodeRequest request)
Parameters
requestAuthController.CodeRequest
Returns
VerifyTwoFactor(CodeRequest)
Completes a pending sign-in with a TOTP or recovery code.
[HttpPost("2fa/verify")]
[Authorize(Policy = "TwoFactorPending")]
public Task<IActionResult> VerifyTwoFactor(AuthController.CodeRequest request)
Parameters
requestAuthController.CodeRequest
Returns
Remarks
Counted and locked under AuthLockoutOptions. A good code also cancels any pending self-service two-factor reset, and the holder is emailed that it was.