DocsData
Sign-in and users
Accounts, passwords, sign-in links, providers, two-step codes, invitations and roles.
Users are a collection with sign-in built in. There is no separate auth service: accounts, sessions and permissions live in the same binary as the data they protect. To sign someone in:
const users = sluurp.collection("users");
await users.authWithPassword(email, password);
sluurp.authStore.record; // the signed-in user
sluurp.logout();Features include:
- Passwords, sign-in links, OAuth providers and two-step codes
- Invitations that fix some fields and let the invitee fill in the rest
- A security log for every account, and an email after each password change
- Roles that rules can check
Sign in
Sign-in answers with a token that lasts 14 days. To exchange it for a fresh one, call authRefresh(). Passwords need at least 8 characters, and are stored as Argon2 hashes.
| Sign-in link | requestSigninLink(email) signs in without a password. The link works once, and expires. |
| Password reset | requestPasswordReset(email) emails a link; confirmPasswordReset(token, password) sets the new password. |
| OAuth | Google, GitHub, Microsoft, GitLab, or any OpenID Connect provider, set up under Sign-in in the admin. Send the user with location.href = users.oauthUrl("google"), and call captureOAuthToken(sluurp) on the page they come back to. |
| Two-step codes | A 6-digit TOTP code after the password. Five wrong codes end the attempt. |
There are no recovery codes. A user who loses their phone asks an administrator, who turns off two-step sign-in on their record and signs them out everywhere.
Choose who may join
Each app chooses who may make an account, and the server enforces it:
invite(the default): by invitation only.open: anyone can sign up, within the collection’s create rule.closed: no sign-ups, for accounts synced from a directory.
An invitation has two parts. The inviter sets some fields, such as the organisation and the roles, which the invitee can’t change. The invitee fills in the rest, such as their name and password.
await users.invite("ada@example.com", {
fields: { org: team.id, roles: ["member"] },
collect: ["first_name", "last_name"],
});Account security
Sluurp keeps a security log for each account, with nothing to set up. It records:
- each sign-in, and how: a password, a provider such as Google, an emailed link, or a two-step code;
- a wrong password on an account that exists;
- a password changed, and by whom: the person, an administrator, or a reset link;
- two-step sign-in turned on or off;
- encryption keys made or replaced, and passkeys added or removed.
Each entry keeps the IP address, the device, and the location when the proxy in front gives one. Cloudflare and Vercel do, in headers Sluurp reads. Sluurp sends IP addresses nowhere to look them up, so without such a proxy there is no location. Behind a proxy on the same machine or network, such as Caddy, the address is the one the proxy forwards.
const entries = await sluurp.collection("users").securityLog();
// [{ event: "signed-in", detail: "password", ip: "203.0.113.7", location: "Brussels, BE", device: "Firefox on macOS", created_at: "…" }, …]People read their own log. An administrator reads anyone’s with securityLog({ id }). Sluurp keeps the newest 500 entries per person.
After any password change, Sluurp emails the person in their language. The email says when it happened, from which address, where and on what device, and links to a page to set a new password. It isn’t a link to undo the change, because whoever changed the password knows the old one. The link works once, and setting a new password signs the account out on every device.
Roles
A user’s roles is a list that rules can check: @request.auth.roles ~ "editor". Only whole roles match, so admin never matches superadmin.
Administrators
- Impersonate a user from their record in the admin, to see the app as they do.
- Sign out everywhere revokes a user’s tokens and ends all their sessions at once.
- Administrators (superusers) are separate from app users. To make one, run
sluurp superuser you@example.com, which asks for the password, or use Platform › Administrators in the admin. The last administrator can’t be deleted, so a server is never left without one.
The first administrator
A new server has no administrator, and the admin at /_/ offers to make one. So that whoever reaches a new server first can’t claim it, this works only on the server itself (opened as localhost, not through a proxy), or with a setup code. While there is no administrator, the server prints the code in its log when it starts:
no administrator yet. Make one at /_/ with the setup code K7QM-2XRP-9WHD, or here: sluurp superuser <email>The sign-in screen asks for the code when you set up from another computer. Once an administrator exists, the code no longer works.
Where administrators sign in from
To let administrators act only from your office or your VPN, list their addresses in Settings › Administrator addresses, one address or range a line:
203.0.113.7
10.0.0.0/8
2001:db8::/32From any other address, an administrator’s password isn’t even tried, an administrator already signed in is refused, and so is an agent with an MCP key. Nobody else is affected. An empty list allows any address.
A list that leaves out the address you are saving it from is refused, so you can’t lock yourself out. The server’s own machine is always allowed: if a list goes wrong, sign in there (through an SSH tunnel, say) and change it. Behind a proxy, the address is the visitor’s own, as the proxy forwards it (see HTTPS).