x

package
v0.1.1-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2020 License: Apache-2.0 Imports: 23 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyUUID db.UUID
View Source
var (
	ErrInvalidCSRFToken = herodot.ErrForbidden.WithReasonf("A request failed due to a missing or invalid csrf_token value.")
)

Functions

func AssertEqualTime

func AssertEqualTime(t *testing.T, expected, actual time.Time)

func DefaultCSRFToken

func DefaultCSRFToken(r *http.Request) string

func DetermineReturnToURL

func DetermineReturnToURL(request *url.URL, defaultReturnTo *url.URL, whitelistedDomains []url.URL) (string, error)

func EasyCookieJar

func EasyCookieJar(t *testing.T, o *cookiejar.Options) *cookiejar.Jar

func EasyGet

func EasyGet(t *testing.T, c *http.Client, url string) (*http.Response, []byte)

func EasyGetBody

func EasyGetBody(t *testing.T, c *http.Client, url string) []byte

func FakeCSRFTokenGenerator

func FakeCSRFTokenGenerator(r *http.Request) string

func FakeCSRFTokenGeneratorWithToken

func FakeCSRFTokenGeneratorWithToken(token string) func(r *http.Request) string

func IsJSONRequest

func IsJSONRequest(r *http.Request) bool

func IsValidNumber

func IsValidNumber(s string) bool

IsValidNumber reports whether s is a valid JSON number literal.

Taken from encoding/json

func IsZeroUUID

func IsZeroUUID(id db.UUID) bool

func MustEncodeJSON

func MustEncodeJSON(t *testing.T, in interface{}) string

func MustReadAll

func MustReadAll(r io.Reader) []byte

func NewCSRFHandler

func NewCSRFHandler(
	router http.Handler,
	writer herodot.Writer,
	logger logrus.FieldLogger,
	path string,
	domain string,
	secure bool,
) *nosurf.CSRFHandler

func NewTestCSRFHandler

func NewTestCSRFHandler(router http.Handler) *nosurf.CSRFHandler

func NewTestHTTPRequest

func NewTestHTTPRequest(t *testing.T, method, url string, body io.Reader) *http.Request

func NewUUID

func NewUUID() db.UUID

func ParseUUID

func ParseUUID(in string) db.UUID

func RequireEqualTime

func RequireEqualTime(t *testing.T, expected, actual time.Time)

func RequireJSONMarshal

func RequireJSONMarshal(t *testing.T, in interface{}) []byte

func SessionGetString

func SessionGetString(r *http.Request, s sessions.Store, id string, key interface{}) (string, error)

SessionGetString returns a string for the given id and key or an error if the session is invalid, the key does not exist, or the key value is not a string.

func SessionGetStringOr

func SessionGetStringOr(r *http.Request, s sessions.Store, id, key, fallback string) string

SessionGetStringOr returns a string for the given id and key or the fallback value if the session is invalid, the key does not exist, or the key value is not a string.

func SessionPersistValues

func SessionPersistValues(w http.ResponseWriter, r *http.Request, s sessions.Store, id string, values map[string]interface{}) error

SessionPersistValues adds values to the session store and persists the changes.

func TypeMap

func TypeMap(m map[string]string) (map[string]interface{}, error)

func UntypedMapToJSON

func UntypedMapToJSON(m map[string]string) (json.RawMessage, error)

Types

type CSRFProvider

type CSRFProvider interface {
	CSRFHandler() *nosurf.CSRFHandler
}

type CSRFToken

type CSRFToken func(r *http.Request) string

type CSRFTokenGeneratorProvider

type CSRFTokenGeneratorProvider interface {
	GenerateCSRFToken(r *http.Request) string
}

type CookieProvider

type CookieProvider interface {
	CookieManager() sessions.Store
}

type Ider

type Ider interface {
	RequestID() string
}

type LoggingProvider

type LoggingProvider interface {
	Logger() logrus.FieldLogger
}

type RouterAdmin

type RouterAdmin struct {
	*httprouter.Router
}

func NewRouterAdmin

func NewRouterAdmin() *RouterAdmin

type RouterPublic

type RouterPublic struct {
	*httprouter.Router
}

func NewRouterPublic

func NewRouterPublic() *RouterPublic

type WriterProvider

type WriterProvider interface {
	Writer() herodot.Writer
}

Jump to

Keyboard shortcuts

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