dpop_http

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: 6 Imported by: 0

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

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper

Jump to

Keyboard shortcuts

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