SpaceMIX v0.1.0 (latest)

Accounts on a server

experimentalfor bothsince protocol 1

How people sign in to a SpaceMIX server: the claim code and the owner's account, invites, email and password accounts (/api/auth/local/*), what a client reads from /.well-known/spacemix (the auth field), linking a SpaceMIX ID, password resets (spacemix-server reset-password, reset links), limits and error codes.

Every SpaceMIX server keeps its own accounts, whether or not it uses SpaceMIX Hub. An account signs in with an email and password kept on that server, with a SpaceMIX ID, or with both once they're linked. Read this page to build a client of the sign-in routes, or to know what happens to an account.

Server behaviour, not part of the extension contract: an extension sees who is signed in only through host.env.me. The code is apps/desktop/src-tauri/src/auth.rs and the routes in server.rs. Passwords are stored as Argon2 hashes in the server's encrypted database.

Who gets an account

There is no open sign-up.

Who Needs Becomes
The first person The claim code the server prints at startup while nobody owns it: SpaceMIX: claim this server with code XXXX-XXXX The owner, and the code stops working
Anyone after that An invite link from someone with server:members: <server address>/?invite=<token> (7 days, once) A member, with the groups and permissions on the invite

A link's address is SPACEMIX_PUBLIC_URL, else the address of the request that made it. SpaceMIX sends no email: whoever makes a link passes it on.

If a removal stops before the account is deleted, the next start keeps the account and its data, ends its API keys and tells the owner, who can remove it again. One that stops after the account is deleted finishes at the next start, or when it's asked for again: the person's data goes, and their builds turn off, with one notice to the owner per build.

What a client reads

GET /.well-known/spacemix needs no session and says how to sign in:

{
  "serverId": "3f2a…",
  "name": "SpaceMIX",
  "version": "0.1.0",
  "issuer": "https://spacemix.ai",
  "claimed": true,
  "publicUrl": "https://spacemix.example.com",
  "publicKey": "…",
  "auth": { "local": true, "hub": "https://spacemix.ai" }
}
Field What it says
auth.local Email and password accounts work here. Always true.
auth.hub The SpaceMIX Hub that signs people in, or null with the Hub off.
issuer The same Hub, from before auth; an empty string with the Hub off.
claimed Whether the server has an owner.
publicUrl SPACEMIX_PUBLIC_URL. Left out when it isn't set.
serverId, publicKey The server's id and the key it is the fingerprint of.
previousId The id the server had before its id came from its key. Left out when there was none.

The routes

Route Needs Body Answers
POST /api/auth/local/register The claim code or an invite { email, password, firstName, lastName, claimCode?, invite? } A session
POST /api/auth/local/login { email, password } A session
POST /api/auth/local/password A session { current, next } 204. This session stays; the account's other sessions, reset links and API keys end.
POST /api/auth/local/reset A reset link's token { token, password } A session. Every other session and the account's API keys end.
POST /api/auth/local/link A session, and the Hub on { token, password }, an identity token { user, receipt }
POST /api/auth/local/unlink A session { password } { user }. Other sessions and the account's API keys end. Works with the Hub off.

A session is { sessionToken, user, receipt }, the same reply as POST /api/auth/connect; receipt is empty for a local sign-in. A request from the server's own page gets the session as an HttpOnly, SameSite=Strict cookie instead, Secure under the __Host- prefix over https, and sessionToken isn't in its reply. Anything else gets sessionToken and uses Authorization: Bearer <sessionToken>. Sessions last 30 days.

Errors

When Status code Text
Wrong password, unknown email, or an account with no password 401 invalid_credentials Wrong email or password.
Registering with no owner and no right claim code 403 claim_required Nobody owns this server yet. Enter the claim code it printed when it started.
Registering without a live invite 403 not_member You need an invite link to join this server. Ask its owner for one.
An email an account here already has 409 email_taken An account with that email already exists.
An invite made for another email 403 invite_email This invite is for a different email address.
A wrong current password 403 wrong_password That isn't your current password.
An account with no password here 409 no_password This account signs in with SpaceMIX ID, so it has no password here.
A reset token that is unknown, used or expired 400 reset_invalid This password reset link isn't valid any more.
Too many attempts 429 rate_limited Too many sign-in attempts from here. Try again in a minute.
Too many attempts through one connecting address, or an attempt waited more than 5 seconds for its turn 429 busy Too many people are signing in right now. Try again in a moment.

