Documentation
¶
Overview ¶
Package sso provides the shared contract used by protocol-specific authentication adapters (SAML, OIDC) in this module.
A consumer of this library plugs in one or more adapters (see the saml and oidc subpackages) and receives a Subject through the OnAuthenticated callback once authentication succeeds. The consumer is responsible for translating that Subject into its own session representation; this package stores nothing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorLogger ¶
ErrorLogger receives runtime errors encountered while processing an SSO HTTP request. The msg argument is a short stable identifier for the failing stage (e.g. "token-exchange", "verify-id-token", "on-authenticated"). HTTP responses from the adapters stay generic; this callback exists so consumers can route the underlying cause to their own structured logger without exposing internals to the browser.
type GroupMapper ¶
type GroupMapper[R comparable] map[string]R
GroupMapper translates raw IdP group identifiers into the consumer's application-specific role type. It is a convenience helper; consumers with different translation needs should skip it and roll their own.
func (GroupMapper[R]) Map ¶
func (m GroupMapper[R]) Map(groups []string) []R
Map returns the roles for every known group, preserving input order and deduplicating results. Unknown groups are silently skipped.
type OnAuthenticated ¶
type OnAuthenticated[T any] func( ctx context.Context, w http.ResponseWriter, r *http.Request, sub Subject[T], ) error
OnAuthenticated fires after a successful authentication round-trip. The consumer is responsible for persisting whatever session representation (cookie, JWT, server-side record, ...) it needs.
Returning a non-nil error aborts the login flow: the adapter will not perform its post-authentication redirect and will surface the error as HTTP 500 to the caller.
type OnLogout ¶
OnLogout fires when the logout handler is invoked. The consumer should destroy its session. Returning a non-nil error aborts logout with HTTP 500 and skips any IdP-side single-logout redirect.
type Subject ¶
type Subject[T any] struct { // ExternalID is the stable IdP-side user identifier // (Azure AD objectidentifier, OIDC `sub`). ExternalID string Email string Firstname string Lastname string // Groups holds the raw group identifiers as returned by the IdP. // Use GroupMapper to translate them into application roles. Groups []string // NameID is the SAML NameID; empty for OIDC and other non-SAML flows. NameID string // Raw carries the protocol-specific payload. Raw T }
Subject is the authenticated principal handed to the consumer after a successful authentication round-trip. The T type parameter carries the protocol-specific raw payload (e.g. saml.Payload, oidc.Payload); the other fields are common across protocols so consumers can share session construction logic.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
safepath
Package safepath provides open-redirect-safe URL target validation shared by the SAML and OIDC adapters.
|
Package safepath provides open-redirect-safe URL target validation shared by the SAML and OIDC adapters. |
|
telemetry
Package telemetry exposes the OpenTelemetry instrumentation scope used by the gosso adapters.
|
Package telemetry exposes the OpenTelemetry instrumentation scope used by the gosso adapters. |
|
Package oidc implements a stateless OIDC 1.0 Relying Party running the Authorization Code flow with PKCE.
|
Package oidc implements a stateless OIDC 1.0 Relying Party running the Authorization Code flow with PKCE. |
|
Package saml implements a stateless SAML 2.0 Service Provider on top of github.com/crewjam/saml.
|
Package saml implements a stateless SAML 2.0 Service Provider on top of github.com/crewjam/saml. |