sso

package
v0.9.15 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 14 Imported by: 1 module, 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 sso is the sign-in library: how a person proves who they are with an account at an identity provider (Google, Microsoft, Apple, GitHub, any OpenID Connect or OAuth 2 server) and what backd does about it. It knows neither backd's users, organizations or sessions nor MongoDB nor HTTP routing: backd plugs in through the ports of the engine. A test fails if anything under sso/ imports a backd package (design/sso.md §3).

This root package holds the types every part shares; the protocol lives in the packages beside it: oidc, oauth2, apple, pkce and safehttp.

Index

Constants

View Source
const (
	CodeCancelled         = "cancelled"
	CodeAccountExists     = "account_exists"
	CodeSignupClosed      = "signup_closed"
	CodeInvitationInvalid = "invitation_invalid"
	CodeLinkConflict      = "link_conflict"
	CodeEmailNotVerified  = "email_not_verified"
	CodeEmailRequired     = "email_required"
	CodeSignInRefused     = "signin_refused"
	CodeProviderError     = "provider_error"
	CodeNotAllowed        = "not_allowed"
	CodeSSORequired       = "sso_required"
)

The codes a failed attempt gives the app, as backd_error.

View Source
const (
	ParamCode     = "backd_code"     // the one-time login code
	ParamError    = "backd_error"    // what went wrong
	ParamProvider = "backd_provider" // with account_exists: the provider that was used
	ParamLinked   = "backd_linked"   // a link succeeded: the provider
	ParamOrg      = "backd_org"      // with the code: where the session will be scoped to
)

The query parameters the engine adds to the app's redirect_to. They carry the prefix so that they can't collide with the app's own, since the app may be any page.

View Source
const (
	AttemptTTL = 10 * time.Minute
	CodeTTL    = time.Minute
)

Lifetimes of the records the engine makes.

View Source
const (
	// EventRefused: the account's state refused a sign-in (audit with the reason).
	EventRefused = "refused"
	// EventAppleToken: keep this refresh token for revoking it when the account goes away.
	EventAppleToken = "apple_token"
	// EventLinkedByDomain: an account was linked to an organization's connection because the address is
	// on a domain the organization proved; the person is to be told.
	EventLinkedByDomain = "linked_by_domain"
)

The kinds of Event.

Variables

View Source
var (
	// ErrAccountExists: an account has the provider's address, but it can't be linked on the
	// provider's word alone.
	ErrAccountExists = errors.New("an account with that address exists")
	// ErrLinkConflict: the provider account belongs to another user, or the user already has an
	// identity of that provider.
	ErrLinkConflict = errors.New("that provider account can't be linked to this user")
	// ErrSignupClosed: sign-up is not open.
	ErrSignupClosed = errors.New("sign-up is closed")
	// ErrInvitationInvalid: sign-up needs an invitation and there is none that fits.
	ErrInvitationInvalid = errors.New("sign-up needs a valid invitation")
	// ErrEmailNotVerified: the realm requires a verified address and the account's is not.
	ErrEmailNotVerified = errors.New("the email address is not verified")
	// ErrEmailRequired: the provider gave no address and accounts need one.
	ErrEmailRequired = errors.New("the provider gave no email address")
	// ErrNotAllowed: the provider's person is not one the place admits.
	ErrNotAllowed = errors.New("the person is not allowed to sign in here")
	// ErrNotFound: the host has no such user or identity.
	ErrNotFound = errors.New("not found")
)

Errors the decision and the host's effects end in. The engine turns each into a code for the app (CodeOf).

View Source
var (
	// ErrInvalidCode: a login code that is unknown, used, expired or not for this verifier.
	ErrInvalidCode = errors.New("the login code is not valid")
	// ErrAuthorizationCodeRequired: Apple's native sign-in needs the authorization code.
	ErrAuthorizationCodeRequired = errors.New("the authorization code is required")
)

Errors of the engine's own.

