middleware

package
v1.89.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: AGPL-3.0 Imports: 43 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 AccessLog added in v1.84.0

func AccessLog(log *zap.Logger, p *accesslogs.Processor, config AccessLogConfig) mux.MiddlewareFunc

AccessLog is a middleware function that logs access information for incoming HTTP requests.

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 SerializeAccessLogConfig added in v1.84.0

func SerializeAccessLogConfig(config AccessLogConfig) ([]string, error)

SerializeAccessLogConfig serializes AccessLogConfig into a slice of strings.

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 AccessLogConfig added in v1.84.0

type AccessLogConfig map[WatchedBucket]DestinationLogBucket

AccessLogConfig is a map of WatchedBucket to DestinationLogBucket configuration.

func ParseAccessLogConfig added in v1.84.0

func ParseAccessLogConfig(log *zap.Logger, config []string) (AccessLogConfig, error)

ParseAccessLogConfig parses a slice of strings representing access log configurations.

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 DestinationLogBucket added in v1.84.0

type DestinationLogBucket struct {
	BucketName string
	Storage    accesslogs.Storage
	Prefix     string
}

DestinationLogBucket represents a destination bucket to store logs.

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.

type WatchedBucket added in v1.84.0

type WatchedBucket struct {
	ProjectID  uuid.UUID
	BucketName string
}

WatchedBucket represents a bucket to collect logs from.

Jump to

Keyboard shortcuts

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