issuer

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package issuer verifies tokens from a trusted external issuer, so a platform that already authenticates its users can open a Dexaflow UI session for them without holding Dexaflow's own signing secret (#1284).

The issuer signs with its own key and publishes it as a JWKS; Dexaflow only ever reads public keys. A verified token names an existing user (by the issuer's subject) in an allowed tenant. It never creates users and never grants roles: roles stay whatever the user row holds.

Index

Constants

View Source
const DefaultMaxLifetime = 2 * time.Minute

DefaultMaxLifetime bounds exp - iat when Config.MaxLifetime is zero. A handoff is posted the moment it is minted, so two minutes is generous.

Variables

View Source
var (
	// ErrInvalidToken covers a bad signature, issuer, audience, expiry or a
	// missing subject or jti: the token is not one the trusted issuer made for
	// us.
	ErrInvalidToken = errors.New("issuer: invalid token")
	// ErrLifetime is a token without iat, one valid for longer than
	// MaxLifetime, or one issued in the future. A handoff token is meant to be
	// used once, right away; a long or post-dated one is a long replay window.
	ErrLifetime = errors.New("issuer: token lifetime missing or too long")
	// ErrTenantNotAllowed is a tenant claim that is absent, not a string, or
	// not in AllowedTenants.
	ErrTenantNotAllowed = errors.New("issuer: tenant not allowed")
	// ErrReplayed is a token whose jti this server already accepted. A handoff
	// token opens one session; a second post of the same token is a replay.
	ErrReplayed = errors.New("issuer: token already used")
)

Verification failures. Each is fail-closed; callers log the class and show the browser nothing more specific than "not signed in".

Functions

This section is empty.

Types

type Config

type Config struct {
	// Name identifies the issuer inside Dexaflow. Its users are linked by
	// (Provider(), subject), so it must stay stable once users exist.
	Name string
	// Issuer is the exact `iss` the tokens carry.
	Issuer string
	// JWKSURL is where the issuer publishes its public signing keys.
	JWKSURL string
	// Audience is the `aud` the tokens must carry for this Dexaflow.
	Audience string
	// TenantClaim names the string claim carrying the Dexaflow tenant name.
	TenantClaim string
	// AllowedTenants lists the tenants this issuer may sign in to; "*" allows
	// every tenant.
	AllowedTenants []string
	// MaxLifetime caps exp - iat; zero means DefaultMaxLifetime.
	MaxLifetime time.Duration
}

Config is one trusted issuer.

type Identity

type Identity struct {
	Subject string
	Email   string
	Tenant  string
}

Identity is what a verified token says about the user.

type Verifier

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

Verifier checks tokens against one trusted issuer.

func New

func New(ctx context.Context, cfg Config) *Verifier

New builds a Verifier. It makes no network call: the JWKS is fetched on the first Verify and cached, refreshed when a token names an unknown key id, so key rotation needs no restart and an issuer outage cannot block boot.

func (*Verifier) Provider

func (v *Verifier) Provider() string

Provider is the key this issuer's users are linked under (the users table's oidc_provider). The "issuer:" prefix keeps it apart from OIDC provider names.

func (*Verifier) Verify

func (v *Verifier) Verify(ctx context.Context, raw string) (*Identity, error)

Verify checks raw and returns the identity it carries.

Jump to

Keyboard shortcuts

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