Versions in this module Expand all Collapse all v0 v0.2.0 Nov 22, 2026 Changes in this version + type MemoryStore struct + func NewMemoryStore() *MemoryStore + func (s *MemoryStore) Add(_ context.Context, key, value string, ttl time.Duration) (bool, error) + func (s *MemoryStore) Delete(_ context.Context, key string) error + func (s *MemoryStore) Get(_ context.Context, key string) (string, bool, error) + func (s *MemoryStore) Set(_ context.Context, key, value string, ttl time.Duration) error + type MultiGetter interface + GetMany func(ctx context.Context, keys []string) (values []string, ok []bool, err error) + type Store interface + Add func(ctx context.Context, key, value string, ttl time.Duration) (bool, error) + Delete func(ctx context.Context, key string) error + Get func(ctx context.Context, key string) (value string, ok bool, err error) + Set func(ctx context.Context, key, value string, ttl time.Duration) error type VerifierConfig + Store Store v0.1.0 Nov 22, 2026 Changes in this version + const DefaultTolerance + const DeliveryIDHeader + const EventIDHeader + const EventTypeHeader + const OpaquePrefix + const RequestIDHeader + const SignatureHeader + const Version + var ErrAccessDenied = &Error + var ErrAuthorizationPending = &Error + var ErrExpiredToken = &Error + var ErrInsecureIssuer = &Error + var ErrInsufficientScope = &Error + var ErrInvalidCredentials = &Error + var ErrInvalidGrant = &Error + var ErrInvalidIDToken = &Error + var ErrInvalidIssuer = &Error + var ErrInvalidOptions = &Error + var ErrInvalidSignature = &Error + var ErrInvalidState = &Error + var ErrInvalidToken = &Error + var ErrLoginRequired = &Error + var ErrNotFound = &Error + var ErrSlowDown = &Error + var ErrUserBlocked = &Error + func AdapterHandler(cfg AdapterConfig) http.Handler + func CodeChallenge(verifier string) string + func DefaultScopes() []string + func Env(name string) string + func NormalizeIssuer(issuer string, allowInsecure bool) (string, error) + func RequireAuth(v AccessTokenVerifier, scopes ...string) func(http.Handler) http.Handler + func SafeReturnPath(path string) string + func SignPayload(secret, method, path string, body []byte) string + func SignPayloadAt(secret, method, path string, body []byte, at time.Time) string + func VerifySignature(secrets []string, header, method, path string, body []byte, ...) error + func WebhookHandler(cfg WebhookConfig) http.Handler + func WithClaims(ctx context.Context, claims Claims) context.Context + func WriteAuthError(w http.ResponseWriter, err error, scopes ...string) + type AccessTokenVerifier interface + Verify func(ctx context.Context, token string, scopes ...string) (Claims, error) + type Adapter interface + Authenticate func(ctx context.Context, id Identifier, password string) (*AdapterUser, error) + FindUser func(ctx context.Context, query UserQuery) (*AdapterUser, error) + OnEvent func(ctx context.Context, event *AdapterEvent) error + type AdapterConfig struct + Adapter Adapter + OnError func(r *http.Request, err error) + Secret string + Secrets []string + Tolerance time.Duration + type AdapterEvent struct + CreatedAt time.Time + Data map[string]any + EventType string + ID string + func (e *AdapterEvent) UserID() string + type AdapterUser struct + Birthdate string + Blocked bool + Email string + EmailVerified bool + FamilyName string + GivenName string + ID string + Locale string + Metadata map[string]any + Name string + PhoneNumber string + PhoneNumberVerified bool + Picture string + Username string + Zoneinfo string + type AnswerCache interface + Clear func(ctx context.Context) + Evict func(ctx context.Context, claim, value string) int + Get func(ctx context.Context, key string) (CachedAnswer, bool) + Set func(ctx context.Context, key string, answer CachedAnswer) + type AuthMiddleware struct + OnError func(w http.ResponseWriter, r *http.Request, err error) + Optional bool + Scopes []string + Verifier AccessTokenVerifier + func (m AuthMiddleware) Wrap(next http.Handler) http.Handler + type CachedAnswer struct + Claims Claims + Until time.Time + type Claims map[string]any + func ClaimsFrom(ctx context.Context) Claims + func (c Claims) Audience() []string + func (c Claims) Bool(name string) bool + func (c Claims) ClientID() string + func (c Claims) ExpiresAt() time.Time + func (c Claims) HasScope(scope string) bool + func (c Claims) Int(name string) (int64, bool) + func (c Claims) IsMachine() bool + func (c Claims) Issuer() string + func (c Claims) Scopes() []string + func (c Claims) SessionID() string + func (c Claims) String(name string) string + func (c Claims) Strings(name string) []string + func (c Claims) Subject() string + func (c Claims) Time(name string) time.Time + func (c Claims) TokenID() string + type ClientCredentials struct + func NewClientCredentials(cfg ClientCredentialsConfig) (*ClientCredentials, error) + func (c *ClientCredentials) HTTPClient(base *http.Client) *http.Client + func (c *ClientCredentials) Invalidate() + func (c *ClientCredentials) Token(ctx context.Context) (string, error) + type ClientCredentialsConfig struct + AllowInsecureIssuer bool + Audience string + ClientID string + ClientSecret string + HTTPClient *http.Client + Issuer string + Scopes []string + func ClientCredentialsConfigFromEnv() ClientCredentialsConfig + type ClientCredentialsOptions struct + Audience string + Scope string + type DeviceAuth struct + func NewDeviceAuth(cfg DeviceAuthConfig) (*DeviceAuth, error) + func (d *DeviceAuth) EnsureFresh(ctx context.Context, tokens *TokenSet, leeway time.Duration) (*TokenSet, error) + func (d *DeviceAuth) Poll(ctx context.Context, code *DeviceCode) (*TokenSet, error) + func (d *DeviceAuth) Refresh(ctx context.Context, refreshToken string) (*TokenSet, error) + func (d *DeviceAuth) Revoke(ctx context.Context, token, hint string) error + func (d *DeviceAuth) Start(ctx context.Context) (*DeviceCode, error) + func (d *DeviceAuth) UserInfo(ctx context.Context, accessToken string) (Claims, error) + func (d *DeviceAuth) Wait(ctx context.Context, code *DeviceCode) (*TokenSet, error) + type DeviceAuthConfig struct + AllowInsecureIssuer bool + Audience string + ClientID string + ClientSecret string + HTTPClient *http.Client + Issuer string + Leeway time.Duration + Scopes []string + type DeviceCode struct + DeviceCode string + ExpiresAt time.Time + ExpiresIn int + Interval int + UserCode string + VerificationURI string + VerificationURIComplete string + type Discovery struct + AuthorizationEndpoint string + AuthorizationResponseIssParameterSupported bool + DeviceAuthorizationEndpoint string + EndSessionEndpoint string + IDTokenSigningAlgValuesSupported []string + IntrospectionEndpoint string + Issuer string + JWKSURI string + RevocationEndpoint string + ScopesSupported []string + TokenEndpoint string + UserinfoEndpoint string + type Error struct + Code string + Description string + Details any + Status int + func (e *Error) Error() string + func (e *Error) Is(target error) bool + func (e *Error) Unwrap() error + type EventDeduplicator struct + LockTTL time.Duration + Prefix string + Store EventStore + TTL time.Duration + func (d *EventDeduplicator) Process(ctx context.Context, eventID string, handler func(context.Context) error) (ProcessStatus, error) + type EventStore interface + Add func(ctx context.Context, key, value string, ttl time.Duration) (bool, error) + Delete func(ctx context.Context, key string) error + Get func(ctx context.Context, key string) (value string, ok bool, err error) + Set func(ctx context.Context, key, value string, ttl time.Duration) error + type Identifier struct + Type string + Value string + type ImportIdentity struct + Connection string + Subject string + type ImportOptions struct + OnConflict string + Source string + type ImportResult struct + Details any + Error string + ID string + Index int + OK bool + Reason string + Status string + type ImportUser struct + CreatedAt *time.Time + ID string + Identities []ImportIdentity + LastLoginAt *time.Time + type ListUsersOptions struct + Cursor string + Limit int + Query string + type Login struct + Pending *PendingLogin + URL string + type LoginLink struct + ExpiresAt time.Time + URL string + type LoginLinkOptions struct + ReturnTo string + TTL time.Duration + type LoginOptions struct + Locale string + LoginHint string + Params map[string]string + Prompt string + RedirectURI string + ReturnTo string + Screen string + type LogoutOptions struct + IDTokenHint string + PostLogoutRedirectURI string + State string + type MFAState struct + Enabled bool + EnabledAt *time.Time + RecoveryCodesLeft *int + type ManagedIdentity struct + Connection string + CreatedAt time.Time + Profile map[string]any + Subject string + type ManagedSession struct + AMR []string + AuthTime time.Time + CreatedAt time.Time + ExpiresAt time.Time + IP string + LastSeenAt time.Time + SID string + UserAgent string + UserID string + type ManagedUser struct + Birthdate string + Blocked bool + CreatedAt time.Time + Email string + EmailVerified bool + FamilyName string + Gender string + GivenName string + ID string + LastLoginAt *time.Time + Locale string + LoginCount int + Metadata map[string]any + MiddleName string + Name string + Nickname string + PhoneNumber string + PhoneNumberVerified bool + Picture string + PreferredUsername string + UpdatedAt time.Time + Username string + Website string + Zoneinfo string + type ManagementClient struct + func NewManagementClient(cfg ManagementConfig) (*ManagementClient, error) + func (m *ManagementClient) BlockUser(ctx context.Context, id string) (*ManagedUser, error) + func (m *ManagementClient) CreateLoginLink(ctx context.Context, id string, opts LoginLinkOptions) (*LoginLink, error) + func (m *ManagementClient) CreateUser(ctx context.Context, user NewUser) (*ManagedUser, error) + func (m *ManagementClient) DeleteUser(ctx context.Context, id string) error + func (m *ManagementClient) FindUser(ctx context.Context, field, value string) (*ManagedUser, error) + func (m *ManagementClient) FindUserByEmail(ctx context.Context, email string) (*ManagedUser, error) + func (m *ManagementClient) GetUser(ctx context.Context, id string) (*UserDetail, error) + func (m *ManagementClient) ImportUsers(ctx context.Context, users []ImportUser, opts ImportOptions) ([]ImportResult, error) + func (m *ManagementClient) ListUserSessions(ctx context.Context, id string) ([]ManagedSession, error) + func (m *ManagementClient) ListUsers(ctx context.Context, opts ListUsersOptions) (*UserList, error) + func (m *ManagementClient) RevokeSession(ctx context.Context, sid string) error + func (m *ManagementClient) RevokeUserSessions(ctx context.Context, id string) (int, error) + func (m *ManagementClient) UnblockUser(ctx context.Context, id string) (*ManagedUser, error) + func (m *ManagementClient) UpdateUser(ctx context.Context, id string, changes UserChanges) (*ManagedUser, error) + type ManagementConfig struct + AllowInsecureIssuer bool + ClientID string + ClientSecret string + HTTPClient *http.Client + Issuer string + func ManagementConfigFromEnv() ManagementConfig + type MemoryAnswerCache struct + func NewMemoryAnswerCache(size int) *MemoryAnswerCache + func (c *MemoryAnswerCache) Clear(context.Context) + func (c *MemoryAnswerCache) Evict(_ context.Context, claim, value string) int + func (c *MemoryAnswerCache) Get(_ context.Context, key string) (CachedAnswer, bool) + func (c *MemoryAnswerCache) Len() int + func (c *MemoryAnswerCache) Set(_ context.Context, key string, answer CachedAnswer) + type MemoryEventStore struct + func NewMemoryEventStore() *MemoryEventStore + func (s *MemoryEventStore) Add(_ context.Context, key, value string, ttl time.Duration) (bool, error) + func (s *MemoryEventStore) Delete(_ context.Context, key string) error + func (s *MemoryEventStore) Get(_ context.Context, key string) (string, bool, error) + func (s *MemoryEventStore) Set(_ context.Context, key, value string, ttl time.Duration) error + type Mode string + const ModeHybrid + const ModeIntrospect + const ModeLocal + type NewUser struct + Birthdate string + Blocked bool + Email string + EmailVerified bool + FamilyName string + GivenName string + Locale string + Metadata map[string]any + Name string + Password string + PasswordHash string + PhoneNumber string + PhoneNumberVerified bool + Picture string + Username string + Zoneinfo string + type PendingLogin struct + CreatedAt int64 + Nonce string + RedirectURI string + ReturnTo string + State string + Verifier string + type ProcessStatus string + const Duplicate + const InProgress + const Processed + func ProcessEventOnce(ctx context.Context, store EventStore, eventID string, ...) (ProcessStatus, error) + type TokenSet struct + AccessToken string + Claims Claims + ExpiresAt time.Time + IDToken string + RefreshToken string + ReturnTo string + Scope string + TokenType string + func (t *TokenSet) Expired(leeway time.Duration) bool + type User struct + Claims Claims + Email string + EmailVerified bool + FamilyName string + GivenName string + Locale string + Name string + PhoneNumber string + Picture string + Subject string + func UserFrom(ctx context.Context) *User + type UserChanges map[string]any + type UserDetail struct + HasPassword bool + Identities []ManagedIdentity + MFA MFAState + Sessions []ManagedSession + User ManagedUser + type UserList struct + NextCursor string + Total int + Users []ManagedUser + type UserQuery struct + ID string + Identifier *Identifier + type Verifier struct + func NewVerifier(cfg VerifierConfig) (*Verifier, error) + func (v *Verifier) Clear(ctx context.Context) + func (v *Verifier) HandleEvent(ctx context.Context, event *WebhookEvent) int + func (v *Verifier) Issuer() string + func (v *Verifier) Mode() Mode + func (v *Verifier) Verify(ctx context.Context, token string, scopes ...string) (Claims, error) + func (v *Verifier) VerifyIDToken(ctx context.Context, idToken, clientID, nonce string) (Claims, error) + type VerifierConfig struct + AllowInsecureIssuer bool + Audience string + Audiences []string + Cache AnswerCache + CacheSize int + CacheTTL time.Duration + ClientID string + ClientSecret string + HTTPClient *http.Client + Issuer string + Leeway time.Duration + Mode Mode + Secret string + func VerifierConfigFromEnv() VerifierConfig + type WebApp struct + func NewWebApp(cfg WebAppConfig) (*WebApp, error) + func (a *WebApp) AccessToken(w http.ResponseWriter, r *http.Request) (string, error) + func (a *WebApp) Auth() *WebAppAuth + func (a *WebApp) Callback(w http.ResponseWriter, r *http.Request) + func (a *WebApp) Login(w http.ResponseWriter, r *http.Request) + func (a *WebApp) Logout(w http.ResponseWriter, r *http.Request) + func (a *WebApp) Middleware(next http.Handler) http.Handler + func (a *WebApp) RequireUser(next http.Handler) http.Handler + func (a *WebApp) ServeHTTP(w http.ResponseWriter, r *http.Request) + func (a *WebApp) Signup(w http.ResponseWriter, r *http.Request) + func (a *WebApp) User(r *http.Request) *User + type WebAppAuth struct + func NewWebAppAuth(cfg WebAppAuthConfig) (*WebAppAuth, error) + func (a *WebAppAuth) ClientCredentials(ctx context.Context, opts ClientCredentialsOptions) (*TokenSet, error) + func (a *WebAppAuth) ClientID() string + func (a *WebAppAuth) CreateLogin(ctx context.Context, opts LoginOptions) (*Login, error) + func (a *WebAppAuth) Discovery(ctx context.Context) (*Discovery, error) + func (a *WebAppAuth) EnsureFresh(ctx context.Context, tokens *TokenSet, leeway time.Duration) (*TokenSet, error) + func (a *WebAppAuth) HandleCallback(ctx context.Context, query url.Values, pending *PendingLogin) (*TokenSet, error) + func (a *WebAppAuth) Issuer() string + func (a *WebAppAuth) LogoutURL(ctx context.Context, opts LogoutOptions) (string, error) + func (a *WebAppAuth) Refresh(ctx context.Context, refreshToken string) (*TokenSet, error) + func (a *WebAppAuth) Revoke(ctx context.Context, token, hint string) error + func (a *WebAppAuth) UserInfo(ctx context.Context, accessToken string) (Claims, error) + func (a *WebAppAuth) VerifyIDToken(ctx context.Context, idToken, nonce string) (Claims, error) + type WebAppAuthConfig struct + AllowInsecureIssuer bool + Audience string + ClientID string + ClientSecret string + HTTPClient *http.Client + Issuer string + Leeway time.Duration + RedirectURI string + Scopes []string + func WebAppAuthConfigFromEnv() WebAppAuthConfig + type WebAppConfig struct + AfterSignInPath string + AfterSignOutPath string + AllowInsecureIssuer bool + Audience string + BasePath string + BaseURL string + ClientID string + ClientSecret string + CookieName string + HTTPClient *http.Client + Issuer string + OnError func(w http.ResponseWriter, r *http.Request, err error) + RefreshLeeway time.Duration + Scopes []string + Secret string + Secrets []string + SessionMaxAge time.Duration + func WebAppConfigFromEnv() WebAppConfig + type WebhookConfig struct + Handle func(ctx context.Context, event *WebhookEvent) error + OnError func(r *http.Request, err error) + Path string + Secret string + Secrets []string + Store EventStore + TTL time.Duration + Tolerance time.Duration + Verifier *Verifier + type WebhookEvent struct + CreatedAt time.Time + Data map[string]any + Environment string + EventType string + ID string + Tenant string + func VerifyWebhook(secrets []string, body []byte, signature, path string) (*WebhookEvent, error) + func VerifyWebhookRequest(r *http.Request, secrets ...string) (*WebhookEvent, error) + func (e *WebhookEvent) User() (*ManagedUser, error) + func (e *WebhookEvent) UserID() string