Skip to content

feat: support keyless PKCE public clients - #96

Merged
nicknisi merged 2 commits into
mainfrom
riker/55-let-workos-inc-authkit-react-router-run
Oct 6, 2026
Merged

nicknisi merged 2 commits into
mainfrom
riker/55-let-workos-inc-authkit-react-router-run

Conversation

@nicknisi

@nicknisi nicknisi commented Oct 5, 2026

Copy link
Copy Markdown
Member

Let @workos-inc/authkit-react-router run as a keyless PKCE public client: a server that only needs to sign users in works with WORKOS_CLIENT_ID, WORKOS_REDIRECT_URI and WORKOS_COOKIE_PASSWORD, with no WORKOS_API_KEY. Model the config as a discriminated union (confidential client with an apiKey vs public client without one), so TypeScript makes clear which features need a key. Then demonstrate it working end to end in the React Router example app (/Users/nicknisi/Developer/react-router-authkit-example) running against the local build with no API key, and hand Nick a running demo plus exact steps so he can sign in, see the session load, and see a token refresh succeed.

Riker's check npm run typecheck && npm run lint && npm run prettier && npm test && npm run build passed.

Opened as a draft by Riker (job 55).

@nicknisi
nicknisi marked this pull request as ready for review October 5, 2026 23:35
WORKOS_API_KEY is now optional. Without it, AuthKit builds the WorkOS client
with only a client ID and runs as a PKCE public client: code exchange and
refresh send no client_secret.

- AuthKitConfig is a union of AuthKitConfidentialConfig (apiKey) and
  AuthKitPublicConfig (no apiKey); getConfig('apiKey') is string | undefined
- WorkOS is constructed with the options form, passing apiKey and clientId
- getFeatureFlagsRuntimeClient throws an actionable error without a key
- README documents public client mode and what needs a key
@nicknisi
nicknisi force-pushed the riker/55-let-workos-inc-authkit-react-router-run branch from a3d4552 to c080133 Compare October 5, 2026 23:37
@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Critical risk] Allows AuthKit to run without an API key, changing authentication mode.

The PR appears safe to merge based on the reviewed changes.

Summary

The PR adds keyless PKCE public-client configuration, retains API-key requirements for feature flags and management calls, and documents and tests callback and refresh behavior.

  • The follow-up clarifies that withAuth does not refresh automatically.
  • It adds an expired-session authkitLoader test covering refresh credentials and a replacement cookie.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  C[Client configuration] --> K{API key present?}
  K -->|No| P[Public PKCE client]
  K -->|Yes| S[Confidential client]
  P --> A[Sign-in and callback]
  S --> A
  A --> L[Session cookie]
  L --> R[authkitLoader refresh]
  S --> F[Feature flags and management APIs]
Loading

Reviews (2) · Last reviewed commit: "test: cover automatic keyless refresh in..."

Comment thread README.md Outdated
Comment thread src/public-client.spec.ts
Add a public-client spec case that loads a route with an expired, really
signed access token: authkitLoader verifies it against the client's JWKS,
refreshes without a client secret, and returns a replacement session cookie.
Clarify in the README that withAuth does not refresh on its own.
@nicknisi
nicknisi requested review from a team, cmatheson and stacurry October 6, 2026 04:32
@nicknisi
nicknisi merged commit 379a24f into main Oct 6, 2026
10 checks passed
@nicknisi
nicknisi deleted the riker/55-let-workos-inc-authkit-react-router-run branch October 6, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants