/** * Authentication options for the observability UI, shared by * `createWorkflowWebHandler` (`@workflow/web/handler`) and `startServer` * (`@workflow/web/server`). * * When `auth` is given, the `WORKFLOW_WEB_AUTH*` environment variables are * ignored. Every list also accepts a comma-separated string, as in the * variables. */ export interface WorkflowWebAuthOptions { /** * `jwt`: verify a token on every request against a JWKS. `oidc`: sign users * in with an OpenID Connect provider. `none`: no authentication. * (`WORKFLOW_WEB_AUTH`) */ mode: 'none' | 'jwt' | 'oidc'; /** * Expected `iss`. In `oidc` mode, also where discovery is read from. * (`WORKFLOW_WEB_AUTH_ISSUER`) */ issuer?: string; /** `jwt` only: accepted `aud` values. (`WORKFLOW_WEB_AUTH_AUDIENCE`) */ audience?: string | string[]; /** `jwt` only: where the signing keys are. (`WORKFLOW_WEB_AUTH_JWKS_URL`) */ jwksUrl?: string; /** * Accepted signing algorithms; asymmetric only. Default: every RS, PS and * ES algorithm and EdDSA. (`WORKFLOW_WEB_AUTH_ALGORITHMS`) */ algorithms?: string | string[]; /** * Seconds of clock skew accepted on `exp`, `nbf` and `iat`. Default 5. * (`WORKFLOW_WEB_AUTH_CLOCK_TOLERANCE`) */ clockTolerance?: number; /** * `jwt` only: the header the token is read from. Default `authorization`, * as `Bearer `; another header may also carry the bare token. * (`WORKFLOW_WEB_AUTH_TOKEN_HEADER`) */ tokenHeader?: string; /** * `jwt` only: a cookie the token is read from when the header is absent. * (`WORKFLOW_WEB_AUTH_TOKEN_COOKIE`) */ tokenCookie?: string; /** * `oidc` only. Default `/.well-known/openid-configuration`. * (`WORKFLOW_WEB_AUTH_DISCOVERY_URL`) */ discoveryUrl?: string; /** `oidc` only. (`WORKFLOW_WEB_AUTH_CLIENT_ID`) */ clientId?: string; /** * `oidc` only. Omit for a public client, which relies on PKCE alone. * (`WORKFLOW_WEB_AUTH_CLIENT_SECRET`) */ clientSecret?: string; /** * `oidc` only: the public URL of `/_auth/callback`. * (`WORKFLOW_WEB_AUTH_REDIRECT_URI`) */ redirectUri?: string; /** * `oidc` only. Default `openid email profile`; `openid` is always added. * (`WORKFLOW_WEB_AUTH_SCOPES`) */ scopes?: string | string[]; /** * `oidc` only: at least 32 characters each. The first encrypts new session * cookies; all of them open existing ones. (`WORKFLOW_WEB_AUTH_SESSION_SECRET`) */ sessionSecret?: string | string[]; /** * `oidc` only: seconds a sign-in lasts. Default 28800 (8 hours). * (`WORKFLOW_WEB_AUTH_SESSION_MAX_AGE`) */ sessionMaxAge?: number; /** * `oidc` only. Default `__Host-workflow_web_session`, or * `workflow_web_session` without `cookieSecure`. * (`WORKFLOW_WEB_AUTH_COOKIE_NAME`) */ cookieName?: string; /** * `oidc` only. Default: true unless `redirectUri` is plain `http:` on * localhost. (`WORKFLOW_WEB_AUTH_COOKIE_SECURE`) */ cookieSecure?: boolean; /** Exact `sub` values allowed. (`WORKFLOW_WEB_AUTH_ALLOWED_SUBJECTS`) */ allowedSubjects?: string | string[]; /** * Email addresses allowed; only with `email_verified: true`. * (`WORKFLOW_WEB_AUTH_ALLOWED_EMAILS`) */ allowedEmails?: string | string[]; /** * Email domains allowed, exact (not subdomains); only with * `email_verified: true`. (`WORKFLOW_WEB_AUTH_ALLOWED_DOMAINS`) */ allowedDomains?: string | string[]; /** Groups allowed. (`WORKFLOW_WEB_AUTH_ALLOWED_GROUPS`) */ allowedGroups?: string | string[]; /** The claim holding groups. Default `groups`. (`WORKFLOW_WEB_AUTH_GROUPS_CLAIM`) */ groupsClaim?: string; /** * Claims that must have one of the given values, such as * `{ environment: 'production' }`. (`WORKFLOW_WEB_AUTH_REQUIRED_CLAIMS`, as * JSON) */ requiredClaims?: Record< string, string | number | boolean | Array >; /** * When set, only these groups get write access; everyone else allowed in * gets read access. (`WORKFLOW_WEB_AUTH_WRITE_GROUPS`) */ writeGroups?: string | string[]; /** * Final say on verified claims, after the allowlists: `false` refuses, * `'read'` or `'write'` sets the access, `true` keeps it. In `oidc` mode it * runs once, at sign-in. Not available as a variable. */ authorize?: ( claims: Record, decision: { access: 'read' | 'write' } ) => boolean | 'read' | 'write' | Promise; } /** `false` or `'none'` turn authentication off, like `{ mode: 'none' }`. */ export type WorkflowWebAuth = WorkflowWebAuthOptions | 'none' | false;