Authentication Guide

Overview

Keymaster supports multiple authentication methods, all unified behind a single login page per app. Users choose their preferred method; Keymaster handles the rest.

Supported Auth Methods

Provider Type Setup Required
password Email + password (argon2id hashed) None — built-in
magic_link Passwordless email link (15-min expiry) Email infrastructure
google Google OAuth 2.0 Google Cloud Console credentials
github GitHub OAuth GitHub Developer Settings credentials
microsoft Microsoft Entra ID Azure App Registration
apple Sign in with Apple Apple Developer Program

Apps choose which providers to enable via the Console. The login page only shows enabled providers.

OAuth2 Authorization Code Flow

This is the primary flow for web applications.

1. Initiate Login

Redirect the user to:

GET https://keymaster.cloud-monitor.com/login
    ?app_id={uuid}
    &redirect_uri={your_callback_url}

Optional parameters: - prompt=login — Force login screen even if SSO session exists (skip SSO fast path)

2. User Authenticates

Keymaster shows the branded login page. The user picks their auth method: - Password → email + password form - Magic Link → email input, receives link via email - OAuth → redirects to provider (Google, GitHub, etc.), returns to Keymaster

3. SSO Fast Path

If the user has an active km_sso session (logged in at Keymaster within the last 8 hours), Keymaster skips the login screen and immediately redirects back with tokens — true cross-app SSO.

This only happens if: - User has a valid km_sso cookie - User is enrolled in the target app - prompt=login is NOT set

4. Callback with Tokens

On success, Keymaster redirects to your redirect_uri:

{redirect_uri}?access_token={jwt}&refresh_token={opaque_token}

5. Error Handling

On failure, Keymaster redirects to the login page with an error parameter:

Error Meaning
oauth_denied User cancelled the OAuth consent screen
oauth_failed Provider error (network, invalid response)
not_enrolled User exists but isn't enrolled in this app
pending_approval User's access request is pending admin approval
suspended User's access to this app has been suspended
provider_not_allowed Auth method not enabled for this app

Registration Policies

Each app has a registration policy that controls how users gain access:

Policy Behavior
open Anyone can sign up. Users are auto-enrolled on first login.
invite Requires an invite code. Users without enrollment see the invite code page.
approval Anyone can request access. Admin must approve before access is granted.

Cross-App SSO

Keymaster's SSO works via the km_sso httponly cookie on the Keymaster domain.

Flow: 1. User logs into App A → Keymaster sets km_sso cookie (8-hour lifetime) 2. User visits App B → App B redirects to Keymaster login 3. Keymaster sees valid km_sso → checks user is enrolled in App B 4. If enrolled → issues tokens and redirects back immediately (no login screen) 5. If not enrolled → shows login page with "You don't have access" message

SSO does NOT auto-enroll users. Each app controls its own enrollment via registration policy.

Password Policy

Two-Factor Authentication (TOTP)

Magic Links

Passwordless email login: 1. User enters email on login page 2. Keymaster sends a signed link (15-min expiry, single-use) 3. User clicks link → Keymaster verifies, creates session, redirects with tokens 4. Link is consumed — cannot be reused

Magic links are ideal for infrequent users or kiosk environments where typing passwords is impractical.

OAuth Provider Notes

Google

GitHub

Microsoft

Apple