secheaders

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyXFrameOptions       = "security_x_frame_options"
	KeyHSTSMaxAge          = "security_hsts_max_age_seconds"
	KeyHSTSIncludeSubs     = "security_hsts_include_subdomains"
	KeyHSTSPreload         = "security_hsts_preload"
	KeyHSTSDisabled        = "security_hsts_disabled"
	KeyCSP                 = "security_csp"
	KeyCSPExtra            = "security_csp_extra"
	KeyXContentTypeOptions = "security_x_content_type_options"
	KeyReferrerPolicy      = "security_referrer_policy"
	KeyPermissionsPolicy   = "security_permissions_policy"
	KeyCORSOrigins         = "security_cors_allowed_origins"
)

Variables

This section is empty.

Functions

func MergeOrigins

func MergeOrigins(lists ...[]string) []string

func Nonce

func Nonce(r *http.Request) string

func RequestIsHTTPS

func RequestIsHTTPS(r *http.Request) bool

Types

type CSP

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

func NewCSP

func NewCSP() *CSP

func ParseCSP

func ParseCSP(s string) *CSP

func (*CSP) Add

func (c *CSP) Add(directive string, sources ...string) *CSP

func (*CSP) Clone

func (c *CSP) Clone() *CSP

func (*CSP) Has

func (c *CSP) Has(directive string) bool

func (*CSP) Remove

func (c *CSP) Remove(directive string) *CSP

func (*CSP) Set

func (c *CSP) Set(directive string, sources ...string) *CSP

func (*CSP) Sources

func (c *CSP) Sources(directive string) []string

func (*CSP) String

func (c *CSP) String() string

type Config

type Config struct {
	XFrameOptions         string
	HSTSMaxAgeSeconds     int
	HSTSIncludeSubDomains bool
	HSTSPreload           bool
	HSTSDisabled          bool
	CSP                   *CSP
	XContentTypeOptions   string
	ReferrerPolicy        string
	PermissionsPolicy     string
	CORSAllowedOrigins    []string
	CORSAllowedHeaders    []string
	StyleNonce            bool
	NoStoreCacheControl   string
	StaticPrefixes        []string
	StaticPaths           []string
	StaticCacheControl    string
	LegacyHeaders         bool
	PerRequest            func(r *http.Request, rq *Request)
}

func Defaults

func Defaults() *Config

func (*Config) ApplySettings

func (c *Config) ApplySettings(get Settings)

func (*Config) CORS

func (c *Config) CORS(next http.Handler) http.Handler

func (*Config) Middleware

func (c *Config) Middleware(next http.Handler) http.Handler

type Request

type Request struct {
	CSP              *CSP
	OmitFrameOptions bool
	CacheControl     string
	Headers          map[string]string
}

type Settings

type Settings func(key string) string

Jump to

Keyboard shortcuts

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