oauthtest

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0, CC-BY-4.0, MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInfo

type ClientInfo struct {
	Secret       string
	RedirectURIs []string
}

type Config

type Config struct {
	// The optional path component of the issuer URL.
	// If non-empty, it should start with a "/". It should not end with a "/".
	// It affects the paths of the server endpoints.
	IssuerPath string
	// Configuration of the metadata endpoint.
	MetadataEndpointConfig *MetadataEndpointConfig
	// Configuration for client registration.
	RegistrationConfig *RegistrationConfig
}

Config holds configuration for FakeAuthorizationServer.

type FakeAuthorizationServer

type FakeAuthorizationServer struct {
	Mux *http.ServeMux
	// contains filtered or unexported fields
}

FakeAuthorizationServer is a fake OAuth 2.0 Authorization Server for testing.

func NewFakeAuthorizationServer

func NewFakeAuthorizationServer(config Config) *FakeAuthorizationServer

NewFakeAuthorizationServer creates a new FakeAuthorizationServer. The server is simple and should not be used outside of testing. It supports: - Only the authorization Code Grant - PKCE verification - Client tracking & dynamic registration - Client authentication

func (*FakeAuthorizationServer) Start

func (s *FakeAuthorizationServer) Start(t testing.TB)

Start starts the HTTP server and registers a cleanup function on t to close the server.

func (*FakeAuthorizationServer) URL

URL returns the base URL of the server (Issuer).

type MetadataEndpointConfig

type MetadataEndpointConfig struct {
	// Whether to serve the OAuth Authorization Server Metadata at
	// /.well-known/oauth-authorization-server + issuerPath.
	ServeOAuthInsertedEndpoint bool
	// Whether to serve the OAuth Authorization Server Metadata at
	// /.well-known/openid-configuration + issuerPath.
	ServeOpenIDInsertedEndpoint bool
	// Whether to serve the OAuth Authorization Server Metadata at
	// issuerPath + /.well-known/openid-configuration.
	// Should be used when issuerPath is not empty.
	ServeOpenIDAppendedEndpoint bool
}

type RegistrationConfig

type RegistrationConfig struct {
	// Whether the client ID metadata document is supported.
	ClientIDMetadataDocumentSupported bool
	// PreregisteredClients is a map of valid ClientIDs to ClientSecrets.
	PreregisteredClients map[string]ClientInfo
	// Whether dynamic client registration is enabled.
	DynamicClientRegistrationEnabled bool
}

Jump to

Keyboard shortcuts

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