secure_headers

package
v0.0.0-...-143550a Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2015 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package secure_headers decorates an http.Handler and sets several key security headers

Index

Examples

Constants

This section is empty.

Variables

View Source
var DefaultSettings = Settings{
	CspOpts:                      csp.Opts{},
	ReportOpts:                   csp.Opts{},
	FrameOptions:                 "SAMEORIGIN",
	StrictTransportSecurity:      "max-age=31536000; includeSubDomains",
	ContentTypeOptions:           "nosniff",
	XSSProtection:                "1; mode=block",
	PermittedCrossDomainPolicies: "master-only",
}

Sane/safe defaults for the secure headers decorator. Content-Security-Policy is disabled by default as it is very restrictive.

Functions

func Decorate

func Decorate(settings Settings, delegate http.Handler) http.Handler
Example
var h http.Handler
h = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})
h = Decorate(DefaultSettings, h) // Responses from h now include default security headers

Types

type Settings

type Settings struct {
	CspOpts    csp.Opts // Content-Security-Policy
	ReportOpts csp.Opts // Content-Security-Policy-Report-Only

	// Where can this site be embedded as an iframe
	FrameOptions string
	// Should user agents default to SSL
	StrictTransportSecurity string
	// Should IE guess mime types
	ContentTypeOptions string
	// Should IE run code that 'looks like' an XSS
	XSSProtection string
	// Specify which cross-domain policies flash can load
	PermittedCrossDomainPolicies string
}

Settings configures the headers a secure handler will add to a ResponseWriter

Directories

Path Synopsis
package csp implements a content-security-policy header generator
package csp implements a content-security-policy header generator

Jump to

Keyboard shortcuts

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