Auth Plugins
Configure password credentials, OAuth providers, magic links, OTP, WebAuthn passkeys, and multi-tenant organizations.
Auth Plugins
Himayah is extended through composable plugins. Each plugin registers its own HTTP endpoints, validation logic, and database interactions. You only pay for what you use.
Password Plugin
Package: @himayah/plugin-password
Standard email + password authentication using PBKDF2-SHA256 with 100,000 iterations. You provide the storage callbacks — Himayah handles the hashing.
Installation
Configuration
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/auth/password/sign-up | Create a new user with email + password |
POST | /api/auth/password/sign-in | Authenticate user and create a session |
POST | /api/auth/password/change-password | Update password (requires active session) |
Usage
Passwords are never stored in plaintext. The hash stored in your database is the PBKDF2-SHA256 output (100,000 rounds), and comparisons are always done in constant time.
OAuth Plugin
Package: @himayah/plugin-oauth
OAuth 2.0 and OIDC login with PKCE, state verification, and automatic user upsert. Comes with built-in configs for GitHub and Google.
Installation
Configuration
Endpoints
| Method | Path | Description |
|---|---|---|
GET | /api/auth/oauth/authorize/:providerId | Redirect to provider authorization URL |
GET | /api/auth/oauth/callback/:providerId | Handle the OAuth callback and create session |
Usage
How It Works
- User clicks "Sign in with GitHub"
- Himayah generates a cryptographically random state token and PKCE code verifier, stores them in short-lived cookies
- User is redirected to GitHub with the state + code challenge
- GitHub calls back to
/api/auth/oauth/callback/github - Himayah verifies the state (constant-time) and PKCE code before exchanging for tokens
- User's profile is fetched, account is linked or created, and a session cookie is set
OAuth state and PKCE verifier comparisons are always performed using timingSafeEqual to prevent timing-based forgery attacks.
Magic Link Plugin
Package: @himayah/plugin-magic-link
Passwordless authentication via secure one-click email links. Tokens are single-use and expire after a configurable window.
Installation
Configuration
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/auth/magic-link/send | Generate and email a magic link |
GET | /api/auth/magic-link/verify | Verify token and create session |
Usage
By default, magic links use an in-memory rate limiter. In production with multiple server instances, configure a Redis or database rate limiter to share state across nodes.
OTP Plugin
Package: @himayah/plugin-otp
Time-limited numeric one-time passcodes sent via SMS or email.
Installation
Configuration
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/auth/otp/send | Generate and send an OTP |
POST | /api/auth/otp/verify | Verify OTP and create session |
Usage
Passkey Plugin (WebAuthn)
Package: @himayah/plugin-passkey
Biometric authentication using the WebAuthn standard — fingerprint, Face ID, Windows Hello, hardware security keys.
Installation
Configuration
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/auth/passkey/register/options | Get registration challenge |
POST | /api/auth/passkey/register/verify | Verify and store new passkey credential |
POST | /api/auth/passkey/authenticate/options | Get authentication challenge |
POST | /api/auth/passkey/authenticate/verify | Verify passkey and create session |
Usage
The @simplewebauthn/browser package handles the browser-side WebAuthn ceremony. Install it with pnpm add @simplewebauthn/browser.
Organization Plugin
Package: @himayah/plugin-organization
Multi-tenant organization support with membership management, role-based access, and email invitations.
Installation
Schema
Add these tables to your schema before enabling the plugin:
Configuration
Register the adapter with organization tables:
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /api/auth/org/create | Create a new organization |
POST | /api/auth/org/invite | Invite a user to an organization |
POST | /api/auth/org/accept-invite | Accept a pending invitation |
POST | /api/auth/org/remove-member | Remove a member from an organization |
POST | /api/auth/org/set-active | Set the user's active organization |
GET | /api/auth/org/list | List organizations the user belongs to |
