permissions

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllowAll  keywordOrigin = "*"
	AllowNone keywordOrigin = "()"
	AllowSelf keywordOrigin = "self"
	AllowSrc  keywordOrigin = "src"
)
View Source
const (
	PolicyTag = "permissions-policy"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AllowList

type AllowList []Origin

func (AllowList) HasAll

func (a AllowList) HasAll() (present bool)

func (AllowList) HasNone

func (a AllowList) HasNone() (present bool)

func (AllowList) IsEmpty

func (a AllowList) IsEmpty() (empty bool)

func (AllowList) Value

func (a AllowList) Value() (value string)

type Directive

type Directive interface {
	DirectiveName() string
	Value() string
}

func NewAccelerometer

func NewAccelerometer(origins ...Origin) Directive

func NewAmbientLightSensor

func NewAmbientLightSensor(origins ...Origin) Directive

func NewAutoplay

func NewAutoplay(origins ...Origin) Directive

func NewBattery

func NewBattery(origins ...Origin) Directive

func NewCamera

func NewCamera(origins ...Origin) Directive

func NewDirective

func NewDirective(name string, allowed ...Origin) (d Directive)

func NewDisplayCapture

func NewDisplayCapture(origins ...Origin) Directive

func NewDocumentDomain

func NewDocumentDomain(origins ...Origin) Directive

func NewEncryptedMedia

func NewEncryptedMedia(origins ...Origin) Directive

func NewExecutionWhileNotRendered

func NewExecutionWhileNotRendered(origins ...Origin) Directive

func NewExecutionWhileOutOfViewport

func NewExecutionWhileOutOfViewport(origins ...Origin) Directive

func NewFullscreen

func NewFullscreen(origins ...Origin) Directive

func NewGamepad

func NewGamepad(origins ...Origin) Directive

func NewGamepadconnected

func NewGamepadconnected(origins ...Origin) Directive

func NewGeolocation

func NewGeolocation(origins ...Origin) Directive

func NewGyroscope

func NewGyroscope(origins ...Origin) Directive

func NewHid

func NewHid(origins ...Origin) Directive

func NewHidden

func NewHidden(origins ...Origin) Directive

func NewIdleDetection

func NewIdleDetection(origins ...Origin) Directive

func NewLocalFonts

func NewLocalFonts(origins ...Origin) Directive

func NewMagnetometer

func NewMagnetometer(origins ...Origin) Directive

func NewMicrophone

func NewMicrophone(origins ...Origin) Directive

func NewMidi

func NewMidi(origins ...Origin) Directive

func NewPayment

func NewPayment(origins ...Origin) Directive

func NewPictureInPicture

func NewPictureInPicture(origins ...Origin) Directive

func NewPublickeyCredentialsGet

func NewPublickeyCredentialsGet(origins ...Origin) Directive

func NewScreenWakeLock

func NewScreenWakeLock(origins ...Origin) Directive

func NewSerial

func NewSerial(origins ...Origin) Directive

func NewSpeakerSelection

func NewSpeakerSelection(origins ...Origin) Directive

func NewUsb

func NewUsb(origins ...Origin) Directive

func NewWebShare

func NewWebShare(origins ...Origin) Directive

func NewXrSpatialTracking

func NewXrSpatialTracking(origins ...Origin) Directive

type ModifyPolicyFn

type ModifyPolicyFn = func(policy Policy, r *http.Request) (modified Policy)

type Origin

type Origin interface {
	OriginType() string
	Value() string
}

func NewSpecificOrigin

func NewSpecificOrigin(uri string) (o Origin)

type Policy

type Policy interface {
	Set(d Directive) Policy

	Get(name string) Directive

	Value() (value string)
}

func NewPolicy

func NewPolicy(directives ...Directive) (policy Policy)

func NoPermissionsPolicy

func NoPermissionsPolicy() Policy

type PolicyHandler

type PolicyHandler struct {
	sync.RWMutex
}

func NewPolicyHandler

func NewPolicyHandler() (h *PolicyHandler)

func (*PolicyHandler) ApplyHeaders

func (h *PolicyHandler) ApplyHeaders(w http.ResponseWriter, r *http.Request)

func (*PolicyHandler) FinalizeRequest

func (h *PolicyHandler) FinalizeRequest(w http.ResponseWriter, r *http.Request)

func (*PolicyHandler) GetRequestPolicy

func (h *PolicyHandler) GetRequestPolicy(r *http.Request) (policy Policy)

func (*PolicyHandler) ModifyPolicyMiddleware

func (h *PolicyHandler) ModifyPolicyMiddleware(fn ModifyPolicyFn) (mw func(next http.Handler) http.Handler)

func (*PolicyHandler) PrepareRequestMiddleware

func (h *PolicyHandler) PrepareRequestMiddleware(next http.Handler) http.Handler

func (*PolicyHandler) SetRequestPolicy

func (h *PolicyHandler) SetRequestPolicy(r *http.Request, policy Policy) (modified *http.Request)

Jump to

Keyboard shortcuts

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