middleware

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheabilityNotSet  Cacheability = ""
	CacheabilityPublic               = "public"
	CacheabilityPrivate              = "private"
)
View Source
const (
	RevalidationNotSet Revalidation = ""
	RevalidationMust                = "must-revalidate"
	RevalidationProxy               = "proxy-revalidate"
)
View Source
const (
	DefaultNonceLength = uint(32)
)

Variables

View Source
var (
	NeverCacheOptions = &Cache{
		NoStore: true,
	}
	AssetOptions = func(maxAge, SharedMaxAge time.Duration) *Cache {
		return &Cache{
			Cacheability: CacheabilityPublic,
			MaxAge:       maxAge,
			SharedMaxAge: SharedMaxAge,
		}
	}
)
View Source
var (
	DefaultSCP = CSP{
		DefaultSrc:  CSPSourceOptsNone(),
		ScriptSrc:   CSPSourceOptsSelf(),
		ObjectSrc:   CSPSourceOptsNone(),
		StyleSrc:    CSPSourceOptsSelf(),
		ImgSrc:      CSPSourceOptsSelf(),
		MediaSrc:    CSPSourceOptsNone(),
		FrameSrc:    CSPSourceOptsNone(),
		FontSrc:     CSPSourceOptsSelf(),
		ManifestSrc: CSPSourceOptsSelf(),
		ConnectSrc:  CSPSourceOptsSelf(),
	}
)

Functions

func AssetsCacheInterceptor added in v0.29.1

func AssetsCacheInterceptor(maxAge, sharedMaxAge time.Duration, h http.Handler) http.Handler

func CORSInterceptor

func CORSInterceptor(h http.Handler) http.Handler

func CORSInterceptorOpts

func CORSInterceptorOpts(opts cors.Options, h http.Handler) http.Handler

func CacheInterceptorOpts added in v0.29.1

func CacheInterceptorOpts(h http.Handler, cache *Cache) http.Handler

func DefaultCacheInterceptor added in v0.29.1

func DefaultCacheInterceptor(pattern string, maxAge, sharedMaxAge time.Duration) (func(http.Handler) http.Handler, error)

func DefaultMetricsHandler added in v0.107.0

func DefaultMetricsHandler(handler http.Handler) http.Handler

func DefaultTelemetryHandler added in v0.107.0

func DefaultTelemetryHandler(handler http.Handler) http.Handler

func GetNonce added in v0.29.1

func GetNonce(r *http.Request) string

func MetricsHandler added in v0.107.0

func MetricsHandler(metricTypes []metrics.MetricType, ignoredMethods ...string) func(http.Handler) http.Handler

func NewUserAgentHandler added in v0.80.2

func NewUserAgentHandler(config *UserAgentCookieConfig, idGenerator id.Generator, localDevMode bool) (func(http.Handler) http.Handler, error)

func NoCacheInterceptor added in v0.29.1

func NoCacheInterceptor(h http.Handler) http.Handler

func SecurityHeaders added in v0.29.1

func SecurityHeaders(csp *CSP, errorHandler func(error) http.Handler, nonceLength ...uint) func(http.Handler) http.Handler

func TelemetryHandler added in v0.107.0

func TelemetryHandler(ignoredMethods ...string) func(http.Handler) http.Handler

func UserAgentIDFromCtx added in v0.80.2

func UserAgentIDFromCtx(ctx context.Context) (string, bool)

Types

type AuthInterceptor added in v1.12.0

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

func AuthorizationInterceptor added in v1.12.0

func AuthorizationInterceptor(verifier *authz.TokenVerifier, authConfig authz.Config) *AuthInterceptor

func (*AuthInterceptor) Handler added in v1.12.0

func (a *AuthInterceptor) Handler(next http.Handler) http.Handler

func (*AuthInterceptor) HandlerFunc added in v1.12.0

func (a *AuthInterceptor) HandlerFunc(next http.HandlerFunc) http.HandlerFunc

type CSP added in v0.29.1

type CSP struct {
	DefaultSrc  CSPSourceOptions
	ScriptSrc   CSPSourceOptions
	ObjectSrc   CSPSourceOptions
	StyleSrc    CSPSourceOptions
	ImgSrc      CSPSourceOptions
	MediaSrc    CSPSourceOptions
	FrameSrc    CSPSourceOptions
	FontSrc     CSPSourceOptions
	ManifestSrc CSPSourceOptions
	ConnectSrc  CSPSourceOptions
	FormAction  CSPSourceOptions
}

func (*CSP) Value added in v0.29.1

func (csp *CSP) Value(nonce string) string

type CSPSourceOptions added in v0.29.1

type CSPSourceOptions []string

func CSPSourceOpts added in v0.29.1

func CSPSourceOpts() CSPSourceOptions

func CSPSourceOptsNone added in v0.29.1

func CSPSourceOptsNone() CSPSourceOptions

func CSPSourceOptsSelf added in v0.29.1

func CSPSourceOptsSelf() CSPSourceOptions

func (CSPSourceOptions) AddEval added in v0.29.1

func (srcOpts CSPSourceOptions) AddEval() CSPSourceOptions

func (CSPSourceOptions) AddHash added in v0.29.1

func (srcOpts CSPSourceOptions) AddHash(alg, b64v string) CSPSourceOptions

func (CSPSourceOptions) AddHost added in v0.29.1

func (srcOpts CSPSourceOptions) AddHost(h ...string) CSPSourceOptions

func (CSPSourceOptions) AddInline added in v0.29.1

func (srcOpts CSPSourceOptions) AddInline() CSPSourceOptions

func (CSPSourceOptions) AddNonce added in v0.29.1

func (srcOpts CSPSourceOptions) AddNonce() CSPSourceOptions

func (CSPSourceOptions) AddScheme added in v0.29.1

func (srcOpts CSPSourceOptions) AddScheme(s ...string) CSPSourceOptions

func (CSPSourceOptions) AddSelf added in v0.29.1

func (srcOpts CSPSourceOptions) AddSelf() CSPSourceOptions

func (CSPSourceOptions) AddStrictDynamic added in v0.29.1

func (srcOpts CSPSourceOptions) AddStrictDynamic() CSPSourceOptions

func (CSPSourceOptions) String added in v0.29.1

func (srcOpts CSPSourceOptions) String(nonce string) string

type Cache added in v0.29.1

type Cache struct {
	Cacheability Cacheability
	NoCache      bool
	NoStore      bool
	MaxAge       time.Duration
	SharedMaxAge time.Duration
	NoTransform  bool
	Revalidation Revalidation
}

type CacheConfig added in v0.29.1

type CacheConfig struct {
	MaxAge       types.Duration
	SharedMaxAge types.Duration
}

type Cacheability added in v0.29.1

type Cacheability string

type Revalidation added in v0.29.1

type Revalidation string

type UserAgent added in v0.80.2

type UserAgent struct {
	ID string
}

type UserAgentCookieConfig added in v0.80.2

type UserAgentCookieConfig struct {
	Name   string
	Domain string
	Key    *crypto.KeyConfig
	MaxAge types.Duration
}

Jump to

Keyboard shortcuts

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