middleware

package
v1.77.0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ParseV2FromHeaderError = errs.Class("header")

ParseV2FromHeaderError is the default error class for V2 parsing header errors.

View Source
var ParseV2FromMPartError = errs.Class("V2 multipart form")

ParseV2FromMPartError is the default error class for V2 parsing multipart form errors.

View Source
var ParseV2FromQueryError = errs.Class("query")

ParseV2FromQueryError is the default error class for V2 parsing query errors.

View Source
var ParseV4CredentialError = errs.Class("credential")

ParseV4CredentialError is the default error class for V4 parsing credential errors.

View Source
var ParseV4FromHeaderError = errs.Class("header")

ParseV4FromHeaderError is the default error class for V4 parsing header errors.

View Source
var ParseV4FromMPartError = errs.Class("V4 multipart form")

ParseV4FromMPartError is the default error class for V4 parsing multipart form errors.

View Source
var ParseV4FromQueryError = errs.Class("query")

ParseV4FromQueryError is the default error class for V4 parsing query errors.

Functions

func AccessKey

func AccessKey(authClient *authclient.AuthClient, trustedIPs trustedip.List, log *zap.Logger) mux.MiddlewareFunc

AccessKey implements mux.Middlware and saves the accesskey to context.

func CollectEvent

func CollectEvent(h http.Handler) http.Handler

CollectEvent collects event data to send to eventkit.

func GetAccessKeyID

func GetAccessKeyID(r *http.Request) (string, error)

GetAccessKeyID returns the access key ID from the request and a signature validator.

func LogRequests

func LogRequests(log *zap.Logger, h http.Handler, insecureLogPaths bool) http.Handler

LogRequests logs requests.

func LogResponses

func LogResponses(log *zap.Logger, h http.Handler, insecureLogAll bool) http.Handler

LogResponses logs responses.

func Metrics

func Metrics(prefix string, next http.Handler) http.Handler

Metrics sends a bunch of useful metrics using monkit: - response time - time to write header - bytes written partitioned by method, status code, API.

It also sends unmapped errors (in the case of Gateway-MT) through eventkit.

TODO(artur): calculate approximate request size.

func MonitorMinioGlobalHandler

func MonitorMinioGlobalHandler(i int, f mux.MiddlewareFunc) mux.MiddlewareFunc

MonitorMinioGlobalHandler adds monkit metrics atop minio middlewares.

func NewLogRequests

func NewLogRequests(log *zap.Logger, insecureLogPaths bool) mux.MiddlewareFunc

NewLogRequests is a convenience wrapper around LogRequests that returns LogRequests as mux.MiddlewareFunc.

func NewLogResponses

func NewLogResponses(log *zap.Logger, insecureLogPaths bool) mux.MiddlewareFunc

NewLogResponses is a convenience wrapper around LogResponses that returns LogResponses as mux.MiddlewareFunc.

func NewMetrics

func NewMetrics(prefix string) mux.MiddlewareFunc

NewMetrics is a convenience wrapper around Metrics that returns Metrics with prefix as mux.MiddlewareFunc.

func ParseFromForm

func ParseFromForm(r *http.Request) (string, error)

ParseFromForm parses V2 or V4 credentials from multipart form credentials.

func SetInMemory

func SetInMemory(next http.Handler) http.Handler

SetInMemory sets appropriate context value for every request with information for uplink to perform in-memory segment encoding while uploading a file.

Types

type BodyCache

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

BodyCache wraps a ReadCloser to allow seeking the first N bytes.

func NewBodyCache

func NewBodyCache(stream io.ReadCloser, bufferSize int64) (*BodyCache, error)

NewBodyCache return a ReadCloser than can Seek the first bufferSize bytes.

func (*BodyCache) Close

func (r *BodyCache) Close() error

Close closes the underlying stream.

func (*BodyCache) Read

func (r *BodyCache) Read(b []byte) (n int, err error)

Read implements the io.Reader interface.

func (*BodyCache) Seek

func (r *BodyCache) Seek(offset int64, whence int) (int64, error)

Seek implements the io.Seeker interface.

type Credentials

type Credentials struct {
	AccessKey string
	authclient.AuthServiceResponse
	Error error
}

Credentials contains an AccessKey, SecretKey, AccessGrant, and IsPublic flag.

func GetAccess

func GetAccess(ctx context.Context) *Credentials

GetAccess returns the credentials.

type Limiter

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

Limiter imposes a limit per key.

func NewLimiter

func NewLimiter(allowed uint, keyFunc func(*http.Request) (string, error), limitFunc func(w http.ResponseWriter, r *http.Request)) *Limiter

NewLimiter constructs a concurrency Limiter. Error and Limit functions are user defined in part because referencing the "minio" package here would cause an import loop.

func NewMacaroonLimiter

func NewMacaroonLimiter(allowed uint, limitFunc func(w http.ResponseWriter, r *http.Request)) *Limiter

NewMacaroonLimiter constructs a Limiter that limits based on macaroon credentials. It relies on the AccessKey middleware being run to append credentials to the request context.

func (*Limiter) Limit

func (l *Limiter) Limit(next http.Handler) http.Handler

Limit applies per-key request concurrency limiting as an HTTP middleware.

type V2

type V2 struct {
	AccessKeyID string
	Signature   string
	Expires     time.Time

	FromHeader bool
}

V2 represents S3 V2 all security related data.

func ParseV2FromFormValues

func ParseV2FromFormValues(formValues http.Header) (_ *V2, err error)

ParseV2FromFormValues parses a V2 signature from the multipart form parameters.

func ParseV2FromHeader

func ParseV2FromHeader(r *http.Request) (_ *V2, err error)

ParseV2FromHeader parses a V2 signature from the request headers.

func ParseV2FromQuery

func ParseV2FromQuery(r *http.Request) (_ *V2, err error)

ParseV2FromQuery parses a V2 signature from the query parameters.

type V4

type V4 struct {
	Credential    *V4Credential
	SignedHeaders []string
	Signature     string

	ContentSHA256 string
	Date          time.Time

	FromHeader bool
}

V4 represents S3 V4 all security related data.

func ParseV4FromFormValues

func ParseV4FromFormValues(formValues http.Header) (_ *V4, err error)

ParseV4FromFormValues parses a V4 signature from the multipart form parameters.

func ParseV4FromHeader

func ParseV4FromHeader(r *http.Request) (_ *V4, err error)

ParseV4FromHeader parses a V4 signature from the request headers.

func ParseV4FromQuery

func ParseV4FromQuery(r *http.Request) (_ *V4, err error)

ParseV4FromQuery parses a V4 signature from the query parameters.

type V4Credential

type V4Credential struct {
	AccessKeyID string
	Date        time.Time
	Region      string
	Service     string
}

V4Credential represents S3 V4 protocol credentials.

func ParseV4Credential

func ParseV4Credential(data string) (*V4Credential, error)

ParseV4Credential parses the credential into it's parts.

Jump to

Keyboard shortcuts

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