Design decisions

Why OpenID Connect, why Passport, and how a sign-in travels.

Checkin is one Laravel 13 application with three faces:

FaceWhoWhereBuilt with
Account & launcherevery person/login, /dashboard, /settings/*Fortify + Livewire 4 + Flux (Laravel's Livewire starter kit)
Identity providerapplications/oauth/*, /.well-known/openid-configurationLaravel Passport 13 + app/Oidc
Administrationadministrators/admin/*Livewire 4 single-file pages + Flux, inside the same sidebar
Updatesadministrators/admin/updates, app:updateapp/Updates, shared with Boogle, Hackly and IndieStats

Decisions#

OpenID Connect, not SAML (and not "just OAuth")#

  • Every application here is a Laravel app (or a modern self-hosted tool: Grafana, Portainer, Gitea, Nextcloud… all speak OIDC). OIDC gives a signed ID token that states who signed in, which plain OAuth 2.0 does not.
  • One protocol means one client package, one set of tests, one set of endpoints to secure.
  • SAML 2.0 is only worth it for enterprise suites that cannot do OIDC (some SaaS, older Google Workspace / AWS SSO setups). If that day comes, codegreencreative/laravel-samlidp can be added next to Passport without touching the account side; the User model already has a stable uuid to use as NameID.

Passport as the OAuth server, a thin OIDC layer on top#

Passport provides clients, authorization codes, access/refresh tokens, PKCE, scopes, the consent screen and the token endpoint, with a well-tested league/oauth2-server underneath. It lacks OIDC, so app/Oidc adds exactly what is missing:

ClassRole
AuthorizationRequestleague's request + the nonce
AuthCodeGrantreads nonce from /oauth/authorize, stores it in the encrypted code payload, hands it to the response at /oauth/token
IdTokenResponsePassport's bearer response + id_token when the openid scope was granted
IdTokenBuilder / Claimsthe claims per scope; signs with Passport's private key (firebase/php-jwt, already a Passport dependency)
Keysthe public key as a JWK, the kid (RFC 7638 thumbprint)
AccessTokenPassport's entity, serialised once so at_hash matches the token actually sent
Concerns\RetrievesOidcAuthRequestlets the consent controllers restore our request class from the session

App\Providers\PassportServiceProvider extends Passport's provider to build the custom grant; composer.json disables Passport's auto-discovery so only this provider registers.

External identities as a door, not as accounts#

Sign-in with Google, GitHub and Microsoft (Laravel Socialite + socialiteproviders/microsoft) is optional and enabled per provider by its credentials. An external identity is a connection to an existing person (social_accounts), never a source of new accounts, and it stands in for the password only: SocialLoginController hands people with TOTP to Fortify's two-factor challenge exactly like RedirectIfTwoFactorAuthenticatable does, then answers with Fortify's LoginResponse, so the intended /oauth/authorize URL survives. Applications see no difference. Details and the reasoning in social-login.md.

Routes declared by hand#

Passport::ignoreRoutes() and routes/oauth.php re-declare the four Passport routes we use (token, authorize GET/POST/DELETE) so EnsureUserMayUseClient can protect /oauth/authorize, and add the OIDC endpoints. The file is loaded without the web group (see bootstrap/app.php): the token, JWKS, discovery and UserInfo endpoints stay stateless; the browser-facing ones add web explicitly. /oauth/logout is excluded from CSRF because applications POST to it from another origin.

One UI, one login#

The administration is a set of Livewire pages under the same layout and sidebar as the launcher and the settings; no second framework, no second CSS bundle, no second login. App\Http\Middleware\EnsureUserIsAdmin (alias admin) admits administrators who are not suspended; User::canAdminister() decides, and the sidebar shows the group only to them.

Access control at the door#

EnsureUserMayUseClient runs on /oauth/authorize:

  1. no user yet → let Passport send them to /login (they come back afterwards);
  2. unknown or disabled client → let Passport answer invalid_client;
  3. suspended person, or application restricted to assigned people without an assignment → 403 page, access-log entry, error=access_denied link back to the app.

Consent is skipped for trusted applications (Client::skipsAuthorization()); Passport also skips it once the person already holds a valid token for the requested scopes.

How a sign-in travels#

  1. The person clicks Continue with Checkin in an app; the client package stores state, nonce and a PKCE verifier in the app's session and redirects to /oauth/authorize?...&code_challenge=…&nonce=….
  2. Not signed in at Checkin? Fortify's login (password, passkey or security key, or a connected Google/GitHub/Microsoft account; then TOTP if enabled) and back.
  3. EnsureUserMayUseClient checks the person may use the app. Passport validates the request; AuthCodeGrant keeps the nonce.
  4. Trusted app (or prior consent) → an authorization code (encrypted JSON carrying client, user, scopes, PKCE challenge, nonce) is sent to the app's redirect URI with the state.
  5. The app posts the code and the PKCE verifier (plus its secret) to /oauth/token. AuthCodeGrant verifies, issues the access and refresh tokens, and IdTokenResponse adds an RS256 ID token with sub = the person's UUID, the nonce, auth_time (last login) and at_hash.
  6. The app verifies the ID token with /oauth/jwks, fetches /oauth/userinfo, finds or creates its local user, logs them in.
  7. AccessTokenCreated lands in the audit log with the person and the application.

Data model#

TableNotes
usersstarter-kit columns + uuid (public sub), role (admin/user), username, last_login_at, suspended_at, Fortify 2FA columns
passkeyslaravel/passkeys credentials (one row per passkey or security key)
social_accountsGoogle/GitHub/Microsoft identities connected to a person: provider, provider_id (unique together), profile copy, last_used_at; no tokens
oauth_clientsPassport + slug, description, launch_url, trusted, access (everyone/assigned), sort
client_userpeople assigned to restricted applications
oauth_auth_codes, oauth_access_tokens, oauth_refresh_tokensPassport
access_logsevent, user_id, client_id, email, ip_address, user_agent, context, created_at

App\Listeners\AccessLogSubscriber turns the authentication events of Laravel, Fortify, Passkeys and Passport into rows, and keeps users.last_login_at (used as auth_time).

Self-update#

app/Updates/Updater.php, UpdateState.php, UpdateFailed.php and app:update are copied verbatim from Boogle (identical in Hackly and IndieStats): keep them in sync across the four applications when one of them changes. config/updates.php points at this repository; VERSION holds the installed version; routes/console.php schedules app:update pending every minute and app:update apply --auto nightly. The Updates page is resources/views/pages/admin/⚡updates.blade.php, with admin/updates/status polled while an update runs.