Table of Contents

Class AccountController

Namespace
FishMMO.ControlPanel.Controllers
Assembly
FishMMO-ControlPanel.dll

Player self-service: registration, verification, and the signed-in account's own profile.

[ApiController]
[Route("api/account")]
public sealed class AccountController : ControllerBase
Inheritance
AccountController
Inherited Members

Remarks

Registration performs the same steps in the same order as the LoginServer's account creation pipeline, so an account made here and an account made in the game client are indistinguishable afterwards. See AccountRegistrationService.

Constructors

AccountController(AccountRegistrationService, SelfServiceService, PasswordResetService, SrpLoginService, TwoFactorService, PanelRegistrationOptions, IAccountService, IWebSessionService, PanelSessionManager, IWebHostEnvironment, RegistrationFormTokenService, IBetaCodeService, VerificationOptions, BetaOptions, ILogger<AccountController>)

public AccountController(AccountRegistrationService registration, SelfServiceService selfService, PasswordResetService passwordReset, SrpLoginService srp, TwoFactorService twoFactor, PanelRegistrationOptions options, IAccountService accounts, IWebSessionService webSessions, PanelSessionManager sessions, IWebHostEnvironment environment, RegistrationFormTokenService formTokens, IBetaCodeService betaCodes, VerificationOptions verification, BetaOptions beta, ILogger<AccountController> log)

Parameters

registration AccountRegistrationService
selfService SelfServiceService
passwordReset PasswordResetService
srp SrpLoginService
twoFactor TwoFactorService
options PanelRegistrationOptions
accounts IAccountService
webSessions IWebSessionService
sessions PanelSessionManager
environment IWebHostEnvironment
formTokens RegistrationFormTokenService
betaCodes IBetaCodeService
verification VerificationOptions
beta BetaOptions
log ILogger<AccountController>

Methods

BeginTwoFactorSetup()

Starts two-factor enrolment. Does not enable it.

[HttpPost("2fa/setup")]
[Authorize(Policy = "Self")]
public Task<IActionResult> BeginTwoFactorSetup()

Returns

Task<IActionResult>

Remarks

For an account whose two-factor is already ON this is a re-enrolment, and it replaces the live authenticator and every recovery code the moment it runs: the secret it writes is the one sign-in reads. That is the same weight as disabling two-factor or regenerating the codes, so it takes the same fresh step-up those do. Without it, a borrowed signed-in browser could swap the owner's authenticator for one of its own.

A first enrolment needs no step-up — there is no authenticator to prove, and nothing is enabled until 2fa/confirm.

ChangeEmail(ChangeEmailRequest)

Changes the contact email and restarts verification.

[HttpPost("email")]
[Authorize(Policy = "Self")]
public Task<IActionResult> ChangeEmail(AccountController.ChangeEmailRequest request)

Parameters

request AccountController.ChangeEmailRequest

Returns

Task<IActionResult>

ChangePassword(ChangePasswordRequest)

Changes the account password.

[HttpPost("password")]
[Authorize(Policy = "Self")]
public Task<IActionResult> ChangePassword(AccountController.ChangePasswordRequest request)

Parameters

request AccountController.ChangePasswordRequest

Returns

Task<IActionResult>

Remarks

The current password is proved by a full SRP exchange, not by sending it: the browser asks for a challenge, derives a proof from the password the user typed, and submits that alongside the new salt and verifier it derived locally. Neither password is ever transmitted, so there is nothing here that could leak one.

Every game token and every OTHER panel session is revoked on success. The session making the change survives, because signing the user out of the page they are looking at to tell them it worked is not an improvement.

Character(long, ICharacterService)

One of the signed-in account's characters.

[HttpGet("/api/characters/{id:long}")]
[Authorize(Policy = "Self")]
public Task<IActionResult> Character(long id, ICharacterService characters)

Parameters

id long
characters ICharacterService

Returns

Task<IActionResult>

Characters(ICharacterService)

The signed-in account's characters.

[HttpGet("/api/characters")]
[Authorize(Policy = "Self")]
public Task<IActionResult> Characters(ICharacterService characters)

Parameters

characters ICharacterService

Returns

Task<IActionResult>

Remarks

Read-only, and deliberately so. Creating and deleting a character are in-game only — deletion spans fourteen sub-entity tables inside one unit of work in the login server, and a second implementation of that is how a shard loses data.

CompletePasswordReset(PasswordResetCompleteRequest)

Completes a reset with a browser-derived salt and verifier.

[HttpPost("password-reset/complete")]
[AllowAnonymous]
[EnableRateLimiting("Register")]
public Task<IActionResult> CompletePasswordReset(AccountController.PasswordResetCompleteRequest request)

Parameters

request AccountController.PasswordResetCompleteRequest

Returns

Task<IActionResult>

Remarks

There is no password parameter here either. The browser generates a fresh salt and derives the verifier locally from the username this code resolved to, so the shard never holds anything a password could be recovered from.

ConfirmTwoFactorSetup(CodeRequest)

Enables two-factor once a code from the new authenticator verifies.

[HttpPost("2fa/confirm")]
[Authorize(Policy = "Self")]
public Task<IActionResult> ConfirmTwoFactorSetup(AuthController.CodeRequest request)

Parameters

request AuthController.CodeRequest

Returns

Task<IActionResult>

DisableTwoFactor()

Turns two-factor off, invalidating every recovery code with it.

[HttpDelete("2fa")]
[Authorize(Policy = "Self")]
public Task<IActionResult> DisableTwoFactor()

Returns

Task<IActionResult>

LookupPasswordReset(PasswordResetCodeRequest)

Returns the account name a reset code belongs to.

