authtest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package authtest is a stand-in for the identity provider an API trusts, for the API's tests. It publishes discovery and a key set, grants client-credentials tokens, and signs RFC 9068 access tokens the way Authelia does: typed at+jwt, RS256, and with no subject on a service's token.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bearer

func Bearer(token string) *http.Client

Bearer is a client sending token with every request.

Types

type Provider

type Provider struct {
	URL string
	// contains filtered or unexported fields
}

Provider is a running stand-in. URL is its issuer.

func NewProvider

func NewProvider(t testing.TB) *Provider

NewProvider starts a provider that lives as long as t.

func (*Provider) Person

func (p *Provider) Person(t testing.TB, clientID, subject string) string

Person is the token a person's device login as clientID would hold.

func (*Provider) Register

func (p *Provider) Register(clientID, secret string, scopes ...string)

Register lets clientID authenticate with secret and be granted scopes.

func (*Provider) Sign

func (p *Provider) Sign(t testing.TB, typ string, claims map[string]any) string

Sign is a token typed typ, carrying claims over the issuer and expiry every token the provider grants has. A claim set to nil is left out.

func (*Provider) Verifier

func (p *Provider) Verifier(t testing.TB, personPrefix, servicePrefix string) *goapiauth.Verifier

Verifier is a goapiauth.Verifier reading this provider, for the person and service client prefixes the caller's production code uses.

Jump to

Keyboard shortcuts

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