View Source
var (
	// ErrExchange: the provider refused the authorization code.
	ErrExchange = errors.New("sso: the provider refused the authorization code")
	// ErrInvalidToken: an ID token that does not verify (signature, issuer, audience, expiry
	// or nonce), or is missing what is needed.
	ErrInvalidToken = errors.New("sso: the ID token is not valid")
	// ErrUnavailable: the provider could not be reached, or answered nonsense.
	ErrUnavailable = errors.New("sso: the provider is not available")
)

Errors a provider's answers can lead to. None of them carries anything the provider said beyond its own error code.

Functions

func CodeOf

func CodeOf(err error) string

CodeOf is the code the app is given for an error of the decision, or CodeProviderError for one it does not know (the host logs it).

Types

type Account

type Account struct {
	ID            string
	Email         string
	EmailVerified bool
	Disabled      bool
	Erased        bool
}

Account is a user of the host, as far as sign-in is concerned.

type Action

type Action int

Action is what Decide says to do with a login.

const (
	// Refuse ends the login with Decision.Err.
	Refuse Action = iota
	// SignInKnown: the identity is linked already; sign in as its user.
	SignInKnown
	// LinkToSignedIn adds the identity to the signed-in user (IntentLink).
	LinkToSignedIn
	// LinkToExisting adds the identity to the account that has the provider's address and
	// signs in as it.
	LinkToExisting
	// Create makes a new user and the identity.
	Create
)

The actions.

type Attempt

type Attempt struct {
	Provider string
	// Scope is where the attempt began (the realm, an organization); the callback must be the
	// one of the same scope.
	Scope string
	// Org is the organization of the connection the attempt goes through; empty for the realm's.
	Org      string
	Intent   Intent
	Strategy string
	// Challenge is the app's PKCE challenge (S256); Verifier and Nonce are backd's own with the
	// provider.
	Challenge  string
	Verifier   string
	Nonce      string
	RedirectTo string
	// LinkUserID: IntentLink, whose identity is being added.
	LinkUserID string
	// Host is the host's own data (the invitation, consents, locales, the organization signed in
	// to…): stored and returned untouched.
	Host      json.RawMessage
	ExpiresAt time.Time
}

Attempt is a browser flow in progress: what must be remembered between sending the person to the provider and the provider sending them back. Its key is the hash of the state value.

type AuthorizeParams

type AuthorizeParams struct {
	RedirectURI   string
	State         string
	Nonce         string
	CodeChallenge string // empty: none
}

AuthorizeParams are what an authorization request carries.

type CallbackInput

type CallbackInput struct {
	// Scope is the scope of the address the callback arrived at; empty when the address names a
	// place that can't be signed in to.
	Scope    string
	Provider string
	State    string
	Code     string
	// Error is the provider's own error code, if it sent one; Issuer the `iss` parameter some send
	// (RFC 9207).
	Error  string
	Issuer string
	// User is Apple's first-authorization form field.
	User    string
	Request Request
}

CallbackInput is what the provider's callback carried.

type Catalog

type Catalog interface {
	// Provider returns the provider named in a scope, ready to use. ErrNotFound for every reason it
	// can't be (unknown, off, no secret, the place inactive), never saying which.
	Provider(ctx context.Context, scope, name string) (Provider, error)
	// CallbackURL is the address the provider sends the person back to; false when backd's own
	// public address is unknown.
	CallbackURL(scope string, p Provider) (string, bool)
}

Catalog says which providers a place offers and holds what they need to be used.

type Claims

type Claims struct {
	// Issuer is the issuer that vouched for the subject, as the verified token states it (Google's
	// older form without the scheme is normalized).
	Issuer string
	// Subject identifies the person for the provider.
	Subject       string
	Email         string
	EmailVerified bool
	Name          string
	GivenName     string
	FamilyName    string
	Picture       string
	// Audience is the client id the token was issued to.
	Audience string
	// HostedDomain is Google's hd, Tenant Microsoft's tid and Username its preferred_username,
	// as the verified token states them: what a connection's restriction reads.
	HostedDomain string
	Tenant       string
	Username     string
}