A password takes at least 8 characters and is under 1024 bytes, and the most common leaked ones are refused: Use at least 8 characters for the password., Keep the password under 1024 characters., That password is too common. Choose another.

Limits

Passwords, claim codes, invites and reset links share these, per client (LOCAL_ATTEMPTS_PER_MINUTE in server.rs). Behind a proxy, set SPACEMIX_TRUSTED_PROXY so the server can tell clients apart (see "Behind a reverse proxy" in DEPLOY.md).

Limit Value
Attempts per client (an IPv6 /64 counts as one) 20 a minute
Attempts per IPv6 /48 100 a minute
Attempts through one connecting address, while the proxy is undeclared 300 a minute, then 429 busy
After a wrong guess That client's next attempt, and its answer, wait 1 second

Attempts are checked in this order: the /48's limit, the penalty, the connecting address's ceiling if the proxy is undeclared, the /64's limit. Each is charged only for attempts that got that far, so being refused for your own limit spends nobody else's.

/api/auth/challenge and the presence proof have their own limits: 60 a minute per client, 300 per IPv6 /48, and 600 through one connecting address while the proxy is undeclared.

After 10 failed passwords on one account within an hour the account is told, at most once a day.

SpaceMIX ID and a local account

An identity token never joins an account because its email matches. With a matching email and no link, POST /api/auth/connect answers 403 not_member, the same as for no account at all. Only someone holding a live invite for that email is told: 409 link_required, This server already has an account with your email. Link it with that account's password. To link, prove the password: Link SpaceMIX ID in Settings → Account, or POST /api/auth/local/link.

Linking keeps the password, so the account still signs in with the Hub off, and keeps the email it signs in with. Unlink, which takes the password too, undoes it.

In a browser, Continue with SpaceMIX ID goes to the Hub's own page and comes back with one short-lived identity token, bound to this server, this address and a nonce. The page a server serves never holds a SpaceMIX ID password, refresh token or Hub session (apps/desktop/src/lib/idSignIn.ts). Only the desktop app keeps a refresh token, in the OS keychain (apps/desktop/src/lib/identity.ts).

What a browser does with a link depends on what the link names (apps/desktop/src/shell/Gate.tsx).

The link What the page does
#/@<handle>/..., naming another server A page belongs to one server, so it can't follow the link. It shows This link is for another server, with This link opens on the server @<handle>, and this is <name>. Ask whoever sent it for that server's address. and Open on <name> instead.
?via=hub, which is how the Hub sends someone to a server It goes straight to the Hub's sign-in, unless someone is signed in already or the server has no Hub. The Hub answers without a screen for a server on the account's list.
?via=hub on a server nobody owns yet The same. A server the Hub made knows its owner. Any other answers claim_required, and the person lands on the first-run form with a note.
?via=hub with an invite The invite's form comes first: joining a server is the person's choice.

An invite in a link also sets aside a #/@<handle> naming another server.

Password resets

SpaceMIX sends no email, so a forgotten password takes a one-time link, good for 24 hours. Making one replaces any link the account had. The account is told in its notifications (source core.account) when a link is made and when one is used. A link looks like <server address>/#spacemix-reset=<token>: the token is in the fragment, so it stays out of server and proxy logs.

Who How For
Someone on the server's machine spacemix-server reset-password <email> [--unlink | --keep-link] Any account, the owner's too
The owner Settings → Members, or POST /api/team/users/{id}/reset-link A member with a password. Only the owner can make a password reset link. for anyone else; never the owner's own.

The command reads the same SPACEMIX_DATA_DIR and SPACEMIX_DB_KEY as the server, and works while the server runs. It prints the link on standard output and whose it is on standard error. Its full use is in "Accounts" in DEPLOY.md.

Stability: experimental, like the rest of who may do what on a server.

This page as markdown · All pages as one file