Skip to content
Back to skills

Workos Knowledge Patch

ASecurity

WorkOS

  • 25 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added September 5, 2026
developmentjavascriptpythongojavareactnextjsnodeapibackend

Works with

  • cursor
  • terminal
  • cli
  • api

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill workos-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Workos Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Workos Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-workos-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-workos-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: workos-knowledge-patch
description: WorkOS
version: "12.4.1"
license: MIT
metadata:
  author: Nevaberry
---



# WorkOS Knowledge Patch

Load this skill when implementing or upgrading WorkOS SDK integrations,
AuthKit authentication, authorization, SSO, Directory Sync, or platform products.
Use the topic references for task-specific details and examples.

## Reference index

| Reference | Topics |
| --- | --- |
| [API and SDK contracts](references/api-and-sdk-contracts.md) | Runtime requirements, Python and Go clients, backend and mobile SDKs, framework integrations, CLI, OpenAPI |
| [Authentication and sessions](references/authentication-and-sessions.md) | PKCE, authorization URL options, session cookies, token verification, authentication data, user lifecycle |
| [AuthKit for Next.js](references/authkit-nextjs.md) | Callback setup, PKCE cookies, proxy composition, caching, server sessions, client tokens, impersonation |
| [AuthKit for React](references/authkit-react.md) | Browser setup, redirect state, token storage and refresh, claims, organization switching |
| [Authorization and features](references/authorization-and-features.md) | Resources, groups, roles, memberships, feature flags, legacy FGA |
| [Node SDK migrations](references/node-sdk-migrations.md) | API types, event unions, HTTP behavior, errors, pagination, webhooks |
| [Platform products](references/platform-products.md) | Agents, Pipes, Connect, API keys, Audit Logs, Vault, Radar, delivery and operations |
| [SSO, directories, and widgets](references/sso-directory-and-widgets.md) | SSO lifecycle, Directory Sync, Admin Portal, IT contacts, domain verification, embedded widgets |

## Breaking changes and upgrade checks

### API values and exhaustive handlers

In Node SDK v12.0.0, API timestamps deserialize as JavaScript `Date` objects.
Update consumers that parse or compare those fields as strings. Nullable SSO
`Profile` fields are required properties that can hold `null`; handle `null`
and supply it for missing values in typed fixtures.

The same release aligns enums and nullable types with the API spec, adds
`UnknownEvent` to the `Event` union, and adds 28 typed events from the spec.
Check exhaustive enum branches and nullable fields, and include a fallback for
unrecognized events in exhaustive handlers.

### Removed and renamed options

- When upgrading to v12.2.0, drop `order` from `listEvents()` calls because
  the endpoint does not support it.
- In v12.0.0, replace the Admin Portal option `adminEmails` with `itContactEmails`.
- When upgrading to v10, remove `search` from Authorization's `listResources()`.
- When upgrading to v9, change `sdk.portal` to `sdk.adminPortal`.
- Migrate legacy FGA integrations before upgrading to v9, which removes the
  package. Authorization resources and FGA deprecation arrived in v8.4.0.
- From v8.3.1, match `api_key.revoked` in handlers that matched `api_key.deleted`.

### Product-specific SDK contracts

In Node SDK v11.0.0, Pipes support for organization-owned and multiple
connections is a breaking change. Review assumptions that every connection is
user-owned or that only one connection is available.

Node SDK v12.0.0 moves Directory Sync to code generated from the API spec;
check calls and response types against its definitions. It also removes
duplicate Vault object interfaces; use the remaining Vault object types for
affected imports. In v12.3.0, check feature flag rule and target management
calls against the updated contracts that follow the API definitions.

### Session and verification requirements

From v12.2.0, session-cookie authentication requires a user access token.
`totp` is optional on listed `AuthenticationFactor` values; check its presence
before reading its contents.

From v9.3.1, pass raw request bytes to webhook signature verification and
preserve the body before JSON parsing if the framework would discard it.
In v12.0.0, verification rejects malformed and future webhook timestamps.
From v12.4.1, JWT verification rejects algorithms outside the explicit allowlist.

