oidc

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package oidc provides OpenID Connect authentication orchestration.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAttemptBlocked  = errors.New("OIDC attempt blocked")
	ErrConflict        = errors.New("OIDC challenge conflict")
	ErrInactiveState   = errors.New("OIDC state is inactive")
	ErrInvalidConfig   = errors.New("invalid OIDC configuration")
	ErrInvalidIdentity = errors.New("invalid OIDC identity")
	ErrInvalidInput    = errors.New("invalid OIDC input")
	ErrInvalidRecord   = errors.New("invalid OIDC record")
	ErrInvalidState    = errors.New("invalid or expired OIDC state")
	ErrNotFound        = errors.New("OIDC record not found")
	ErrUnverifiedEmail = errors.New("OIDC email is not verified")
)

Functions

This section is empty.

Types

type Attempt

type Attempt struct {
	Operation    Operation
	ConnectionID string
	SourceKey    string
}

type AttemptGuard

type AttemptGuard interface {
	Check(ctx context.Context, attempt Attempt) error
}

type BeginInput

type BeginInput struct {
	ConnectionID string
	SourceKey    string
}

type Challenge

type Challenge struct {
	StateHash            StateHash
	ConnectionID         string
	Issuer               string
	ClientID             string
	RedirectURL          string
	Scopes               []string
	RequireVerifiedEmail bool
	Nonce                string
	CodeVerifier         string
	CreatedAt            time.Time
	ExpiresAt            time.Time
}

type CompleteInput

type CompleteInput struct {
	State     string
	Code      string
	SourceKey string
}

type Config

type Config struct {
	StateLifetime  time.Duration
	HTTPClient     *http.Client
	AttemptGuard   AttemptGuard
	SecurityEvents SecurityEventSink
	Now            func() time.Time
}

type Connection

type Connection struct {
	ID                   string
	Issuer               string
	ClientID             string
	ClientSecret         string
	RedirectURL          string
	Scopes               []string
	RequireVerifiedEmail bool
}

type ConnectionSource

type ConnectionSource interface {
	Find(ctx context.Context, connectionID string) (Connection, error)
}

type EventType

type EventType string
const (
	EventAuthenticationFailed    EventType = "oidc_authentication_failed"
	EventAuthenticationSucceeded EventType = "oidc_authentication_succeeded"
)

type Identity

type Identity struct {
	ConnectionID    string
	Issuer          string
	ProviderSubject string
	Email           string
	EmailVerified   bool
	Name            string
}

type Manager

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

func NewManager

func NewManager(store Store, connections ConnectionSource, config Config) (*Manager, error)

func (*Manager) Begin

func (manager *Manager) Begin(ctx context.Context, input BeginInput) (Started, error)

func (*Manager) Complete

func (manager *Manager) Complete(ctx context.Context, input CompleteInput) (Identity, error)

type Operation

type Operation string
const (
	OperationBegin    Operation = "begin"
	OperationComplete Operation = "complete"
)

type SecurityEvent

type SecurityEvent struct {
	Type            EventType
	ConnectionID    string
	ProviderSubject string
	SourceKey       string
	OccurredAt      time.Time
}

type SecurityEventSink

type SecurityEventSink interface {
	Record(ctx context.Context, event SecurityEvent)
}

type Started

type Started struct {
	AuthorizationURL string
	State            string
	ExpiresAt        time.Time
}

type StateHash

type StateHash token.Hash

type Store

type Store interface {
	CreateChallenge(ctx context.Context, challenge Challenge) error
	ConsumeChallenge(ctx context.Context, stateHash StateHash, consumedAt time.Time) (Challenge, error)
}

Store creates and consumes each state in one operation.

Jump to

Keyboard shortcuts

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