security

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidContentType is an error that indicates invalid content type.
	ErrInvalidContentType = errors.New("invalid content type")
	// ErrInvalidHeader is an error that indicates invalid X-Content-Security header.
	ErrInvalidHeader = errors.New("invalid X-Content-Security header")
	// ErrInvalidKey is an error that indicates invalid key.
	ErrInvalidKey = errors.New("invalid key")
	// ErrInvalidPublicKey is an error that indicates invalid public key.
	ErrInvalidPublicKey = errors.New("invalid public key")
	// ErrInvalidSecret is an error that indicates invalid secret.
	ErrInvalidSecret = errors.New("invalid secret")
)

Functions

func VerifySignature

func VerifySignature(r *http.Request, securityHeader *ContentSecurityHeader, tolerance time.Duration) int

VerifySignature verifies the signature in given r.

Types

type ContentSecurityHeader

type ContentSecurityHeader struct {
	Key         []byte
	Timestamp   string
	ContentType int
	Signature   string
}

A ContentSecurityHeader is a content security header.

func ParseContentSecurity

func ParseContentSecurity(decrypters map[string]codec.RsaDecrypter, r *http.Request) (
	*ContentSecurityHeader, error)

ParseContentSecurity parses content security settings in give r.

func (*ContentSecurityHeader) Encrypted

func (h *ContentSecurityHeader) Encrypted() bool

Encrypted checks if it's a crypted request.

type WithCodeResponseWriter

type WithCodeResponseWriter struct {
	Writer http.ResponseWriter
	Code   int
}

A WithCodeResponseWriter is a helper to delay sealing a http.ResponseWriter on writing code.

func (*WithCodeResponseWriter) Flush

func (w *WithCodeResponseWriter) Flush()

Flush flushes the response writer.

func (*WithCodeResponseWriter) Header

func (w *WithCodeResponseWriter) Header() http.Header

Header returns the http header.

func (*WithCodeResponseWriter) Write

func (w *WithCodeResponseWriter) Write(bytes []byte) (int, error)

Write writes bytes into w.

func (*WithCodeResponseWriter) WriteHeader

func (w *WithCodeResponseWriter) WriteHeader(code int)

WriteHeader writes code into w, and not sealing the writer.

Jump to

Keyboard shortcuts

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