rkmidsec

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 5 Imported by: 4

Documentation

Overview

package rkmidsec provide auth related options

Index

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"`
	IgnorePrefix          []string `yaml:"ignorePrefix" json:"ignorePrefix"`
	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

func WithCSPReportOnly(val bool) Option

WithCSPReportOnly provide Content-Security-Policy-Report-Only header value. Optional. Default value false.

func WithContentSecurityPolicy

func WithContentSecurityPolicy(val string) Option

WithContentSecurityPolicy provide Content-Security-Policy header value. Optional. Default value "".

func WithContentTypeNosniff

func WithContentTypeNosniff(val string) Option

WithContentTypeNosniff provide X-Content-Type-Options header value. Optional. Default value "nosniff".

func WithEntryNameAndType

func WithEntryNameAndType(entryName, entryType string) Option

WithEntryNameAndType provide entry name and entry type.

func WithHSTSExcludeSubdomains

func WithHSTSExcludeSubdomains(val bool) Option

WithHSTSExcludeSubdomains provide excluding subdomains of HSTS.

func WithHSTSMaxAge

func WithHSTSMaxAge(val int) Option

WithHSTSMaxAge provide Strict-Transport-Security header value.

func WithHSTSPreloadEnabled

func WithHSTSPreloadEnabled(val bool) Option

WithHSTSPreloadEnabled provide enabling HSTS preload. Optional. Default value false.

func WithIgnorePrefix

func WithIgnorePrefix(paths ...string) Option

WithIgnorePrefix provide paths prefix that will ignore. Mainly used for swagger main page and RK TV entry.

func WithMockOptionSet

func WithMockOptionSet(mock OptionSetInterface) Option

WithMockOptionSet provide mock OptionSetInterface

func WithReferrerPolicy

func WithReferrerPolicy(val string) Option

WithReferrerPolicy provide Referrer-Policy header value. Optional. Default value "".

func WithXFrameOptions

func WithXFrameOptions(val string) Option

WithXFrameOptions provide X-Frame-Options header value. Optional. Default value "SAMEORIGIN".

func WithXSSProtection

func WithXSSProtection(val string) Option

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
}

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

Jump to

Keyboard shortcuts

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