Claims are what a provider said of the person, checked: a verified ID token's claims, or the fields of a userinfo answer.

type Code

type Code struct {
	UserID string
	// Method is the first factor the code stands for.
	Method   string
	Strategy string
	// Challenge is the app's PKCE challenge.
	Challenge string
	NewUser   bool
	Profile   Profile
	// Scope is where the session is scoped to (an organization's id), empty for none.
	Scope     string
	ExpiresAt time.Time
}

Code is the one-time login code's record: what the app gets a session for when it redeems the code with the verifier of the challenge.

type Decision

type Decision struct {
	Action Action
	// Err is set with Refuse.
	Err error
	// ByDomain, with LinkToExisting: the account was linked on the strength of a verified domain.
	ByDomain bool
	// Verified, with Create: the new user's address counts as verified (the provider is trusted
	// and says it is).
	Verified bool
}

Decision is the outcome of Decide.

func Decide

func Decide(p Provider, f Facts) Decision

Decide is the rule that turns a login into an action (design/sso.md §8.1). It reads nothing and changes nothing: the host supplies the facts and carries the action out.

type Directory

type Directory interface {
	// NormalizeEmail returns the address as accounts hold it, or "" when it isn't one.
	NormalizeEmail(raw string) string
	// Identity returns the owner of a provider account (ErrNotFound when it is not linked).
	Identity(ctx context.Context, key IdentityKey) (Account, error)
	// User returns a user by id (ErrNotFound).
	User(ctx context.Context, id string) (Account, error)
	// UserByEmail returns the account that has the (normalized) address (ErrNotFound).
	UserByEmail(ctx context.Context, email string) (Account, error)
	// MaySignIn applies the rules every sign-in answers to (not erased, not disabled, from an
	// allowed network, a verified address when the realm requires one): a *Refused or ErrEmailNotVerified.
	MaySignIn(ctx context.Context, a Account, req Request) error
	// Touch records a sign-in with a linked identity and what the provider says of the address now.
	Touch(ctx context.Context, key IdentityKey, l Login, email string)
	// Link adds the identity to the account; ErrLinkConflict when it is taken or the account
	// already has one of the provider.
	Link(ctx context.Context, a Account, l Login, email string) error
	// Create makes a user and its identity, as the place's sign-up rules allow: ErrSignupClosed,
	// ErrInvitationInvalid or ErrAccountExists (a race for the address). verified says the provider
	// vouches for the address.
	Create(ctx context.Context, l Login, email string, verified bool) (Account, error)
	// Enter lets a resolved login into the place it was for (joins the organization, uses the
	// invitation). allowed is false when the person may not sign in there; scope is what the session
	// is scoped to.
	Enter(ctx context.Context, e Entry) (scope string, allowed bool)
	// Superseded says whether the attempt may not finish because the place's rules changed since it
	// began (the organization now requires its connection): the code to give the app, or "".
	Superseded(ctx context.Context, a Attempt, p Provider) string
	// CleanProfile builds the profile handed to the app from the claims and the extra fields some
	// providers send in the callback (Apple's name): bounded, with only the known fields.
	CleanProfile(c Claims, extra map[string]string) Profile
}

Directory is the host's accounts, as far as sign-in is concerned. Every method that changes something is the host's whole business for it: audit, quotas, on-signup hooks.

type Endpoints

type Endpoints struct {
	Authorize, Token, JWKS, Revoke string
	// UserInfo is where an OAuth 2 provider's person is read (GitHub: /user); Emails is GitHub's list
	// of addresses.
	UserInfo, Emails string
}

Endpoints are the URLs of a provider.

func BuiltinEndpoints

func BuiltinEndpoints(kind Kind, tenant string) Endpoints

BuiltinEndpoints are the endpoints of the built-in kinds.

