social

package
v0.7.17-dev.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package social implements sign-in for individual accounts through the deployment's OpenID provider (linked via identities; no password), on the relying party in internal/auth/oidc. It admits anyone with an account at the provider, grants an individual session and is configured server-wide.

Index

Constants

View Source
const (
	// ProviderAuthentik is the deployment's generic sign-in provider under
	// the id authentik, where its accounts are linked under that id: the
	// same provider as ProviderOIDC, with no defaults.
	ProviderAuthentik = "authentik"
	// ProviderOIDC is the deployment's generic sign-in provider: any OpenID
	// Connect issuer the operator points it at, with no defaults.
	ProviderOIDC = "oidc"
)

Provider ids. Closed set: an unknown id is a 404, never a guess.

Variables

This section is empty.

Functions

func Providers

func Providers() []string

Providers lists the supported provider ids, in the order the sign-in page offers them. The API layer validates provider names against its generated enum, so this is a listing for tooling and tests, not a gate.

func Startable

func Startable(name string, cfg Config) bool

Startable reports whether a provider's settings are enough for New to build it: a client id, a secret and an issuer. It needs no network, so it can answer for a provider whose issuer is down; New can still fail then.

Types

type Config

type Config struct {
	ClientID     string
	ClientSecret string
	// Issuer is the OpenID provider's issuer; its discovery document names
	// every endpoint.
	Issuer string
	Scopes []string
	// HTTPClient is used for discovery, token exchange, and API calls.
	HTTPClient *http.Client
}

Config configures the provider.

type Identity

type Identity struct {
	// Provider is the provider id ("oidc", "authentik").
	Provider string
	// Subject is the provider's stable id for this account, NOT namespaced.
	Subject string
	// NamespacedSubject is what goes in identities.subject: "<provider>:<sub>".
	// Namespacing keeps one provider's subject 42 apart from another's in a
	// single-column, provider-agnostic identity table.
	NamespacedSubject string
	Email             string
	EmailVerified     bool
	DisplayName       string
	// AMR/ACR carry the ID token's authentication-method claims. See
	// oidc.Claims.
	AMR []string
	ACR string
	// Groups is the ID token's `groups` claim (directory group names).
	Groups []string
	// Username is the ID token's `preferred_username`: the name chosen at the
	// IdP, which seeds a new account's handle. Never used to find an account.
	Username string
	// AuthTime is the ID token's `auth_time`: when the person last actually
	// authenticated at the IdP (zero when absent). A remembered browser is
	// minted only from a fresh one.
	AuthTime time.Time
	// Claims is every claim of the ID token, for a reader of an IdP's own
	// claims: an extension reads them through the sign-in hook.
	Claims map[string]any
}

Identity is what a completed sign-in asserts about the caller.

func (*Identity) MFAAsserted

func (id *Identity) MFAAsserted() bool

MFAAsserted reports whether AMR names a second factor, by the relying party's rule (oidcrp.AMRNamesSecondFactor).

type Provider

type Provider interface {
	// Name is the provider id.
	Name() string
	// UsesPKCE reports whether Exchange expects a PKCE verifier.
	UsesPKCE() bool
	// AuthURL builds the provider's authorization URL.
	AuthURL(state, nonce, verifier string) string
	// Exchange completes the flow and returns the asserted identity.
	Exchange(ctx context.Context, code, verifier, nonce string) (*Identity, error)
}

Provider is the configured sign-in provider.

func New

func New(ctx context.Context, name string, cfg Config, redirectURL string) (Provider, error)

New builds the provider named by name.

Jump to

Keyboard shortcuts

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