### Runtime and framework migration

The Node SDK README specifies Node.js 20 or later. Before installing the v9
SDK, upgrade the runtime to Node.js 22.11 or later.

AuthKit for Next.js v3 enables PKCE on every authorization request: remove
`WORKOS_ENABLE_PKCE`, preserve `Set-Cookie` through redirects, and return
`wos-auth-verifier` on the callback. A missing cookie fails with
`Auth cookie missing`; a cookie differing from URL `state` fails with
`OAuth state mismatch`. The callback clears the verifier cookie after use.

Use `authkitProxy()` in `proxy.ts` for Next.js 16+ and `authkitMiddleware()`
in `middleware.ts` for Next.js 15 and earlier.

## PKCE and authorization URLs

For a browser, mobile app, or CLI, initialize with only a client ID. Open the
returned `url` for sign-in and keep `codeVerifier` in secure on-device storage
until the callback, including across app restarts.

```ts
import { WorkOS } from '@workos-inc/node';

const clientId = 'client_...';
const sdk = new WorkOS({ clientId });

function beginSignIn() {
  return sdk.userManagement.getAuthorizationUrlWithPKCE({
    provider: 'authkit',
    redirectUri: 'myapp://callback',
    clientId,
  });
}

function exchangeCode(code: string, codeVerifier: string) {
  return sdk.userManagement.authenticateWithCode({ clientId, code, codeVerifier });
}
```

For a confidential client, use the same flow with `new WorkOS('sk_...')` on the
server. With `codeVerifier`, `authenticateWithCode()` sends both
`client_secret` and `code_verifier`.

User Management's `getAuthorizationUrl()` supports `max_age` and
`invitationToken`. Forward an agent claim nonce with
`sdk.userManagement.getAuthorizationUrl({ ...options, claimNonce })`;
`options` contains the other authorization URL settings.

## Next.js AuthKit

### Callback and session configuration

Configure `WORKOS_CLIENT_ID`, `WORKOS_API_KEY`, and a `WORKOS_COOKIE_PASSWORD`
of at least 32 characters. Set `NEXT_PUBLIC_WORKOS_REDIRECT_URI` to the
registered callback URL and export `handleAuth()` as that route's `GET` handler.
The proxy's `redirectUri` overrides the environment callback URL.
`handleAuth({ baseURL: 'https://app.example.com' })` sets the public redirect
origin when requests arrive with an internal hostname.

`WORKOS_COOKIE_NAME` defaults to `wos-session`; `WORKOS_COOKIE_MAX_AGE` defaults
to `34560000` seconds (400 days). An unset `WORKOS_COOKIE_DOMAIN` scopes the
cookie to the current host. Parent-domain sharing needs the same cookie password.
`WORKOS_COOKIE_SAMESITE` defaults to `lax`, accepts `strict` or `none`, and
forces Secure with `none`.

### Route protection and response handling

`middlewareAuth.enabled` requires sign-in for matched routes except
`unauthenticatedPaths`, which uses Next.js matcher syntax. `signUpPaths`
requests the sign-up screen for selected paths redirecting to AuthKit.

When composing a proxy, `authkit(request)` returns `session`, `headers`, and
`authorizationUrl`. Use `handleAuthkitHeaders(request, headers, { redirect: authorizationUrl })`
to redirect or `handleAuthkitHeaders(request, headers)` to continue.
For rewrites, use `partitionAuthkitHeaders(request, headers).requestHeaders`
with `NextResponse.rewrite()` and apply `responseHeaders` with
`applyResponseHeaders(response, responseHeaders)`.

A session cookie, an `Authorization` header, or an active authenticated session
triggers cache protection. Preserve `Cache-Control` with `private` and
`no-store`, `Vary: Cookie`, and `x-middleware-cache: no-cache` through custom
response logic and the CDN.

### State, hydration, and tokens

