Help us shape the future of Go! Take the 2026 Go Developer Survey

oidc

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package oidc is the generic OpenID Connect identity adapter (R-043).

One adapter for every provider that speaks OpenID Connect — Okta, Microsoft Entra ID, Google Workspace, Keycloak, Authentik — configured by its issuer. What differs between them is which claim carries what, and that is configuration with presets, not a kind per vendor.

Authentication only (R-044). The adapter turns a callback into a Subject and nothing else: it does not know what an account is, what a group may do, or whether this person has signed in before. Core decides all of that.

Index

Constants

View Source
const DefaultSessionLifetime = 12 * time.Hour

DefaultSessionLifetime is how long a session lasts when the configuration does not say. It is also the revocation window when no SCIM client pushes changes (R-050), which is why it is not longer.

View Source
const Kind = "oidc"

Kind is the adapter's kind string.

Variables

This section is empty.

Functions

func Info

func Info() api.KindInfo

Info describes this kind of adapter for the console and CLI forms.

The presets are where each provider's quirks live, stated once: Entra's sub claim differs per application, so it matches on oid; Google sends no groups and admits any Google account unless the domain is fixed. A preset is only settings — choosing one is the same as typing them.

Types

type Adapter

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

Adapter is the OIDC identity adapter.

func New

func New() *Adapter

New builds an unconfigured adapter.

func (*Adapter) Authenticate

func (a *Adapter) Authenticate(ctx context.Context, c api.Credential) (api.Subject, error)

Authenticate exchanges the code and verifies the ID token: signature, issuer, audience, expiry and nonce. The state was matched by core before this is called — that is how core found the flow.

func (*Adapter) Begin

func (a *Adapter) Begin(ctx context.Context, req api.BeginRequest) (*api.Redirect, error)

Begin builds the authorization request: code flow, PKCE S256, a nonce, and core's state.

func (*Adapter) Category

func (a *Adapter) Category() api.Category

func (*Adapter) Configure

func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error

Configure validates settings without contacting the provider, so a configuration can be saved while the provider is unreachable. HealthCheck and the first sign-in find out whether it answers.

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(ctx context.Context) error

HealthCheck fetches the provider's discovery document.

func (*Adapter) Kind

func (a *Adapter) Kind() string

func (*Adapter) ServiceMetadata

func (a *Adapter) ServiceMetadata(context.Context, api.Endpoints) (*api.Metadata, error)

ServiceMetadata returns nil: an OpenID Connect provider is given a redirect URI, which core shows, and nothing else.

func (*Adapter) SessionPolicy

func (a *Adapter) SessionPolicy() api.SessionPolicy

SessionPolicy declares this adapter's session behavior (R-047).

Expiry-only on its own: Pando does not keep the provider's tokens, so there is nothing to refresh and nothing that would learn of a revocation. When the installation turns SCIM on for this provider, core reports push instead, because a deprovisioning then ends sessions immediately (R-048, R-050).

func (*Adapter) SupportsPush

func (a *Adapter) SupportsPush() bool

SupportsPush is true: every provider this adapter targets can provision through SCIM, which core accepts on its behalf.

func (*Adapter) WithGraphURL added in v0.10.0

func (a *Adapter) WithGraphURL(u string) *Adapter

WithGraphURL replaces the Microsoft Graph address used to read the groups an Entra ID token left out, for tests.

func (*Adapter) WithHTTPClient

func (a *Adapter) WithHTTPClient(c *http.Client) *Adapter

WithHTTPClient replaces the client used to reach the provider, for tests.

type Config

type Config struct {
	Issuer   string `json:"issuer"`
	ClientID string `json:"client_id"`

	// Scopes, space- or comma-separated. openid is always requested.
	Scopes string `json:"scopes,omitempty"`

	// Which claim carries what. Empty is the standard claim.
	SubjectClaim  string `json:"subject_claim,omitempty"`
	UsernameClaim string `json:"username_claim,omitempty"`
	EmailClaim    string `json:"email_claim,omitempty"`
	NameClaim     string `json:"name_claim,omitempty"`
	GroupsClaim   string `json:"groups_claim,omitempty"`

	// HostedDomain restricts sign-in to one Google Workspace domain, by the
	// hd claim Google sets. Without it, a Google provider lets in anyone with
	// a Google account.
	HostedDomain string `json:"hosted_domain,omitempty"`

	// DisableUserinfo skips the userinfo endpoint. By default its claims fill
	// in what the ID token left out: several providers put groups or email
	// only there.
	DisableUserinfo bool `json:"disable_userinfo,omitempty"`

	// Prompt is sent as the prompt parameter: "login" to always ask for
	// credentials, "select_account" to always offer a choice.
	Prompt string `json:"prompt,omitempty"`

	SessionMaxLifetime string `json:"session_max_lifetime,omitempty"`

	Credentials struct {
		ClientSecret string `json:"client_secret,omitempty"`
	} `json:"credentials,omitempty"`
}

Config is what an administrator sets.

Jump to

Keyboard shortcuts

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