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

oidc

package
v0.38.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2026 License: Apache-2.0, Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package oidc performs OIDC/OAuth2 authentication and returns an ID token. It is a plain library: callers own how the token state and user-facing progress are surfaced (the broker streams progress to ssh sessions; other callers may just discard it).

Index

Constants

This section is empty.

Variables

View Source
var ErrDeviceAuthorizationUnsupported = errors.New("OIDC issuer does not advertise device authorization")

ErrDeviceAuthorizationUnsupported means the issuer did not advertise the RFC 8628 endpoint required for device login.

View Source
var Scopes = []string{"openid", "profile", "email"}

Scopes is the fixed set requested during browser authentication. Policy maps a verified token to inventory using its configured identity mode.

Functions

func Authenticate added in v0.18.0

func Authenticate(ctx context.Context, cfg Config, prev *oauth2.Token, out io.Writer) (idToken string, next *oauth2.Token, err error)

Authenticate returns a fresh ID token. prev carries refresh state from the previous call (nil on first use); the returned token is the next state. User-facing progress ("visit this URL…") is written to out.

Types

type Config

type Config struct {
	IssuerURL    string
	ClientID     string
	ClientSecret string // Optional for PKCE.
	TLSConfig    tlsconfig.Config
	LoginMethod  LoginMethod
}

Config holds OIDC authentication configuration.

type LoginMethod added in v0.33.0

type LoginMethod uint8

LoginMethod selects the interactive operation used when neither a valid token nor a working refresh token is available. Its zero value preserves the browser-based behavior used before device authorization was added.

const (
	LoginBrowser LoginMethod = iota
	LoginDevice
)

type Verifier added in v0.27.0

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

Verifier checks ID tokens independently of inventory identity mapping. It can be shared by concurrent callers and caches the provider's signing keys.

func NewVerifier added in v0.27.0

func NewVerifier(ctx context.Context, config Config) (*Verifier, error)

NewVerifier discovers the configured issuer and prepares token verification.

func (*Verifier) Verify added in v0.27.0

func (v *Verifier) Verify(ctx context.Context, token string) (*coreoidc.IDToken, error)

Verify checks signature, issuer, audience, expiry, and a nonempty subject. Callers may inspect claims only after this succeeds.

Jump to

Keyboard shortcuts

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