Documentation
¶
Index ¶
- Variables
- func NewTokenSource(proofer *dpop.Proofer, tokenURL *url.URL, clientID string, ...) (*tokenSource, error)
- type ClaimsMarshaler
- type NonceStore
- type TokenRequest
- type TokenRequestOption
- type TokenSourceOption
- func WithBaseContext(ctx context.Context) TokenSourceOption
- func WithHTTPClient(client *http.Client) TokenSourceOption
- func WithNonceStore(store *NonceStore) TokenSourceOption
- func WithProofOptions(options ...dpop.ProofOption) TokenSourceOption
- func WithRequestOption(opt TokenRequestOption) TokenSourceOption
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 (*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