Documentation
¶
Overview ¶
Package dpop_http provides a net/http client with DPoP support
Package dpop_http provides net/http server middleware with DPoP support
Index ¶
Constants ¶
View Source
const ( // AuthorizationHeader is the standard HTTP header for authorization AuthorizationHeader = "Authorization" // DPoPScheme is the scheme used for DPoP bound tokens DPoPScheme = "DPoP" // BearerScheme is the scheme used for Bearer tokens BearerScheme = "Bearer" )
Variables ¶
View Source
var ( // ErrMissingDPoPHeader is returned when the DPoP header is missing ErrMissingDPoPHeader = errors.New("missing DPoP header") // ErrInvalidDPoPHeader is returned when the DPoP header is invalid ErrInvalidDPoPHeader = errors.New("invalid DPoP header") // ErrInvalidAuthScheme is returned when the Authorization header has an invalid scheme ErrInvalidAuthScheme = errors.New("invalid authorization scheme") )
Functions ¶
func Middleware ¶
func Middleware(opts ...ServerOption) func(http.Handler) http.Handler
Middleware creates a new DPoP middleware handler
Types ¶
type ServerOption ¶
type ServerOption func(*serverOptions)
ServerOption configures how we set up the DPoP middleware
func WithErrorHandler ¶
func WithErrorHandler(h func(w http.ResponseWriter, r *http.Request, err error)) ServerOption
WithErrorHandler sets the error handler function
func WithNonceGenerator ¶
func WithNonceGenerator(ng dpop.NonceGenerator) ServerOption
WithNonceGenerator sets the nonce generator function
func WithValidationOptions ¶
func WithValidationOptions(opts ...dpop.Option) ServerOption
WithValidationOptions sets the validation options for DPoP proof validation
type Transport ¶
type Transport struct {
// Base is the base RoundTripper used to make HTTP requests.
// If nil, http.DefaultTransport is used.
Base http.RoundTripper
// TokenSource provides the access token for requests.
TokenSource oauth2.TokenSource
// ProofOptions are additional options for DPoP proof generation
ProofOptions []dpop.ProofOption
// contains filtered or unexported fields
}
Transport implements http.RoundTripper and adds DPoP proof headers to requests. It can be composed with other RoundTrippers like oauth2.Transport.
func NewTransport ¶
func NewTransport(base http.RoundTripper, key *jose.JSONWebKey, tokenSource oauth2.TokenSource, opts ...dpop.ProofOption) (*Transport, error)
NewTransport creates a new Transport with the given key and token getter
Click to show internal directories.
Click to hide internal directories.