helper

package
v0.0.0-...-bf7a4f5 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2019 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractJWT

func ExtractJWT(r *http.Request) (*jwt.Token, error)

ExtractJWT parses the http.Request and extract the JWT from it. It also check that the token signature is correct.

func GenerateJWT

func GenerateJWT() *jwt.Token

func GenerateRandomBytes

func GenerateRandomBytes() []byte

GenerateRandomBytes generated a []byte containing n secure random numbers

func GenerateSecret

func GenerateSecret()

GenerateSecret sets the secret by generating a new one The secret can only be set once...

func GetSecret

func GetSecret() []byte

GetSecret returns the secret that should be used for signing JWT

func GetSignedString

func GetSignedString(token *jwt.Token) (string, error)

func IsJWTValid

func IsJWTValid(token *jwt.Token, tokenError error) error

IsJWTValid checks that the token is a well formed and not expired JWT

func IsOriginAllowed

func IsOriginAllowed(origin string) bool

IsOriginAllowed returns True if the current Origin is one of the allowed one

func ReadFile

func ReadFile(filepath string) ([]byte, error)

ReadFile reads the file indicated by filepath and return the corresponding array of bytes

func SetHeader

func SetHeader(w http.ResponseWriter, r *http.Request)

SetHeader adds to the header the 'good' value for CORS

func SetSecret

func SetSecret(b []byte)

SetSecret sets the secret given b an array of bytes read from a file for example

func StringInSlice

func StringInSlice(a string, list []string) bool

func WriteFile

func WriteFile(filepath string, buf []byte, perm os.FileMode) (bool, error)

WriteFile writes buf to a file whose path is indicated by filepath.

Types

This section is empty.

Jump to

Keyboard shortcuts

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