Skip to content

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.

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.

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.
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.

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.

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).

Roles can change after sign-in. How each stack notices:

  • Refresh tokens. Ask for offline_access and 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 offers POST /flowcatalyst/refresh for a “refresh my permissions” button.
  • Revocation checks (Laravel). FLOWCATALYST_OIDC_CHECK_REVOCATION=true asks 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.

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, with FLOWCATALYST_REDIRECT_AFTER_LOGOUT registered as a post-logout redirect URI.
  • Go SDK: oauthClient.LogoutURL(postLogoutRedirectURI, idTokenHint, state).
  • Framework: POST /auth/logout answers the platform’s endSessionUrl when it has one.

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).

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.

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.