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.
Code + PKCE + nonce
Tokens against JWKS
Permissions per org
Manifest + Clauth bar
The contract
Must items are required to be listed as a Clauth kit. Should items are strongly recommended.
Clauth rejects sign-ins without PKCE and a nonce.
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.
sub, never by email alone.Email may be used once to link an existing user; after that, sub is the identity.
Read orgs.<org>.permissions; offer a "can" helper and a route guard that returns 403.
Apply new roles on refresh; if refresh fails because the person was disabled, sign them out.
/.well-known/clauth.jsonBuilt from the app's own config: permissions and roles.
A one-line include for templates, backed by /bar/v1 and /api/v1/bar fetched server-side.
Do nothing to sign-in until CLAUTH_ENABLED=true, so apps can install it safely.
401 without a valid token, 403 without the permission.
Send the browser to CLAUTH_LOGIN_URL when set; keep validating against the issuer.
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.
| Name | Meaning |
|---|---|
CLAUTH_ENABLED | Master switch, default false |
CLAUTH_ISSUER | The Clauth server, e.g. https://auth.example.com |
CLAUTH_AUDIENCE | The app key |
CLAUTH_CLIENT_ID / CLAUTH_CLIENT_SECRET | From Register app |
CLAUTH_REDIRECT_URI | Your callback URL |
CLAUTH_LOGIN_URL | Optional custom sign-in domain |
Suggested API
Match the shape of the Laravel kit, in your language's idiom:
| Laravel kit | Purpose |
|---|---|
/auth/clauth/redirect, /callback, /logout | Ready-made routes |
clauth.can:expense.approve | Route guard |
$user->clauthCan('expense.approve') | Check in code |
clauth.fresh | Refresh the session token |
clauth.api | Bearer-token guard |
@clauthBar | Render 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
- Name it
clauth-<framework>and publish to your language's package registry. - Include a README with the connect checklist and the config names above.
- 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.