alepha@docs:~/docs/reference/primitives$
cat $auth.md1 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 provider13 keycloak = $auth({14 oidc: {15 issuer: "https://auth.example.com",16 clientId: "my-app",17 clientSecret: "secret",18 redirectUri: "/auth/callback"19 }20 });21}