DevelopAuth & access
@holtkeeper/auth
The contract every sign-in method implements, plus shared helpers for sessions.
AuthProvider
Section titled “AuthProvider”interface AuthProvider { readonly name: string authenticate(request: Request): Promise<Principal | undefined> handle?( request: Request, path: string, principal: Principal | undefined, ): Promise<Response | undefined> info(): AuthInfo start?(): Promise<string[]>}- The server asks the configured provider who each request comes from.
undefinedmeans anonymous; the API answers401where a principal is needed. handleserves the provider’s own endpoints under/auth/<name>/(login, callbacks, user admin). It uses plainRequest/Response, so providers do not depend on the server framework.info()tells the UI which login methods to show (password,passkey,oidclinks) and where to log out.start()runs once at server start and returns lines to log, e.g. a first-admin setup link.
Providers
Section titled “Providers”| Package | Who signs in |
|---|---|
@holtkeeper/auth-none |
Nobody — every request is root |
@holtkeeper/auth-header |
Users identified by a reverse proxy through headers, grants from proxy groups |
@holtkeeper/auth-password |
Root behind one password |
@holtkeeper/auth-users |
Real users: passkeys and OIDC, invites, recovery links, scoped grants |
Helpers
Section titled “Helpers”createSessionCodec(secret)— stateless HMAC-SHA256 signed tokens with expiry for session cookies. Payloads are readable by clients; never put secrets in them.readCookie,sessionCookie(HttpOnly, SameSite=Lax, Secure by default),clearCookie.safeEqual(a, b)— constant-time comparison of secrets.json(body, init)— JSON responses for provider endpoints.