Authentication
Sign-in for the emulator (OAuth + PKCE over a loopback redirect)
Section titled “Sign-in for the emulator (OAuth + PKCE over a loopback redirect)”A desktop app can’t keep an OAuth client secret, so the server runs the OAuth flow with the providers. The emulator only receives a one-time code, protected with PKCE (RFC 8252 / RFC 7636).
sequenceDiagram
participant E as Emulator
participant B as Browser
participant S as AcidBoy server
participant P as GitHub / Discord / Google
E->>E: listen on 127.0.0.1:random port, make verifier, challenge = SHA-256(verifier) and state
E->>B: open /auth/{provider}/start?redirect_uri=http://127.0.0.1:port/callback&code_challenge&state
B->>S: GET /auth/{provider}/start
S->>P: OAuth authorize (server's client id)
P->>S: /auth/callback/{provider} (code)
S->>S: find or create the account, then a one-time code bound to the challenge (1 min)
S->>B: redirect to http://127.0.0.1:port/callback?code&state
B->>E: GET /callback (state checked)
E->>S: POST /auth/token {code, codeVerifier}
S->>E: access token (JWT, 15 min) + refresh token (60 days)
- Redirects: only plain-HTTP loopback redirects (
127.0.0.1,[::1],localhost) are accepted, so a code can never be sent to another machine. - Codes: a code is single-use and dies after a failed verifier.
- Accounts: an account is identified by its provider identity (
ExternalLogin: provider + user id). The display name and avatar come from the provider on first sign-in: the GitHub login, the Google profile name, or the Discord global name (falling back to the username).
OAuth apps
Section titled “OAuth apps”| Provider | Callback URL to register | Scopes |
|---|---|---|
| GitHub | https://<host>/auth/callback/github |
read:user |
| Discord | https://<host>/auth/callback/discord |
identify |
https://<host>/auth/callback/google |
openid profile email (the defaults) |
For local development use http://localhost:5280/... (GitHub and Discord accept it; Google accepts
localhost). Set Auth:Providers:<provider>:ClientId and ClientSecret. GET /auth/providers
lists the enabled ones.
Tokens
Section titled “Tokens”| Token | Format | Lifetime | Stored |
|---|---|---|---|
| Access token | JWT (HMAC-SHA256 with Auth:SigningKey), claims sub (account id) and name |
15 min | Emulator memory |
| Refresh token | 32 random bytes, base64url | 60 days | Emulator: settings.json (DPAPI on Windows). Server: its SHA-256 only |
- Refreshing:
POST /auth/refreshrotates the refresh token: the old one stops working. The emulator refreshes a minute before the access token expires. - Signing out:
POST /auth/logoutrevokes a refresh token. - The lobby connection: the SignalR connection authenticates with the access token in the
access_tokenquery parameter, because WebSocket clients can’t send headers. This is accepted only on/hubs/lobby. - Relay tickets are separate, single-use tokens; see Link relay.
Developer sign-in
Section titled “Developer sign-in”POST /auth/dev {"name": "..."} signs in with just a name, which maps to the identity dev:<name>.
It exists only when Auth:EnableDevLogin is true, which is the default in Development only. It can
never open the admin dashboard, even for an account with an admin role.
A banned account:
- can’t get tokens:
/auth/dev,/auth/tokenand/auth/refreshanswer 403 with{"error": "This account is banned until 2026-12-08 17:00 UTC: cheating"}, and the emulator shows it; - is refused at once: every authenticated request checks the ban (
ModerationCache, refreshed within 30 s and cleared the moment a moderator acts), so live access tokens stop working immediately; - loses its sessions: a ban revokes all of the account’s refresh tokens, disconnects its lobby connections and ends its relayed links. See Admin dashboard › Moderation.
The ban message is sent over the lobby connection, which closes one second later (LobbyState.NoticeGrace).
A long-polling client fetches messages with a new request each time, so in that second its “receive”
request on that connection (GET /hubs/lobby?id=…) is still allowed. Otherwise the request would be
refused and the message lost. That request can only receive: hub calls, new connections and every
other endpoint are refused as above.
Admin dashboard sign-in
Section titled “Admin dashboard sign-in”The dashboard has its own GitHub-only sign-in and cookie, separate from the game’s tokens. See Admin dashboard › Access.