type Engine

type Engine struct {
	Store     Store
	Catalog   Catalog
	Directory Directory
	Events    Events
	Protocol  Protocol
	// Now is the clock; time.Now when nil.
	Now func() time.Time
}

Engine runs sign-ins with external providers over the host's ports. It holds no state of its own, so one serves every realm.

func (*Engine) Callback

func (e *Engine) Callback(ctx context.Context, in CallbackInput) Outcome

Callback finishes a browser flow: it checks the attempt, runs the exchange and the checks of the place, decides who the person is and ends with a login code (or a code for what went wrong).

func (*Engine) IDToken

func (e *Engine) IDToken(ctx context.Context, in IDTokenInput) (Native, error)

IDToken signs a person in (or links their account) with an ID token the app already holds. The errors are ErrInvalidToken (401), ErrUnavailable (the provider could not be reached), ErrNotAllowed, ErrNotFound (a connection that can't be used), ErrAuthorizationCodeRequired, ErrExchange (Apple's code), or the rules' (CodeOf).

func (*Engine) Redeem

func (e *Engine) Redeem(ctx context.Context, code, verifier string) (Code, error)

Redeem trades a login code and the PKCE verifier for the record the host makes a session from. The code is used up whether or not the verifier fits, so a stolen code can't be tried again. The record is returned with ErrInvalidCode when the code was good and the verifier was not, so the host can audit whose it was.

func (*Engine) Resolve

func (e *Engine) Resolve(ctx context.Context, l Login) (Result, error)

Resolve decides who a provider's person is under the rules of design/sso.md §8.1 and carries the decision out through the Directory. It starts no session.

func (*Engine) Start

func (e *Engine) Start(ctx context.Context, in StartInput) (string, error)

Start remembers the attempt and returns the provider's authorize URL.

type Entry

type Entry struct {
	Login   Login
	Result  Result
	Attempt Attempt
}

Entry is a login that has been resolved to a user, about to be let into the place it was for.

type Event

type Event struct {
	// Kind is one of the Event constants.
	Kind     string
	Provider Provider
	UserID   string
	// Reason is, for EventRefused, why.
	Reason string
	// Token is, for EventAppleToken, Apple's refresh token to keep for revocation, with Audience
	// the client id it was issued to. It is never logged.
	Token, Audience string
}

Event is something that happened because of a sign-in, for the host's audit and jobs.

type Events

type Events interface {
	Emit(ctx context.Context, e Event)
}

Events receives what happens because of sign-ins.

type Facts

type Facts struct {
	Intent Intent
	// Known is the owner of the identity, when it is linked.
	Known *Account
	// LinkUser is the signed-in user of an IntentLink attempt (nil when there is none to find).
	LinkUser *Account
	// ByEmail is the account that has the provider's address.
	ByEmail *Account
	// Email is the provider's address, normalized; empty when it gave none or an invalid one.
	Email string
	// EmailVerified is the provider's word on it.
	EmailVerified bool
	// DomainOK: the address is on a verified domain of the organization that lets sign-ins link accounts.
	DomainOK bool
	// LinkUserID is the user an IntentLink attempt was started by.
	LinkUserID string
}

Facts are what the host found out about a login.

type IDTokenInput

type IDTokenInput struct {
	Scope             string
	Provider          Provider
	IDToken, Nonce    string
	AuthorizationCode string
	Intent            Intent
	LinkUserID        string
	Host              []byte
	Request           Request
}

IDTokenInput is a native app's sign-in: the ID token the platform gave it.

type IdentityKey

type IdentityKey struct {
	Provider string
	Org      string // the organization of a connection; empty for the realm's providers
	// Issuer is the issuer that vouched for the subject: a subject is only unique within one
	// issuer, so an identity of another issuer is a different person (design/sso.md §6.1).
	Issuer  string
	Subject string
}

IdentityKey names a provider account: the identity it makes is unique on it.

type Intent

type Intent string

