oidc

package
v1.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package oidc implements schemaf's built-in identity providers on top of a generic OIDC ID-token verifier (discovery + JWKS via coreos/go-oidc).

Built-ins are activated purely by environment variables (see FromEnv); apps don't import this package.

Index

Constants

View Source
const MaxTokenAge = 5 * time.Minute

MaxTokenAge is how old (by iat) an ID token may be when posted to the login route. The server can't check the nonce, so this limits replay.

Variables

View Source
var Builtins = []Builtin{
	{
		Name:        "auth0",
		Title:       "Auth0",
		DomainEnv:   "PUBLIC_AUTH0_DOMAIN",
		ClientIDEnv: "PUBLIC_AUTH0_CLIENT_ID",
		Issuer:      func(domain string) string { return "https://" + domain + "/" },
	},
}

Builtins lists the built-in providers. Their names are reserved.

Functions

func FromEnv

func FromEnv(getenv func(string) string) ([]api.IdentityProvider, error)

FromEnv returns the built-in providers activated by the environment. For each built-in: neither variable set → off; both set → active; only one set → error.

func IsReserved

func IsReserved(name string) bool

IsReserved reports whether name belongs to a built-in provider.

Types

type Builtin

type Builtin struct {
	Name        string // reserved provider name, e.g. "auth0"
	Title       string // for messages, e.g. "Auth0"
	DomainEnv   string // e.g. "PUBLIC_AUTH0_DOMAIN"
	ClientIDEnv string // e.g. "PUBLIC_AUTH0_CLIENT_ID"
	Issuer      func(domain string) string
}

Builtin describes a built-in identity provider activated by two env vars. Both are PUBLIC_* variables: the frontend needs the same values and reads them via /api/config. Further built-ins (keycloak, google, ...) are just more entries.

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is an identity provider that accepts {"id_token": "<jwt>"} and verifies it against an OIDC issuer: signature via the issuer's JWKS, iss, aud (must contain the client ID), exp, and iat no older than MaxTokenAge.

func New

func New(name, issuer, clientID string) *Provider

New returns a provider named name for the given issuer URL and client ID. Discovery happens lazily on first login, so an unreachable issuer does not prevent the server from starting.

func (*Provider) Exchange

func (p *Provider) Exchange(ctx context.Context, r *http.Request) (api.Identity, error)

Exchange implements api.IdentityProvider.

func (*Provider) Name

func (p *Provider) Name() string

Name implements api.IdentityProvider.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL