Files
Shellcore-Accounts/README.md
T

4.1 KiB

ShellcoreDB account service

Library credits

Uses ASP.NET Core and Identity by Microsoft and contributors (MIT), Dapper by Sam Saffron, Marc Gravell, Nick Craver, and contributors (Apache 2.0), and Npgsql by Francisco Figueiredo Jr. and contributors (PostgreSQL License). See third-party for the package inventory.

Internal account and session API for Zombie Lab. The game client talks to the game server; only trusted server processes call ShellcoreDB. New accounts can use a username and password or a verified Steam ticket. A Steam-only account has no local credential row; every localCredentials.passwordHash is required.

Setup

Use .NET 10, PostgreSQL, and dotnet restore. Application source and SQL are under scripts/. For a new database, apply scripts/sql/shellcore.sql once. For a database using the earlier schema, back it up and apply scripts/sql/migrations/001SeparateCredentialsAndEmail.sql instead. That migration refuses to discard populated plaintext email values or migrate accounts with no valid credential.

Set ConnectionStrings__Shellcore and ShellcoreServiceKey in the service environment. Keep the service key separate from ZombieLabDB's key. A localhost start is:

export ConnectionStrings__Shellcore='Host=127.0.0.1;Database=shellcore;Username=replace-me;Password=replace-me'
export ShellcoreServiceKey='replace-with-a-long-random-secret'
export ASPNETCORE_URLS='http://127.0.0.1:5081'
dotnet run

For Steam sign-in, also set Steam__AppId, Steam__PublisherKey, and Steam__Identity. The identity must match the string used when the native game obtains a web API ticket. Never place the publisher key in Godot or in a URL exposed to players. Steam is optional at startup; /internal/auth/steam returns steamUnavailable until configured. Use HTTPS between machines, and permit only trusted game servers and future website backends to reach this API.

Internal routes

All routes require X-Service-Key and return { "success": true, "data": ... } or { "success": false, "error": { "code": "...", "message": "..." } }.

Route JSON body Success data
POST /internal/auth/register {"username":"player","password":"long-password"} {accountId, username}; 201
POST /internal/auth/login Same {accountId, username, token, expiresAt}
POST /internal/auth/steam {"ticket":"hex-ticket","username":"player"} Same login data; username needed only for a new account
POST /internal/sessions/validate {"token":"..."} {accountId, expiresAt}
POST /internal/sessions/revoke {"token":"..."} {revoked: true/false}

Username/password registration requires a unique username and a password of 12 to 1024 characters. ASP.NET Core Identity manages usernames and password hashes through a store for the existing tables; no schema migration or password reset is required. Session tokens are random, and only a SHA-256 hash of each token is stored. Sessions expire after 30 days. A suspended or disabled account cannot validate a session. 401 means missing service key, bad credentials, invalid ticket, or invalid session depending on the route; 400 invalid signup input; 403 unavailable account; 409 taken username; 503 database or Steam unavailable; 500 unexpected error.

Unexpected server errors use application/problem+json with standard ProblemDetails fields. They also retain success: false and the existing error: {code, message} members for current callers. Ordinary validation and authentication errors retain their existing JSON envelope.

Email privacy

The new schema does not collect or store email. Email enrollment and delivery need a separate mail process with a separate encryption key; routine account, game, and database operators should see only usernames. A future encrypted mail store must keep plaintext out of logs, backups, and game API responses. A host administrator with control of the mail process can still access mail while it is being sent.