Intent is what a sign-in attempt is for.

const (
	IntentSignIn Intent = "signin"
	IntentLink   Intent = "link"
)

The intents of an attempt.

func (Intent) Valid

func (i Intent) Valid() bool

Valid says whether i is one of the two.

type Kind

type Kind string

Kind says how a provider is spoken to and which rules its tokens follow.

const (
	Google    Kind = "google"
	Microsoft Kind = "microsoft"
	Apple     Kind = "apple"
	// OIDC is any OpenID Connect provider the operator names (type: oidc): its endpoints come from
	// its issuer's discovery document.
	OIDC Kind = "oidc"
	// GitHub is GitHub: OAuth 2 without an ID token, the person read from its API.
	GitHub Kind = "github"
	// OAuth2 is a plain OAuth 2 service the operator describes (type: oauth2): its endpoints and the
	// fields of its userinfo answer are configured.
	OAuth2 Kind = "oauth2"
)

The built-in kinds.

type LinkPolicy

type LinkPolicy int

LinkPolicy says when a provider's word about an address is enough to link an account.

const (
	// LinkNever: an account with the address is reported (account_exists), never linked.
	LinkNever LinkPolicy = iota
	// LinkVerifiedEmail: a verified address the provider asserts links the account that has
	// it, if the account's own address is verified too.
	LinkVerifiedEmail
	// LinkVerifiedDomain: an organization's connection: a verified address on one of the organization's
	// verified domains links the account that has it, if the account's own address is verified.
	LinkVerifiedDomain
)

The policies.

type Login

type Login struct {
	Provider Provider
	Claims   Claims
	Profile  Profile
	Intent   Intent
	// LinkUserID is, for IntentLink, the signed-in user.
	LinkUserID string
	// Host is the host's own data from the start of the attempt (the library never reads it).
	Host    json.RawMessage
	Request Request
}

Login is a person a provider has vouched for, with the context the host needs to decide what to do about it.

type Native

type Native struct {
	Result
	// Scope is what the session is scoped to.
	Scope string
}

Native is the outcome of a native sign-in.

type Outcome

type Outcome struct {
	// Page: the attempt can't be traced to an app (unknown, used, expired or foreign state): show the
	// error page.
	Page bool
	// RedirectTo and Params: send the browser back to the app with these query parameters (name,
	// value, name, value…).
	RedirectTo string
	Params     []string
	// UserID is the user a successful sign-in is for.
	UserID string
	// Err is why the attempt failed, for the host's log; the app only gets the code.
	Err error
}

Outcome is what the engine tells the host to do at the end of a callback.

type Profile

type Profile map[string]string

Profile is what the provider says of the person (name, given_name, family_name, picture): handed to the app once, for a new user, and kept nowhere.

type Protocol

type Protocol interface {
	// Prepare completes a provider before it is used: a generic OpenID Connect provider's endpoints
	// are read from its issuer's discovery document (cached). ErrUnavailable when they can't be.
	Prepare(ctx context.Context, p Provider) (Provider, error)
	// UsesPKCE says whether a PKCE challenge goes to the provider.
	UsesPKCE(p Provider) bool
	AuthorizeURL(p Provider, a AuthorizeParams) string
	// Exchange trades the authorization code for the person's tokens.
	Exchange(ctx context.Context, p Provider, code, redirectURI, verifier string) (Tokens, error)
	// Identify says who the tokens of a code exchange are for: an OpenID Connect provider's ID token
	// is verified against the nonce, an OAuth 2 provider's person is read with the access token.
	Identify(ctx context.Context, p Provider, t Tokens, nonce string) (Claims, error)
	// Verify checks an ID token and returns what it says; native admits the mobile apps' audiences
	// and the hashed nonce.
	Verify(ctx context.Context, p Provider, idToken, nonce string, native bool) (Claims, error)
	// AppleRefresh trades the authorization code a native app sends with its ID token for Apple's
	// refresh token, checking that both belong to the same person and app.
	AppleRefresh(ctx context.Context, p Provider, claims Claims, code string) (string, error)
	// FirstAuthorization reads the extra fields a provider posts to the callback the first time a
	// person authorizes the app (Apple's name); nil for the others.
	FirstAuthorization(p Provider, raw string) map[string]string
}

