alepha@docs:~/framework/docs/reference/primitives$
cat $auth.md | pretty1 min read
#$auth
#Import
typescript
1import { $auth } from "alepha/server/auth";
#Overview
Creates an authentication provider primitive for handling user login flows.
Supports multiple authentication strategies: credentials (username/password), OAuth2, and OIDC (OpenID Connect). Handles token management, user profile retrieval, and integration with both external identity providers (Auth0, Keycloak) and internal realms.
Authentication Types: Credentials, OAuth2 (Google, GitHub), OIDC, External providers
#Options
| Option | Type | Required | Description |
|---|---|---|---|
name |
string |
No | Name of the identity provider |
disabled |
boolean |
No | If true, auth provider will be skipped. |
#Examples
ts
1class AuthProviders { 2 // Internal credentials-based auth 3 credentials = $auth({ 4 realm: this.userRealm, 5 credentials: { 6 account: async ({ username, password }) => { 7 return await this.validateUser(username, password); 8 } 9 }10 });11 12 // External OIDC provider: no user table, the provider's tokens are the13 // session. The callback is served at `/oauth/callback`.14 keycloak = $auth({15 oidc: {16 issuer: "https://auth.example.com/realms/acme",17 clientId: "my-app",18 clientSecret: "secret",19 }20 });21 22 // Verifies the provider's tokens, from its discovery.23 keycloakIssuer = $issuer({ oidc: () => this.keycloak });24}