saml

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: 20 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 saml provides SAML Web SSO orchestration for service providers.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAttemptBlocked  = errors.New("SAML attempt blocked")
	ErrConflict        = errors.New("SAML request conflict")
	ErrInactiveRequest = errors.New("SAML request is inactive")
	ErrInvalidConfig   = errors.New("invalid SAML configuration")
	ErrInvalidIdentity = errors.New("invalid SAML identity")
	ErrInvalidInput    = errors.New("invalid SAML input")
	ErrInvalidRecord   = errors.New("invalid SAML record")
	ErrInvalidResponse = errors.New("invalid SAML response")
	ErrInvalidState    = errors.New("invalid or expired SAML state")
	ErrNotFound        = errors.New("SAML record not found")
)

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 CompleteInput

type CompleteInput struct {
	State        string
	SAMLResponse string
	SourceKey    string
}

type Config

type Config struct {
	RequestLifetime time.Duration
	AttemptGuard    AttemptGuard
	SecurityEvents  SecurityEventSink
	Now             func() time.Time
}

type Connection

type Connection struct {
	ID               string
	EntityID         string
	MetadataURL      string
	ACSURL           string
	IDPMetadata      []byte
	PrivateKey       crypto.Signer
	Certificate      *x509.Certificate
	SubjectAttribute string
	EmailAttribute   string
	NameAttribute    string
	RequireEmail     bool
	ForceAuthn       bool
}

type ConnectionSource

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

type EventType

type EventType string
const (
	EventAuthenticationFailed    EventType = "saml_authentication_failed"
	EventAuthenticationSucceeded EventType = "saml_authentication_succeeded"
)

type Identity

type Identity struct {
	ConnectionID    string
	Issuer          string
	ProviderSubject string
	SubjectFormat   string
	Email           string
	Name            string
	SessionIndex    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)

func (*Manager) Metadata

func (manager *Manager) Metadata(ctx context.Context, connectionID string) ([]byte, error)

type Operation

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

type Request

type Request struct {
	StateHash      StateHash
	ConnectionID   string
	ConnectionHash [32]byte
	RequestID      string
	CreatedAt      time.Time
	ExpiresAt      time.Time
}

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 {
	CreateRequest(ctx context.Context, request Request) error
	ConsumeRequest(ctx context.Context, stateHash StateHash, consumedAt time.Time) (Request, error)
}

Store creates and consumes each request in one operation.

Jump to

Keyboard shortcuts

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