identitytest

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package identitytest is a tiny OIDC issuer (discovery + JWKS + token minting + an auto-approving authorization-code/PKCE flow) for tests and the compose demo. Not for production use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sign

func Sign(header, claims map[string]any, sign func([]byte) ([]byte, error)) (string, error)

Sign assembles header.payload.signature with a caller-supplied signer (nil signer => empty signature, for alg=none tests).

Types

type Issuer

type Issuer struct {
	URL string // issuer identifier; set once serving
	Key *rsa.PrivateKey
	KID string
	// contains filtered or unexported fields
}

Issuer serves /.well-known/openid-configuration and /jwks.

func NewIssuer

func NewIssuer(kid string) (*Issuer, error)

NewIssuer generates a key. Call Handler (demo) or Serve (tests) next.

func (*Issuer) Handler

func (i *Issuer) Handler() http.Handler

Handler serves discovery and JWKS; i.URL must already be the public issuer URL.

func (*Issuer) JWK

func (i *Issuer) JWK() map[string]string

JWK is the public key as a JSON Web Key.

func (*Issuer) Mint

func (i *Issuer) Mint(claims map[string]any) (string, error)

Mint signs claims (RS256) with the issuer key. iss/exp/iat are defaulted, and email_verified=true when an email is present (as a real IdP would); a nil claim value removes the claim (e.g. "email_verified": nil).

func (*Issuer) Serve

func (i *Issuer) Serve() *httptest.Server

Serve starts an httptest server and points i.URL at it. Caller closes.

func (*Issuer) SetLogin

func (i *Issuer) SetLogin(claims map[string]any)

SetLogin sets the claims (e.g. email, groups) the /authorize endpoint auto-approves for subsequent code flows; nil makes /authorize refuse.

Jump to

Keyboard shortcuts

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