Protocol speaks to a provider. sso/protocol implements it over the oidc, oauth2 and apple packages; tests use a fake.

type Provider

type Provider struct {
	Name string // what identities, URLs and the audit call it
	Kind Kind
	// ClientID is the application's id with the provider (Apple: the Services ID).
	ClientID string
	// NativeClientIDs (Apple: bundle ids) are the extra audiences the ID-token endpoint accepts.
	NativeClientIDs []string
	// Tenant is Microsoft's: common, organizations, consumers or a tenant id.
	Tenant string
	// Issuer is the issuer a generic OpenID Connect provider is configured with; its ID tokens must
	// name exactly it. Built-in providers know theirs. Empty: unknown (Microsoft across tenants).
	Issuer string
	// Scopes are extra scopes asked for besides openid email profile (generic providers), or all of
	// them for a plain OAuth 2 provider.
	Scopes []string
	// Claims maps the fields of an OAuth 2 provider's userinfo answer to the person: subject, email,
	// email_verified, name, given_name, family_name, picture. A name is a field, or a dotted path.
	Claims map[string]string
	// NoPKCE: the provider takes no PKCE challenge (OAuth 2 providers that reject unknown parameters).
	NoPKCE bool
	// Hosts are the hosts the library may reach for this provider besides the built-in ones: the
	// issuer's, and after discovery the endpoints' that share its registered domain.
	Hosts []string
	// AllowPrivate lets the provider's own hosts resolve to private ranges (never loopback,
	// link-local or the metadata address): an identity provider on the operator's network.
	AllowPrivate bool
	// TeamID and KeyID are Apple's: they sign the client secret.
	TeamID, KeyID string
	Endpoints     Endpoints

	// Org is the organization of a connection; empty for the realm's providers. Identities of
	// a connection are (Name, Org, subject).
	Org string
	// Method is how a session records the first factor of this provider (its name, or the
	// connection's).
	Method string
	// Link says whether the provider's verified addresses may link an existing account.
	Link LinkPolicy
	// Secret is the client secret (Apple: the .p8 private key's PEM), read by the host when it
	// resolved the provider; the library keeps none.
	Secret string
	// RevokeOnDelete: keep Apple's refresh token so a deleted account's tokens can be revoked.
	RevokeOnDelete bool
	// LinkDomains are, for LinkVerifiedDomain, the organization's verified domains that let a sign-in
	// link accounts (verified, with link_accounts on), as of the moment the provider was resolved.
	LinkDomains []string
	// VerifiesEmail says whether the provider vouches for the address of the claims; nil: the claims'
	// own EmailVerified. A Microsoft tenant vouches for an address on the domain of its account's name.
	VerifiesEmail func(Claims) bool
	// Admit says whether the place admits the person the provider vouched for (a connection's
	// restriction); nil admits everyone.
	Admit func(Claims) bool
	// Authority is a last check before a connection signs anybody in (its setter still holds
	// the roles it was set with); nil is none. An error ends the attempt as an unavailable provider.
	Authority func(ctx context.Context) error
}

Provider is a provider ready to be spoken to: what the protocol packages need and nothing of where the configuration came from.

func (Provider) Audiences

func (p Provider) Audiences(native bool) []string

Audiences are the client ids an ID token may be issued to: the web client and, for the ID-token endpoint, the native ones.

type Refused

type Refused struct {
	UserID string
	Reason string
}

Refused is a sign-in the account's state refuses (disabled, erased, from this network). The app is only told it was refused; Reason is for the audit.

func (*Refused) Error

func (e *Refused) Error() string

type Request

