Accounts
One account and one sign-in for every SVRBC site. Anyone may have an
account. Church membership, and every other role, is a group that admins
put people in. A path on any site is open to everyone, to anyone signed in,
or to a group. The service is auth.svrbc.org
(svrbc/auth.svrbc.org), and
its API’s contract is that repository’s
api/README.md.
Decided 2026-10-18.
A pilot: auth.svrbc.org is being built, and none of this has run in AWS yet. The first site with a members-only section settles the details and records them here.
- An account is anyone who has signed in.
- A member is an account in the
membergroup: a member of the church. This handbook also says “members” for GitLab group members, so on this page and in code say “church members” or “themembergroup”. GitLab Pages’ Only project members is unrelated: it is the gate for developers. - An admin is an account in the
admingroup. Admins decide who is in every group.
What a site gets
Section titled “What a site gets”- A path needs one of
public,signed-in, or a group. The site’s CloudFront viewer function checks, before the cache answers, so a static site (tier 1) can have a members-only section. Nothing reaches the cache or the bucket for a visitor who may not see it. - Someone not signed in is sent to sign in, and back. Someone signed in without the group gets a page that says so, not a sign-in form.
- Changes take effect within seconds: a new member, a removal, a sign-out everywhere, a deleted account. Nothing is cached in the cookie.
- No passwords. A 6-digit code by email is the way in, and signing in for the first time creates the account. Once signed in, anyone may add a passkey and sign in with it instead; the code still works, and is how someone who has lost theirs gets back in.
Groups
Section titled “Groups”Code decides which groups exist; admins decide who is in them.
groups.toml
in auth.svrbc.org lists them, each with a description. A group does nothing
until a site’s rules name it, and those rules are code, so a new group is a
merge request either way.
- A group for the whole church has a plain name (
member,elder). A site’s own group starts with the site’s hostname and a colon (recipes.svrbc.org:editor), so two sites can never mean different things by one name. - A site’s roles are groups, not role management of its own: its API reads the account’s groups. Only a permission that depends on the data (“may edit the recipes they wrote”) stays in the site’s code, stored against the account id.
- Adding one: a merge request to
groups.toml, released before the site’s own merge request names it, so the admin page can grant it first. - Never renamed. Add the new group, move the people, update the sites, then remove the old one, once no site’s rules name it.
- Not yet: group managers, such as a deacon managing the
deacongroup without being an admin. It would be amanagersline ingroups.toml.
Who is in a group is data, not code: it lives in auth.svrbc.org’s DynamoDB table, with who changed what and when. Git would make every change wait for a release, would need a developer to make it, and would put the church’s member list in a repository’s history for good.
Using it in a site
Section titled “Using it in a site”The site must be a subdomain of svrbc.org, so one cookie covers it
(below).
Protecting paths
Section titled “Protecting paths”The site’s router/router.js starts with its rules, longest prefix first; a
path no rule covers is public:
var ACCESS = [ ['/members/elders/', 'elder'], ['/members/', 'member'], ['/my/', 'signed-in'],]Below the rules, it carries the session check from auth.svrbc.org’s
router/router.js,
the block marked for copying, as it is, and its handler starts with
svrbcCheck(event, ACCESS), before rewriting anything. The check matches
rules against the path as S3 will look it up, not as it was typed: S3
decodes percent-escapes, so a rule matched on the raw URI would let
/%6Dembers/ or /members%2Fa.html past /members/. Escapes are decoded
before matching, and a path with empty, . or .. segments (//members/)
is sent to its canonical spelling first. A rule ending in a slash covers
the page without it too ('/members/' covers /members), since page URLs
have no trailing slash (Sites); an older copy of the session
block may not, and lets /members through. The function is associated with the
svrbc-accounts KeyValueStore (a function takes one store), and the site’s
deploy keeps that association when it publishes the function. Its
AGENTS.md says which paths need what.
Showing who is signed in
Section titled “Showing who is signed in”A static page that says “Signed in as Jane” asks
GET https://auth.svrbc.org/api/me from a small script, with
credentials: 'include': CORS allows any https://*.svrbc.org origin. It
answers the account, or 401. The service worker never caches the answer.
The account menu does this, and is what a site’s
header uses.
The account menu
Section titled “The account menu”Every site with accounts shows who is signed in, in the same place, with
the same menu: the handbook’s
templates/astro-site/src/components/AccountMenu.astro,
copied into the site unchanged, and changed in the template and nowhere
else. A new site has it already (Tools); a site
takes a new version by copying the file again. svrbc-audit’s
account-menu check (Tools) compares each site’s copy
with the template’s, by hash: one that isn’t the current file fails, naming
the release it fell behind at, or saying it was edited; so does a site whose
layout doesn’t use it, or whose layout or header draws a sign-in or sign-out
link of its own.
Decided 2026-11-30 (the plan).
- The button is a pill: the person’s profile picture in a 28-pixel circle, or their initials on the site’s primary color when they have none, and their name, cut short past about 20 characters. On a phone, the circle alone. An account with no passkey has a dot on it.
- It opens onto their name and primary address, Account (the account page), an Add a passkey chip for an account with none (below), and Sign out. It opens on a click, or Enter or Space on the focused button, and closes on Escape or a click elsewhere; every item is a link or a button, in order for the keyboard.
- Before the account is known, an empty circle of the same size holds its place, so the header doesn’t jump. Signed out, or with auth.svrbc.org unreachable, it is a Sign in button that comes back to the same page.
- Sign out is
POST https://auth.svrbc.org/api/signout, the one change auth.svrbc.org takes from another SVRBC site’s page (the worst a site could do with it is sign its own visitor out), then the site’s home page. On a site with no public page, that sends them straight to sign in, which is where they should land. “Sign out everywhere” stays on the account page. - The picture is
GET https://auth.svrbc.org/api/me/picture?v=<version>, the version beingpictureinGET /api/me’s account. Every SVRBC site is the same site to the browser, so the cookie goes with the<img>’s request. It answers only the signed-in account’s own picture (and an admin’s list): there is no address for anyone else’s, since a church’s members include children and a guessable address would be a directory by accident. A member adds, changes or removes it on the account page. - How: a
<details>and a plain script, no island. It asksGET /api/meonce the page loads and draws the answer as text. Its defaults are auth.svrbc.org’s, so a site with central sign-in writes<AccountMenu />; a site with accounts of its own writes<AccountMenu api="" signin="/signin" account="/account" />, and without pictures in its API shows initials. A site draws no sign-in or sign-out link of its own in its header: the menu is the one.
A site’s API
Section titled “A site’s API”A site’s Rust API checks the same cookie against the same keys, and reads the account’s groups. How it gets the keys and groups, a shared crate or a call to auth.svrbc.org, is settled when the first site needs it. Store a site’s own data against the account id, never the email, which can change.
Signing in
Section titled “Signing in”- A visitor without a session asks for a protected page; the site’s
function answers
302tohttps://auth.svrbc.org/?return=<the page>. - They enter an email. If the limits allow, a code goes to it (10 minutes, 5 tries). The page answers the same whether or not an account has that address, so it can’t be used to find out who uses SVRBC’s sites.
- They type the code. An existing account is signed in. A new address is asked for a name, and the account is created, with any groups an admin granted that address beforehand.
- The cookie is set for
.svrbc.org, and they go back to the page. auth.svrbc.org follows areturnonly tohttps://svrbc.orgor a subdomain.
A code, not only a link, because every SVRBC site is a PWA: a link in an email opens in the mail app’s browser, which gets the cookie, not the installed app. The email carries a link too, for signing in in the same browser.
Limits, since anyone can sign up: 3 codes to an address per 15 minutes, 20 from an IP per hour, 1,000 in all per day, 200 new accounts per day.
Passkeys
Section titled “Passkeys”A passkey is another way in, never the only one. Someone signed in adds
one on /account (with a recent sign-in, as admin actions need), up to 10,
and the sign-in page offers it beside the code, and in the email field’s
autofill where the browser can. A passkey sign-in counts as a recent one.
Decided 2026-11-12:
- Its relying party is
auth.svrbc.org, notsvrbc.org: signing in happens only there, so no other site can ask for an SVRBC passkey. Changing it would make every passkey useless, so it doesn’t change. - Discoverable, user-verified, ES256 or EdDSA, no attestation: no email to type, a fingerprint or PIN on the device, and no list of approved makers to keep. A cloned key is caught by its signature counter.
- Checked by the function itself, in pure Rust (
api/src/webauthn.rs), since the WebAuthn crates need OpenSSL, which the function’s static build doesn’t have. Each challenge is used once and lasts 5 minutes. - Limits: 60 sign-in challenges from an IP per hour, 5,000 in all per day, 30 registrations an account starts per hour.
The routes and items are auth.svrbc.org’s
api/README.md.
Encouraging a passkey
Section titled “Encouraging a passkey”Every site with accounts offers a passkey, in two places. A passkey is faster than waiting for an email, and it can’t be phished: it answers only the site it was made for, where a code or a link can be handed to whoever asks for it. Email stays the way back in, for a new device or a lost passkey, so this offers and never insists. Decided 2026-11-24:
GET /api/mesays how many passkeys the account has:{account, passkeys},passkeysa number (its type isMeResponse), so a page can tell an account with none.- After a sign-in by email, the sign-in page offers one, before going
on, if the browser can make one (a platform authenticator with user
verification), and never after a passkey sign-in. To an account with
none it says “Sign in faster next time”; to one that has a passkey but
signed in by email all the same, “Add a passkey on this device”. Add a
passkey makes one there and then (the sign-in just now is the recent
one adding needs) and goes on; Not now goes on at once. If
/api/meor the browser’s check fails, it just goes on: the offer never stands between someone and signing in. Its container carriesdata-passkey-offer. - The account menu, in the header, the same
component in every site. For an account with no passkey (
passkeysexactly 0: an older API that doesn’t say shows nothing), the menu holds an Add a passkey chip (data-passkey-chip), linking to the account page’s#add-passkey, and its button carries a dot, so it is seen without opening.
svrbc-audit’s account-menu check (Tools) looks
for the template’s menu in every site with accounts, and for the offer and
the count in one that signs people in itself.
The session
Section titled “The session”svrbc_session=v1.<payload>.<signature>; Domain=.svrbc.org; Path=/; Max-Age=7776000; HttpOnly; Secure; SameSite=LaxThe payload names the account, its session version, when it signed in, when the session expires (90 days) and which key signed it; the signature is HMAC-SHA256. No email and no groups: the account id means nothing elsewhere, and groups are looked up on every request.
- HMAC, because a CloudFront Function can compute an HMAC but can’t verify an RSA or ECDSA signature. The cost is that whatever can check a session can make one, so the keys are kept from everything but the function and CloudFront (below).
- The session version makes “sign out everywhere” possible: raising it ends every older cookie for the account at once.
- Admin actions need a recent sign-in, within 12 hours, so a cookie left on a device for weeks can see the site but can’t change who is a member.
- Requests that change something must come from auth.svrbc.org itself
(
Origin) as JSON. Everysvrbc.orgsubdomain is the same site, soSameSite=Laxalone wouldn’t stop a page on one of them from posting to the API with the visitor’s cookie.
The check at the edge
Section titled “The check at the edge”For a path that needs a session, the site’s function:
- Parses the cookie; if it is missing or malformed, sends the visitor to sign in.
- Looks up the signing key in the KeyValueStore, checks the HMAC (in constant time) and the expiry.
- Looks up the account’s entry,
<version>|<groups>. An account with no entry has none (0|). An entrydeletedordisabled, or a version other than the cookie’s, sends the visitor to sign in. - Checks the path’s group is among the account’s groups.
- Goes on to the router and the cache. The cookie never enters the cache key, so everyone allowed shares one cached copy of a page.
The KeyValueStore
Section titled “The KeyValueStore”One store, svrbc-accounts, holds the signing keys (k:<id>) and an entry
for each account with groups, a sign-out everywhere or a deletion behind it
(a:<id>). A plain sign-up writes nothing there: a write costs $1 per
1,000, which would make open sign-up the service’s largest cost. Changes are
written by auth.svrbc.org’s function (DynamoDB first, then the store, then
read back); the store’s API signs with SigV4A, which the AWS CLI and SDKs
handle and hand-written SigV4 doesn’t.
Admins
Section titled “Admins”auth.svrbc.org’s /admin/, for the admin group:
- Add people to any group
groups.tomllists, or remove them, by account or by an address that hasn’t signed in yet; a pasted list of addresses goes in at once. - See every account, its groups, and the log of who changed what.
- Sign an account out everywhere, or disable it.
- Merge two accounts into one (below).
- An admin can’t remove their own
admin, and the last admin can’t be removed.
svrbc-accounts does the same from a terminal
with AWS credentials, for the first admin and for checks.
Each account’s own /account changes its name, its addresses and its
passkeys, merges another account into it, and signs out here or everywhere. An account has up to five
email addresses, each verified by a code, and any of them signs in; one is
primary. An address belongs to one account, and a grant waiting on it moves
to the account when it is added. Adding one needs a recent sign-in, as a
passkey does: it is another way in. An account is deleted only on request
(the privacy page says to whom); its grants go back to waiting on its
primary address, so signing in again restores them.
Merging accounts
Section titled “Merging accounts”Two accounts that are one person’s can be merged into one, by the person or by an admin. Without it, the only way out is to delete one and start again, which loses its groups, passkeys and history (Stack asks it of every account system).
- On
/account, “Merge another account into this one”: the person enters an address of the other account, types the code sent to it, and sees what will move before the Merge button. The code proves they control the other account. It needs a recent sign-in, as adding an address does. - On
/admin/, any account’s “Merge into another account…”, picking the one that survives, with the same preview and a recent sign-in. It is for someone who has lost every way into one of the two. - The account merged into survives, with its id, name and primary address. The other’s addresses, passkeys and groups move to it (it gets the groups of both), and the other account is gone: its sessions end at once.
- The old id is remembered, for good: an item
ACCOUNT#<old>/MERGEDnames the account it went into, and when. Its sort key isn’tACCOUNT, so nothing that lists accounts sees it. A site that keeps its own data by account id follows it to move that data. - All or nothing: one DynamoDB transaction, then the KeyValueStore, as every change is (above), and a line in the log.
- The limits still hold. If the two together would have more than five addresses or ten passkeys, the merge is refused, saying what to remove first; removing is always possible. Neither account may be disabled (an admin enables it first), and nothing merges into itself.
- It can’t be undone, and the page says so before the person confirms.
The routes and items are auth.svrbc.org’s
api/README.md.
Who can read what
Section titled “Who can read what”ReadOnlyAccess reads KeyValueStore keys,
DynamoDB items and SSM parameters, and every member who can push to a fork can plan with it. Left alone, any
developer could read a signing key and make themselves an admin’s session,
and read the member list. So infra/aws-account denies the planner
cloudfront-keyvaluestore:GetKey and ListKeys, reading items from any
table, and the parameters under /svrbc/auth-svrbc-org-api/. OpenTofu
manages the tables and the store, never what is in them, so no plan needs
them. Only the function, CloudFront and administrators read them.
A profile picture is kept in the service’s bucket under pictures/,
which CloudFront is refused (infra/auth-svrbc-org-site’s bucket policy);
only the function reads and writes it, and answers it only to its own
account and to admins.
The function never logs a code, a cookie or a key, and logs an email only as a hash: its logs are readable by the same role.
Cents a month: every piece bills per use, with no monthly minimum and nothing by the hour. An estimate for 300 accounts, 500 sign-ins and 200,000 protected page views a month comes to about $0.15: email (SES, $0.10 per 1,000) and DynamoDB reads, with Lambda, the viewer function and KeyValueStore reads inside AWS’s free monthly allowances. A database billed by the hour (the smallest RDS instance, about $12 a month) would cost more than all of it.
Decisions, and why
Section titled “Decisions, and why”- One service, not accounts per site: one sign-in, one member list, one place personal data is kept.
- Our own, not Cognito: Cognito’s tokens are RS256, which a CloudFront Function can’t check, so it would still need our own cookie or Lambda@Edge on every request; its groups ride in tokens that last up to a day, which breaks “within seconds”; and the admin page would still be ours. It would have been only the email-code step, the easy part. Auth0 and Clerk add a third party holding the member list, and the edge check is still ours.
- Not CloudFront signed cookies: a missing one is a 403, which a distribution maps to its error page, with no way back from sign-in; and they can’t be revoked before they expire.
svrbc.orgsubdomains only: one cookie for all of them. A site on another domain needs a hand-off (a short-lived token in the URL, and a cookie its own function sets), designed but not built until a site needs it.- A cookie for all of
.svrbc.orgreaches every subdomain, GitLab Pages ones included. HttpOnly keeps it from their scripts; keep DNS tidy, since a dangling subdomain someone took over would receive sessions. - Merging, not deleting and starting again: people end up with two accounts, and deleting one loses its groups, passkeys and history.
- Open sign-up, with the limits above: a site that doesn’t want strangers
protects its paths with a group, not
signed-in.
Open questions
Section titled “Open questions”- auth.svrbc.org end to end: the first release, the first admin, and a members-only page on another site.
- How long a KeyValueStore write takes to reach the edge (AWS describes it as seconds).
- How a site’s API checks sessions: a shared crate, or asking auth.svrbc.org.
- Where the session check lives for other sites to share, once there is a second: today it is copied from auth.svrbc.org’s router.
- A budget alert on the service’s costs.
- Sign in with Google: not in the first build; added if people stall at the code step.