Next.js `getSignInUrl()` and `getSignUpUrl()` accept application `state` as a
string. `handleAuth({ onSuccess })` receives it with the authentication payload;
the Next.js reference lists required and optional fields.

Seed `AuthKitProvider`'s `initialAuth` with the session from server-side `withAuth()`,
excluding the access token, to avoid an auth server action on mount.
`useAccessToken()` refreshes tokens before expiry; its `refresh()` resolves to
`string | undefined` and updates the auth session. `useAuth().refreshAuth()`
also updates the hook's token.

Switch organization using server-side `refreshSession({ organizationId })`
in a server action or route handler, or client-side
`useAuth().refreshAuth({ organizationId })`. This refreshes roles and permissions.
An unauthorized switch produces an authentication error, exposed by the client
method on `result?.error`.

## Browser React AuthKit

Configure the callback Redirect URI and the app origin under allowed origins.
For dashboard impersonation and other external login flows, register `/login`
as the sign-in endpoint and have that route call `signIn()` inside `AuthKitProvider`.

Pass state as an object with `signIn({ state: { returnTo: '/dashboard' } })`
and read it in `onRedirectCallback(({ state }) => …)`.
Switch organization with `await switchToOrganization({ organizationId, signInOpts })`;
`signInOpts` is optional.

`getAccessToken()` refreshes as needed and throws `LoginRequiredError` when
no user is authenticated. `getClaims(accessToken)` decodes claims such as
`org_id` and `permissions`. `devMode` uses `localStorage` and is enabled
automatically on `localhost` and `127.0.0.1`. Return `false` from
`onBeforeAutoRefresh` to skip automatic refresh.

## Authorization and feature flags

Group role assignments include `source` to identify grants from groups.
AuthKit organization memberships support multiple roles, including identity-provider role
assignment through SSO and Directory Sync. IT admins can map identity-provider
groups to roles during SSO setup in the Admin Portal.

Use the feature flags runtime client for local evaluation from v8.11.0 and
custom target evaluation from v10.11.0. In v12.0.0, targeting rules are evaluated
in order; review the order when targets overlap. Polling continues after an
error even without an error listener. From v12.3.0, polling timeouts are reported
and abandoned requests are canceled.

## Requests, sessions, and platform APIs

From v10.14.0, pass raw path parameter values to legacy modules so the SDK
URL-encodes them once. Request timeouts also cover reading the response body.
From v12.3.0, SDK API requests stop at HTTP redirect responses.

From v12.0.0, automatic pagination drops the initial `before` cursor on follow-up
requests. From v12.2.0, `autoPagination()` starts with the page already returned
by the list call and fetches subsequent pages as needed.

`CookieSession.refresh()` distinguishes transient from terminal failures so
callers can decide whether to retry. From v10.14.0, successful refresh returns
the refreshed `user` and `impersonator`; use them to update the application session.
From v12.3.0, `getLogoutUrl()` works after the session access token expires.

Use `connect.exchangeToken()` for RFC 8693 OAuth token exchange from v12.2.0.
Pipes supports API-key installations and Data Integration operations;
`finishConnection()` completes a connection from v12.1.0, and
`authorizeDataIntegration()` results include `state` from v12.2.0.

From v12.3.0, `createOrganizationApiKey()` accepts `expiresAt`, and
`adminPortal.generateLink()` accepts `externalUserId`. Use
`adminPortal.revokeLink()` to invalidate a generated link.
From v12.4.0, use `sso.authorizeLogout()` for RP-initiated Single Logout and
`sso.listConnections({ state })` to filter connections by state.

Files in this skill

  • SKILL.md9 KB
  • coverage.json898 B
  • references/api-and-sdk-contracts.md2.2 KB
  • references/authentication-and-sessions.md2.7 KB
  • references/authkit-nextjs.md5.1 KB
  • references/authkit-react.md1.6 KB
  • references/authorization-and-features.md2.3 KB
  • references/node-sdk-migrations.md4.5 KB
  • references/platform-products.md3.1 KB
  • references/sso-directory-and-widgets.md2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.