[HttpPost("password-reset/lookup")]
[AllowAnonymous]
[EnableRateLimiting("Register")]
public Task<IActionResult> LookupPasswordReset(AccountController.PasswordResetCodeRequest request)

Parameters

request AccountController.PasswordResetCodeRequest

Returns

Task<IActionResult>

Remarks

The browser cannot derive an SRP verifier without the username, because the username is an input to the key derivation. Holding the code already proves control of the mailbox the code was sent to, and the mail names the account, so answering this adds nothing an attacker did not already have.

The code travels in the BODY, never in the path or the query string: URLs end up in access logs, proxy logs, Referer headers and browser history, and a reset code in any of those is a reset code somebody else can use.

Me()

The signed-in account's own profile.

[HttpGet]
[Authorize(Policy = "Self")]
public Task<IActionResult> Me()

Returns

Task<IActionResult>

MyBetaCodes()

The beta codes the signed-in account has redeemed.

[HttpGet("beta")]
[Authorize(Policy = "Self")]
public Task<IActionResult> MyBetaCodes()

Returns

Task<IActionResult>

Policy()

Returns the account rules, so the browser can apply exactly the server's validation.

[HttpGet("policy")]
[AllowAnonymous]
public IActionResult Policy()

Returns

IActionResult

Remarks

It deliberately takes no input. An endpoint that answered "is this password allowed?" would require the password to be transmitted — which is the one thing this whole design exists to prevent. The rules come from Authentication, which the LoginServer uses too, so the browser, the game client and the server cannot drift.

RedeemBetaCode(RedeemBetaCodeRequest)

Redeems a beta code for the signed-in account.

[HttpPost("beta/redeem")]
[Authorize(Policy = "Self")]
[EnableRateLimiting("Auth")]
public Task<IActionResult> RedeemBetaCode(AccountController.RedeemBetaCodeRequest request)

Parameters

request AccountController.RedeemBetaCodeRequest

Returns

Task<IActionResult>

Remarks

For an account made before the gate went up, or whose redemption at registration lost a race for a code's last use. The service's refusal is passed through unaltered: it deliberately gives one message for every kind of bad code.

RegenerateRecoveryCodes()

Issues a fresh set of recovery codes, discarding the previous ones.

[HttpPost("2fa/recovery-codes")]
[Authorize(Policy = "Self")]
public Task<IActionResult> RegenerateRecoveryCodes()

Returns

Task<IActionResult>

Register(RegisterRequest)

Creates an account from a browser-computed SRP salt and verifier.

[HttpPost("register")]
[AllowAnonymous]
[EnableRateLimiting("Register")]
public Task<IActionResult> Register(AccountController.RegisterRequest request)

Parameters

request AccountController.RegisterRequest

Returns

Task<IActionResult>

Remarks

There is no password parameter. The browser derives the salt and verifier locally with the same SRP rules the game client uses, so the shard never holds anything a password could be recovered from — the same property the in-game path has.

RegistrationForm()

Issues a registration form: a signed token and the randomised decoy fields to render.

[HttpGet("register/form")]
[AllowAnonymous]
[EnableRateLimiting("Register")]
public IActionResult RegistrationForm()

Returns

IActionResult

Remarks

Rate-limited under the registration bucket, because a token is only ever wanted by somebody about to register. The in-game client gets nothing like it — bots there speak the protocol, not the page — see the README.

RequestPasswordReset(PasswordResetRequest)

Starts password recovery for the account at an email address.

[HttpPost("password-reset/request")]
[AllowAnonymous]
[EnableRateLimiting("Register")]
public Task<IActionResult> RequestPasswordReset(AccountController.PasswordResetRequest request)

Parameters

request AccountController.PasswordResetRequest

Returns

Task<IActionResult>

Remarks

Always 200, always the same body. It says nothing about whether the address is registered, whether the account is banned, or whether the per-account resend cooldown suppressed the mail — a reset form that answered differently for a registered address would be an account enumeration oracle, and that is exactly what they are probed for.

ResendVerification(ResendVerificationRequest)

Sends a fresh verification code for one channel, if the account is owed one.

[HttpPost("verify/resend")]
[AllowAnonymous]
[EnableRateLimiting("Register")]
public Task<IActionResult> ResendVerification(AccountController.ResendVerificationRequest request)

Parameters

request AccountController.ResendVerificationRequest

Returns

Task<IActionResult>

Remarks

Always the same 200 and the same words: unknown account, verified account, a channel it never chose, or a cooldown still running. Anything else would say which names exist.

Discord is refused with a 400, for every account alike: its code is sent once, as one DM, and is never re-sent. Because the refusal does not depend on the account, it says nothing about one.

RevokeSession(long)

Revokes one of the signed-in account's other sessions.

[HttpDelete("sessions/{id:long}")]
[Authorize(Policy = "Self")]
public Task<IActionResult> RevokeSession(long id)

Parameters

id long

Returns

Task<IActionResult>

Sessions()

The signed-in account's live panel sessions.

[HttpGet("sessions")]
[Authorize(Policy = "Self")]
public Task<IActionResult> Sessions()

Returns

Task<IActionResult>

Verify(VerifyRequest)

Redeems a verification code from any channel.

[HttpPost("verify")]
[AllowAnonymous]
[EnableRateLimiting("Register")]
public Task<IActionResult> Verify(AccountController.VerifyRequest request)

Parameters

request AccountController.VerifyRequest

Returns

Task<IActionResult>

Remarks

One endpoint for every channel, because any one correct code verifies the account: the player types whichever code reached them first, and the database finds which channel it belongs to. There used to be a verify-phone twin; it is gone with the every-channel rule.

Every failure — wrong code, unknown account, verified account, the third wrong code opening a support ticket — is one 400 with InvalidCodeError.