type Request struct {
	IP        string
	UserAgent string
	Locales   []string
}

Request is what the host knows of the HTTP request an engine call came from.

type Result

type Result struct {
	Account Account
	NewUser bool
	// Linked: an identity was added to an existing account.
	Linked  bool
	Profile Profile
}

Result is who a login turned out to be.

type StartInput

type StartInput struct {
	// Scope is where the attempt begins; the callback must be in the same one.
	Scope       string
	Provider    Provider
	CallbackURL string
	Intent      Intent
	Strategy    string
	// Challenge is the app's PKCE challenge.
	Challenge  string
	RedirectTo string
	LinkUserID string
	// Host is the host's own data, returned untouched at the callback.
	Host []byte
}

StartInput describes a sign-in or a link the host has checked (redirect allowed, strategy chosen, secrets set) and wants begun.

type Store

type Store interface {
	// PutAttempt saves the attempt under the hash of its state value.
	PutAttempt(ctx context.Context, key string, a Attempt) error
	// TakeAttempt returns the attempt and forgets it: ErrNotFound when it is unknown, used or expired.
	TakeAttempt(ctx context.Context, key string) (Attempt, error)
	// PutCode saves a login code under the hash of its value.
	PutCode(ctx context.Context, key string, c Code) error
	// TakeCode returns the code's record and forgets it: ErrNotFound when it is unknown, used or expired.
	TakeCode(ctx context.Context, key string) (Code, error)
}

Store keeps what the library creates and must find again. Reads of one-time records are atomic: two concurrent takes of the same key get the record once.

type Tokens

type Tokens struct {
	IDToken string
	// AccessToken is what an OAuth 2 provider without an ID token gives; it is used once, to read the
	// person, and never kept.
	AccessToken  string
	RefreshToken string
}

Tokens are what a code exchange gives back that the library keeps using.

Directories

Path Synopsis
Package apple holds what Sign in with Apple needs beyond OpenID Connect: the client secret (a JWT signed with the developer's key) and the revocation of a user's tokens.
Package apple holds what Sign in with Apple needs beyond OpenID Connect: the client secret (a JWT signed with the developer's key) and the revocation of a user's tokens.
Package httpsso is the HTTP side of the sso engine that does not depend on the host: reading what a provider's callback carries and sending the browser back to the app.
Package httpsso is the HTTP side of the sso engine that does not depend on the host: reading what a provider's callback carries and sending the browser back to the app.
Package oauth2 runs the OAuth 2 authorization-code flow against a provider: the authorize URL and the code exchange.
Package oauth2 runs the OAuth 2 authorization-code flow against a provider: the authorize URL and the code exchange.
Package oidc verifies the ID tokens of OpenID Connect providers: the signature against the provider's published keys (cached), issuer, audience, expiry and nonce.
Package oidc verifies the ID tokens of OpenID Connect providers: the signature against the provider's published keys (cached), issuer, audience, expiry and nonce.
Package pkce makes and checks PKCE (RFC 7636) verifiers and S256 challenges.
Package pkce makes and checks PKCE (RFC 7636) verifiers and S256 challenges.
Package protocol implements sso.Protocol over the oidc, oauth2 and apple packages: it is what the engine uses to speak to the real providers.
Package protocol implements sso.Protocol over the oidc, oauth2 and apple packages: it is what the engine uses to speak to the real providers.
Package safehttp is the HTTP client sign-in uses to reach identity providers.
Package safehttp is the HTTP client sign-in uses to reach identity providers.
Package ssotest is a small identity provider for tests: it signs ID tokens with its own key, publishes them, and plays the parts of a provider's authorize, token and keys endpoints, so the sign-in flow can be run end to end without a real one.
Package ssotest is a small identity provider for tests: it signs ID tokens with its own key, publishes them, and plays the parts of a provider's authorize, token and keys endpoints, so the sign-in flow can be run end to end without a real one.

Jump to

Keyboard shortcuts

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