clauth github ↗ Get started

Docs · Extend

Build a kit for your language

A kit is a small library that connects one framework to Clauth. Follow this contract and your kit behaves exactly like the official ones — then list it on the Kits page.

Reference kit clauth-laravel In progress clauth-node

What a kit does

Any OIDC library can sign people in to Clauth. A kit adds the parts that make apps consistent: permission checks per organization, token refresh so role changes land, the permissions manifest, and the Clauth bar.

Sign in

Code + PKCE + nonce

Verify

Tokens against JWKS

Check

Permissions per org

Show

Manifest + Clauth bar

The contract

Must items are required to be listed as a Clauth kit. Should items are strongly recommended.

MUST
Use Authorization Code with PKCE (S256), state and nonce.

Clauth rejects sign-ins without PKCE and a nonce.

MUST
Verify every ID and access token locally.

Signature via /.well-known/jwks.json (cache about an hour; refetch once on an unknown kid), plus iss, aud = the app key, exp and nonce.

MUST
Link local users by sub, never by email alone.

Email may be used once to link an existing user; after that, sub is the identity.

MUST
Expose permission checks per organization.

Read orgs.<org>.permissions; offer a "can" helper and a route guard that returns 403.

MUST
Refresh the token at least every 15 minutes while signed in.

Apply new roles on refresh; if refresh fails because the person was disabled, sign them out.

MUST
Serve the permissions manifest at /.well-known/clauth.json

Built from the app's own config: permissions and roles.

MUST
Render the Clauth bar.

A one-line include for templates, backed by /bar/v1 and /api/v1/bar fetched server-side.

MUST
Be off by default.

Do nothing to sign-in until CLAUTH_ENABLED=true, so apps can install it safely.

SHOULD
Offer a bearer-token guard for APIs.

401 without a valid token, 403 without the permission.

SHOULD
Support a custom sign-in domain.

Send the browser to CLAUTH_LOGIN_URL when set; keep validating against the issuer.

SHOULD
Sign out of Clauth too.

A logout route that ends the local session and Clauth's, then returns to an after-sign-out URL.

Config names

Use the same environment names in every language, so docs and deploys carry over.

NameMeaning
CLAUTH_ENABLEDMaster switch, default false
CLAUTH_ISSUERThe Clauth server, e.g. https://auth.example.com
CLAUTH_AUDIENCEThe app key
CLAUTH_CLIENT_ID / CLAUTH_CLIENT_SECRETFrom Register app
CLAUTH_REDIRECT_URIYour callback URL
CLAUTH_LOGIN_URLOptional custom sign-in domain

Suggested API

Match the shape of the Laravel kit, in your language's idiom:

Laravel kitPurpose
/auth/clauth/redirect, /callback, /logoutReady-made routes
clauth.can:expense.approveRoute guard
$user->clauthCan('expense.approve')Check in code
clauth.freshRefresh the session token
clauth.apiBearer-token guard
@clauthBarRender the bar

Node.js sketch

The official Node.js kit is in progress. Its intended shape, for anyone building for Express, Fastify, Hono or Next.js:

// Sketch — API may change before release
import { clauth } from 'clauth-node';

const auth = clauth({ issuer: process.env.CLAUTH_ISSUER, audience: 'xpenses' });

app.use(auth.routes());                         // /auth/clauth/*
app.post('/approve', auth.can('expense.approve'), handler);
app.get('/.well-known/clauth.json', auth.manifest(permissions));
app.use('/api', auth.bearer());                 // phone apps, SPAs

Test checklist

Run these against a local Clauth before you publish. They're the same checks the Laravel kit passes.

Publish & list it

  1. Name it clauth-<framework> and publish to your language's package registry.
  2. Include a README with the connect checklist and the config names above.
  3. Open a pull request adding it to the Kits page, with a link to your test results.

Questions while building? Start a discussion — happy to help.