Use FlowCatalyst as your app's identity provider
FlowCatalyst is an OpenID Connect provider. Your web application can hand sign-in to it: the platform hosts the sign-in page and every credential (passwords, second factors, passkeys, an organisation’s SSO through the OIDC bridge), and your application receives a verified identity with the user’s roles in your application. The tutorial sign users in walks one login end to end; this page covers the choices around it.
The model in one paragraph
Section titled “The model in one paragraph”Your application is an OIDC relying party and its own backend-for-frontend: it runs the
authorization-code flow with PKCE, verifies the id_token once at the callback, and starts its
own session (a cookie). The id_token lives 5 minutes and carries sub, name, email, tier,
clients and the user’s roles, narrowed to the applications the login client is linked to. The
access token that comes with it is an identity token (token_use=identity) unless the client is
flagged apiAccess: it cannot call the platform API. Tokens explains the split.
Register a login client
Section titled “Register a login client”| Choice | When |
|---|---|
| Confidential client (has a secret) | A server-side web application. |
| Public client (PKCE only, no secret) | A single-page or native application, or a server that prefers not to hold a secret. PKCE is enforced. |
apiAccess |
Only for a trusted first-party application that must call the platform API as the signed-in person (an operator console). Its logins receive token_use=api tokens narrowed to the client’s applications. Leave it off otherwise. |
Provision it from the application’s page in the console (Login Client, Provision Login
Client) or with POST /api/applications/{id}/provision-login-client
({"clientType": "CONFIDENTIAL" | "PUBLIC", "redirectUris": [...]}). The client gets the
authorization_code and refresh_token grants and the openid profile email scopes, and is linked
to the application. Then, under OAuth clients:
- Redirect URIs are matched exactly. Register each environment’s callback (scheme, host, port, path).
- Post-logout redirect URIs are needed for single logout (below).
- Allowed origins, for a browser application that calls the token endpoint directly.
Wire it
Section titled “Wire it”import { flowcatalystAuth, defineRbac, PgSessionStore, initSessionSchema } from "@flowcatalyst/sdk/fastify";
await initSessionSchema(pool);await app.register(flowcatalystAuth, { baseUrl: "https://platform.example.com", clientId: process.env.FC_CLIENT_ID!, clientSecret: process.env.FC_CLIENT_SECRET!, // a confidential client cookie: { secret: process.env.SESSION_SECRET! }, // 32 bytes, base64url publicBaseUrl: "https://orders.example.com", // callback = publicBaseUrl + /auth/callback scope: "openid profile email offline_access", // offline_access: refresh tokens rbac: defineRbac().role("orders:clerk").grants("orders:sales:order:*").build(), sessionStore: new PgSessionStore({ executor: pool, cookieName: "fc_session", cookieOptions: { path: "/", httpOnly: true, secure: true, sameSite: "lax", maxAge: 8 * 3600 } }),});Routes: /auth/login, /auth/callback, /auth/logout (rename with routes). The default
CookieSessionStore keeps the encrypted session in the cookie (about 4 KB, nothing on the
server); PgSessionStore and RedisSessionStore keep it server-side, so sessions can be revoked
and hold more data.
FLOWCATALYST_BASE_URL=https://platform.example.comFLOWCATALYST_OIDC_ENABLED=trueFLOWCATALYST_NATIVE_LOGIN=trueFLOWCATALYST_OIDC_CLIENT_ID=...FLOWCATALYST_OIDC_CLIENT_SECRET=... # omit for a public (PKCE) clientFLOWCATALYST_OIDC_SCOPE="openid profile email offline_access"Routes: /flowcatalyst/login, /flowcatalyst/callback, /flowcatalyst/logout,
/flowcatalyst/refresh. The redirect URI is https://your-app/flowcatalyst/callback.
| Mode | Set | Local user | Permissions from |
|---|---|---|---|
| Local sync (default with the native-login bridge) | FLOWCATALYST_OIDC_HANDLER=database |
Upserted by email at sign-in (FLOWCATALYST_OIDC_USER_MODEL) |
Spatie tables, filled from the user’s roles and each role’s permissions at sign-in and refresh |
| Stateless | FLOWCATALYST_OIDC_HANDLER=session |
None | A bound RbacCatalogue (roles to permissions) |
The native-login bridge also makes the stock auth middleware send guests into the login (opt
out with FLOWCATALYST_OIDC_AUTO_GUEST_REDIRECT=false; an application’s own login route
wins). Bind your own OidcUserHandler for tenant checks or extra columns.
The application framework’s auth module (go/v0.2.0) is the Go relying party:
mod, err := authd.Build(ctx, b, auth.SessionStore(authdb.Factory(dbs)), // fw_session table; or authredis, cookie, memory auth.Application(fw.MustApplicationCode("orders")), auth.Permissions(auth.ScopesMapper().And(auth.ByRole(map[string][]string{ "orders:clerk": {"orders:sales:order:view"}, }))), auth.IdleTimeout(30*time.Minute), auth.AbsoluteTimeout(8*time.Hour))Configuration: AUTH_ISSUER, AUTH_CLIENT_ID, AUTH_CLIENT_SECRET (confidential only),
AUTH_PUBLIC_BASE_URL. Endpoints: /auth/login, /auth/callback, /auth/session,
/auth/logout. The framework does not use refresh tokens: its session has its own idle and
absolute lifetimes, and offline_access in the scope fails start-up. Without the framework, the
Go SDK’s auth.OAuthClient gives the building blocks (authorize URL with PKCE, code exchange,
refresh, revoke, userinfo, logout URL).
The application framework’s AuthModule (framework-auth) is the Java relying party:
.module(new AuthDatabaseModule()).module(AuthModule.builder() .application(new ApplicationCode("orders")) .permissions(PermissionMapper.scopes().and(PermissionMapper.byRole(Map.of( "orders:clerk", Set.of("orders:sales:order:view"))))) .build())Configuration: AUTH_ISSUER, AUTH_CLIENT_ID, AUTH_CLIENT_SECRET (confidential only),
AUTH_PUBLIC_BASE_URL. Endpoints: /auth/login, /auth/callback, /auth/session,
/auth/logout. See sessions and login.
Choose the ID-token signing algorithm
Section titled “Choose the ID-token signing algorithm”Each OAuth client chooses the algorithm that signs the ID tokens it receives: ID token signing
algorithm on the client’s form under OAuth clients, or idTokenSignedResponseAlg in the API
(id_token_signed_response_alg in OIDC terms). The default is RS256.
| Algorithm | What it is |
|---|---|
RS256 |
RSA. The default, and what every relying party can verify. |
EdDSA |
Ed25519. Small and fast. |
ML-DSA-65 |
A post-quantum signature (FIPS 204). |
The platform’s keyring always holds a key of each algorithm, so switching a client needs no operator step, and discovery lists the published algorithms. The relying party’s library must support the algorithm you choose: a library that does not refuses every ID token, and users cannot sign in. Change the algorithm only after you have checked the application’s verifier. What the SDKs and the framework verify, from their source:
| Relying party | Verifies |
|---|---|
| PHP SDK (Laravel bridge) | RS256 and EdDSA (it needs ext-sodium). It refuses ML-DSA-65 with a message that says to use RS256 or EdDSA. |
Application framework, Go (auth module) and Java (framework-auth) |
RS256 only. Leave the client on RS256. |
| TypeScript SDK (Fastify plugin) | Verification is by the jose library with no algorithm restriction, so it accepts what the installed jose version supports for the key in the platform’s JWKS. It has not been checked end to end against EdDSA or ML-DSA-65 tokens. |
For other libraries, check the library’s own documentation. The signing keys and their rotation are an operator matter: see rotate signing keys.
Protect routes
Section titled “Protect routes”Browsers and machines authenticate differently, and the guards keep them apart:
| Browser (session cookie) | API caller (Authorization: Bearer) |
Either | |
|---|---|---|---|
| TypeScript | app.fc.requireSession(): 302 to login |
app.fc.requireBearer(): 401 JSON |
app.fc.requireAuth(): redirects a browser navigation, 401 for everything else |
| PHP | auth, auth:fc-session, or ['fc.auth', 'fc.session'] |
auth:fc-token, or ['fc.auth', 'fc.bearer'] |
['fc.auth', 'fc.any'] |
| Framework | requiresContext(): 401, turned into 302 /auth/login for an HTML navigation |
the same routes accept a bearer token | the same |
A bearer token is checked as a platform API access token: signature (RS256, keys from discovery),
issuer, expiry and token_use. Your own SPA calling your own backend should use the session cookie,
not a platform token; bearer tokens are for services calling you (another application’s service
account, for example). A token’s permissions are its scope claim.
Fetch and XHR requests without a session get a 401, not a redirect, so your front end can react
(for example by sending the browser to the login URL).
Keep sessions fresh
Section titled “Keep sessions fresh”Roles can change after sign-in. How each stack notices:
- Refresh tokens. Ask for
offline_accessand the platform issues a refresh token (rotated on every use, with reuse detection, and a 7-day absolute limit). The TypeScript plugin refreshes the session in the background before the access token expires; Laravel refreshes before expiry and offersPOST /flowcatalyst/refreshfor a “refresh my permissions” button. - Revocation checks (Laravel).
FLOWCATALYST_OIDC_CHECK_REVOCATION=trueasks the platform, at most once per cache window, whether the user or their roles changed since the token was minted, and forces a refresh if so. - Framework sessions have idle (30 minutes) and absolute (8 hours) lifetimes; the user signs in again after that.
Sign out
Section titled “Sign out”Signing out of your application clears your session. To end the platform session too (single
logout), send the browser to the platform’s end-session endpoint (/auth/oidc/session/end, also in
the discovery document) with a post_logout_redirect_uri registered on the client:
- TypeScript:
app.fc.logout(req, reply, { redirectTo: "https://platform.example.com/logout" })clears the local session and redirects. - Laravel:
FLOWCATALYST_OIDC_SINGLE_LOGOUT=true, withFLOWCATALYST_REDIRECT_AFTER_LOGOUTregistered as a post-logout redirect URI. - Go SDK:
oauthClient.LogoutURL(postLogoutRedirectURI, idTokenHint, state). - Framework:
POST /auth/logoutanswers the platform’sendSessionUrlwhen it has one.
Send users to their organisation’s SSO
Section titled “Send users to their organisation’s SSO”When an organisation signs in through its own identity provider, the platform picks it from the email
domain (sign-in and federation). To skip the email prompt, name the provider:
Laravel FLOWCATALYST_OIDC_PROVIDER=idp_... (or ?provider= per request).
Brand the sign-in page
Section titled “Brand the sign-in page”Add the client’s identifier to the login (client=acme) and the platform’s sign-in pages wear that
client’s branding (logo, colours, name, footer) configured under Clients, Login Branding. It
is cosmetic only: it changes nothing about who may sign in. TypeScript client: "acme" (or
?client= on the login route), Laravel FLOWCATALYST_OIDC_CLIENT=acme, framework
.loginTheme("acme") / auth.LoginTheme.
Customers, not staff?
Section titled “Customers, not staff?”For a client’s own customers (people who are not platform users), use the separate portal
identity plane: build a customer portal. TypeScript portal: true and Laravel
FLOWCATALYST_OIDC_PORTAL=true switch the same flow to it.
Related
Section titled “Related”- Define and check permissions in code.
- Tokens, principals, second factors.
- Token claims and the OAuth routes.
- SDK pages: TypeScript Fastify, PHP auth.