dpop_oauth2

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingRequiredField indicates a required field was not provided
	ErrMissingRequiredField = errors.New("dpop_oauth2: missing required field")

	// ErrInvalidToken indicates the token response was invalid
	ErrInvalidToken = errors.New("dpop_oauth2: invalid token response")

	// ErrNonceMissing indicates the server requested a nonce but didn't provide one
	ErrNonceMissing = errors.New("dpop_oauth2: server requested DPoP nonce but did not provide one")

	// ErrTokenRequestFailed indicates the token request failed
	ErrTokenRequestFailed = errors.New("dpop_oauth2: token request failed")

	// ErrProofCreationFailed indicates failure to create or sign DPoP proof
	ErrProofCreationFailed = errors.New("dpop_oauth2: failed to create or sign DPoP proof")
)

Functions

func NewTokenSource

func NewTokenSource(proofer *dpop.Proofer, tokenURL *url.URL, clientID string, clientSecret *jose.JSONWebKey, opts ...TokenSourceOption) (*tokenSource, error)

Types

type ClaimsMarshaler

type ClaimsMarshaler func(*jwt.Claims) ([]byte, error)

ClaimsMarshaler is a function that marshals JWT claims

type NonceStore

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

NonceStore provides thread-safe storage and retrieval of the most recent DPoP nonce

func NewNonceStore

func NewNonceStore() *NonceStore

NewNonceStore creates a new NonceStore

func (*NonceStore) GetNonce

func (ns *NonceStore) GetNonce() string

GetNonce returns the current nonce value, or empty string if none is set

func (*NonceStore) SetNonce

func (ns *NonceStore) SetNonce(nonce string)

SetNonce updates the current nonce value

type TokenRequest

type TokenRequest struct {
	Claims    *jwt.Claims
	Body      url.Values
	Headers   http.Header
	Marshaler ClaimsMarshaler
}

TokenRequest encapsulates all the data needed for a token request

type TokenRequestOption

type TokenRequestOption func(*TokenRequest) error

TokenRequestOption is a function that modifies a token request

func WithCustomHeaders

func WithCustomHeaders(fn func(http.Header) error) TokenRequestOption

WithCustomHeaders returns an option that adds additional headers

func WithCustomMarshaler

func WithCustomMarshaler(m ClaimsMarshaler) TokenRequestOption

WithCustomMarshaler returns an option that sets a custom claims marshaler

func WithCustomParameters

func WithCustomParameters(fn func(url.Values) error) TokenRequestOption

WithCustomParameters returns an option that adds additional body parameters

type TokenSourceOption

type TokenSourceOption func(*tokenSourceOptions)

TokenSourceOption configures the behavior of the token source

func WithBaseContext

func WithBaseContext(ctx context.Context) TokenSourceOption

WithBaseContext sets a custom base context for the token source

func WithHTTPClient

func WithHTTPClient(client *http.Client) TokenSourceOption

WithHTTPClient sets a custom HTTP client

func WithNonceStore

func WithNonceStore(store *NonceStore) TokenSourceOption

WithNonceStore sets a nonce store for DPoP proofs

func WithProofOptions

func WithProofOptions(options ...dpop.ProofOption) TokenSourceOption

WithProofOptions sets additional DPoP proof options

func WithRequestOption

func WithRequestOption(opt TokenRequestOption) TokenSourceOption

WithRequestOption adds a TokenRequestOption to modify the token request

Jump to

Keyboard shortcuts

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