Documentation
¶
Overview ¶
Package rkmidsec provide auth related options
Index ¶
- type BeforeCtx
- type BootConfig
- type Option
- func ToOptions(config *BootConfig, entryName, entryType string) []Option
- func WithCSPReportOnly(val bool) Option
- func WithContentSecurityPolicy(val string) Option
- func WithContentTypeNosniff(val string) Option
- func WithEntryNameAndType(entryName, entryType string) Option
- func WithHSTSExcludeSubdomains(val bool) Option
- func WithHSTSMaxAge(val int) Option
- func WithHSTSPreloadEnabled(val bool) Option
- func WithMockOptionSet(mock OptionSetInterface) Option
- func WithPathToIgnore(paths ...string) Option
- func WithReferrerPolicy(val string) Option
- func WithXFrameOptions(val string) Option
- func WithXSSProtection(val string) Option
- type OptionSetInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeforeCtx ¶
type BeforeCtx struct { Input struct { UrlPath string // contains filtered or unexported fields } Output struct { HeadersToReturn map[string]string } }
BeforeCtx context for Before() function
func NewBeforeCtx ¶
func NewBeforeCtx() *BeforeCtx
NewBeforeCtx create new BeforeCtx with fields initialized
type BootConfig ¶
type BootConfig struct { Enabled bool `yaml:"enabled" json:"enabled"` Ignore []string `yaml:"ignore" json:"ignore"` XssProtection string `yaml:"xssProtection" json:"xssProtection"` ContentTypeNosniff string `yaml:"contentTypeNosniff" json:"contentTypeNosniff"` XFrameOptions string `yaml:"xFrameOptions" json:"xFrameOptions"` HstsMaxAge int `yaml:"hstsMaxAge" json:"hstsMaxAge"` HstsExcludeSubdomains bool `yaml:"hstsExcludeSubdomains" json:"hstsExcludeSubdomains"` HstsPreloadEnabled bool `yaml:"hstsPreloadEnabled" json:"hstsPreloadEnabled"` ContentSecurityPolicy string `yaml:"contentSecurityPolicy" json:"contentSecurityPolicy"` CspReportOnly bool `yaml:"cspReportOnly" json:"cspReportOnly"` ReferrerPolicy string `yaml:"referrerPolicy" json:"referrerPolicy"` }
BootConfig for YAML
type Option ¶
type Option func(*optionSet)
Option
func ToOptions ¶
func ToOptions(config *BootConfig, entryName, entryType string) []Option
ToOptions convert BootConfig into Option list
func WithCSPReportOnly ¶
WithCSPReportOnly provide Content-Security-Policy-Report-Only header value. Optional. Default value false.
func WithContentSecurityPolicy ¶
WithContentSecurityPolicy provide Content-Security-Policy header value. Optional. Default value "".
func WithContentTypeNosniff ¶
WithContentTypeNosniff provide X-Content-Type-Options header value. Optional. Default value "nosniff".
func WithEntryNameAndType ¶
WithEntryNameAndType provide entry name and entry type.
func WithHSTSExcludeSubdomains ¶
WithHSTSExcludeSubdomains provide excluding subdomains of HSTS.
func WithHSTSMaxAge ¶
WithHSTSMaxAge provide Strict-Transport-Security header value.
func WithHSTSPreloadEnabled ¶
WithHSTSPreloadEnabled provide enabling HSTS preload. Optional. Default value false.
func WithMockOptionSet ¶
func WithMockOptionSet(mock OptionSetInterface) Option
WithMockOptionSet provide mock OptionSetInterface
func WithPathToIgnore ¶
WithPathToIgnore provide paths prefix that will ignore.
func WithReferrerPolicy ¶
WithReferrerPolicy provide Referrer-Policy header value. Optional. Default value "".
func WithXFrameOptions ¶
WithXFrameOptions provide X-Frame-Options header value. Optional. Default value "SAMEORIGIN".
func WithXSSProtection ¶
WithXSSProtection provide X-XSS-Protection header value. Optional. Default value "1; mode=block".
type OptionSetInterface ¶
type OptionSetInterface interface { GetEntryName() string GetEntryType() string Before(*BeforeCtx) BeforeCtx(*http.Request) *BeforeCtx ShouldIgnore(string) bool }
OptionSetInterface mainly for testing purpose
func NewOptionSet ¶
func NewOptionSet(opts ...Option) OptionSetInterface
NewOptionSet Create new optionSet with options.
func NewOptionSetMock ¶
func NewOptionSetMock(before *BeforeCtx) OptionSetInterface
NewOptionSetMock for testing purpose