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

saml

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: 17 Imported by: 0

Documentation

Overview

Package saml is the SAML 2.0 identity adapter (R-043).

Service-provider-initiated sign-in over the HTTP-Redirect binding, with the response returned over HTTP-POST. Every response must be signed — the Response, the Assertion, or both — by a certificate from the provider's metadata; an unsigned one is refused whatever it says. Sign-ins the provider starts on its own (IdP-initiated) are refused unless an administrator turns them on, because nothing ties such a response to the browser presenting it.

Authentication only (R-044): a verified assertion becomes a Subject, and core decides everything else.

Index

Constants

View Source
const ClockSkew = 3 * time.Minute

ClockSkew is how far the provider's clock and Pando's may disagree, in either direction, before an assertion is refused as not yet valid or expired. Three minutes, set once for every provider: the library holds it as a package variable.

View Source
const DefaultSessionLifetime = 12 * time.Hour

DefaultSessionLifetime is the session length when the configuration does not say. Without SCIM it is also the revocation window (R-050).

View Source
const Kind = "saml"

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.

Types

type Adapter

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

Adapter is the SAML 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 verifies a SAMLResponse posted to the assertion consumer service: signature, issuer, audience, recipient, destination, validity window and — for a sign-in Pando started — that it answers Pando's request.

func (*Adapter) Begin

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

Begin builds an AuthnRequest for the HTTP-Redirect binding, with core's state as the RelayState.

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. Metadata given inline is parsed now, so a paste that is not metadata fails at save; metadata by URL is fetched at the first use and HealthCheck, so a provider that is down does not block saving.

func (*Adapter) HealthCheck

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

HealthCheck makes sure the provider's metadata can be read and names a sign-in address and a signing certificate.

func (*Adapter) Kind

func (a *Adapter) Kind() string

func (*Adapter) ServiceMetadata

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

ServiceMetadata is Pando's service provider metadata: its entity ID, the assertion consumer service for HTTP-POST, and that assertions must be signed. An administrator gives the provider its URL, or the file.

func (*Adapter) SessionPolicy

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

SessionPolicy declares this adapter's session behavior (R-047). As for OIDC: expiry-only unless the installation turns SCIM on for the provider, which core then reports as push (R-048, R-050).

func (*Adapter) SupportsPush

func (a *Adapter) SupportsPush() bool

SupportsPush is true: the providers this targets provision through SCIM.

func (*Adapter) WithHTTPClient

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

WithHTTPClient replaces the client used to fetch metadata, for tests.

type Config

type Config struct {
	// One of these: where the provider publishes its metadata, or the
	// metadata itself.
	MetadataURL string `json:"idp_metadata_url,omitempty"`
	MetadataXML string `json:"idp_metadata_xml,omitempty"`

	// NameIDFormat asks for a NameID format: unspecified (the default),
	// email, persistent or transient. Transient is refused: it changes at
	// every sign-in, so it cannot identify anyone.
	NameIDFormat string `json:"name_id_format,omitempty"`

	// Which attribute carries what. Empty tries the names Okta, Entra, Google,
	// Keycloak and Authentik use.
	SubjectAttribute  string `json:"subject_attribute,omitempty"`
	UsernameAttribute string `json:"username_attribute,omitempty"`
	EmailAttribute    string `json:"email_attribute,omitempty"`
	NameAttribute     string `json:"name_attribute,omitempty"`
	GroupsAttribute   string `json:"groups_attribute,omitempty"`

	// TrustEmail says the provider's email attribute is controlled by its
	// administrators, not by the people signing in. SAML has no
	// email_verified, so without this Pando never links an account by email.
	TrustEmail bool `json:"trust_email,omitempty"`

	// AllowIDPInitiated accepts sign-ins started from the provider's own
	// dashboard. Off by default: such a response is not tied to the browser
	// that presents it, so it can sign someone in as someone else.
	AllowIDPInitiated bool `json:"allow_idp_initiated,omitempty"`

	SessionMaxLifetime string `json:"session_max_lifetime,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