Two-factor and sessions
Authenticator-app sign-in, recovery codes, team roles and invitations for the Baseera console.
This page covers how people sign in to the console. For end-user sessions in your app, see Sessions.
Two-factor sign-in
Baseera uses Supabase Auth's TOTP. Owners, admins and anyone else who wants it can add an authenticator app.
- A person with an authenticator must pass it (assurance level
aal2) before any page. - Owners and admins of an organization that requires it must enroll first. Only an owner can turn the requirement on, and needs their own code and a verified factor to do so, so an owner cannot lock themselves out.
- Developers and viewers are not forced, but can turn it on in the security page.
- If the organization lookup fails, the person is sent to enroll. It fails closed.
SMS and email codes were turned down as weaker, and a cost per sign-in. WebAuthn is a possible follow-up.
The database checks the second factor
Triggers on agent_keys (insert), provider_keys and webhook_endpoints (insert, and update of the secret) refuse the change with AE102 when the organization requires a second factor and the session has not passed its code. Server actions check first, but the trigger is the guarantee: a call straight to the API cannot create a secret from a session that has not passed its code. Granting owner or admin also needs the granter's second factor when the organization requires one.
Recovery codes
- Ten codes of 12 characters (60 bits), made in the database, shown once as
XXXX-XXXX-XXXX. - Stored only as bcrypt hashes. No API role can read a hash. A person can see how many are left.
- Generating new codes needs an
aal2session and replaces all earlier codes. - Using a code removes the authenticator, every other code and every other session. The person then sets up a new authenticator, or is made to if the organization requires it.
- 5 wrong tries in 15 minutes lock recovery for 15 minutes.
- A recovery code never counts as a second factor itself.
Enrolling, removing a factor, recovery and the organization switch are all in the audit log.
Team and roles
Four roles: owner, admin, developer, viewer. Every change goes through a reviewed function. Signed-in users have no direct privilege on members or invitations.
- Owners invite any role. Admins invite only developers and viewers.
- Nobody changes their own role.
- The last owner cannot be removed or demoted. It is a trigger, so no path skips it.
- Only owners and admins add or remove provider keys, secret keys and webhook secrets.
Invitations
An invitation is a single-use token of 256 random bits that expires in 7 days. It is stored only as a SHA-256 hash, and the raw token appears only in the email link's fragment, which is never sent to a server and is removed from the address bar on arrival.
Accepting needs a signed-in, email-verified account whose address equals the invited one. Every other case (unknown, expired, used, revoked, someone else's address) is the same invalid answer, and 10 tries an hour are allowed per person.
Email abuse is capped: 50 pending invitations and 100 members plus pending per organization, 20 an hour per person and 40 an hour per organization, 5 to one address in 24 hours, and 5 sends per invitation.
Auth settings
Passwords need 12 or more characters with lower and upper case letters and a digit. Email confirmation is on, access tokens and email links last 15 minutes, and secure password change is on.