Configure your authentication flows
Auth and access
A workflow is code you own, triggered by Kinde, that shapes tokens, auth steps, and integrations that Kinde doesn’t support out of the box.
How it works:
The following workflow removes the permissions and feature_flags claims from the access token. See the full workflow example: Customize token with workflow.
import { onUserTokenGeneratedEvent, WorkflowSettings, WorkflowTrigger, accessTokenCustomClaims,} from "@kinde/infrastructure";
// The setting for this workflowexport const workflowSettings: WorkflowSettings = { id: "removeClaimWorkflow", name: "Remove Claim Workflow", trigger: WorkflowTrigger.UserTokenGeneration, failurePolicy: { action: "stop", }, bindings: { "kinde.accessToken": {}, // required to modify access token claims url: {}, // required for URL parameters },};
// The workflow code to be executed when the event is triggeredexport default async function Workflow(event: onUserTokenGeneratedEvent) { const accessToken = accessTokenCustomClaims<{ permissions: string[], feature_flags: Record<string, unknown>, }>()
accessToken.permissions = [] accessToken.feature_flags = {}}We’ll add more triggers over time, including the option to create your own.
Workflow for Kinde to recognize them as containing workflow code. For example, MFAWorkflow.ts or PreauthorizationWorkflow.jsx..ts, .js, .tsx, or .jsx.