Documentation
¶
Index ¶
- func ExtractJWT(r *http.Request) (*jwt.Token, error)
- func GenerateJWT() *jwt.Token
- func GenerateRandomBytes() []byte
- func GenerateSecret()
- func GetSecret() []byte
- func GetSignedString(token *jwt.Token) (string, error)
- func IsJWTValid(token *jwt.Token, tokenError error) error
- func IsOriginAllowed(origin string) bool
- func ReadFile(filepath string) ([]byte, error)
- func SetHeader(w http.ResponseWriter, r *http.Request)
- func SetSecret(b []byte)
- func StringInSlice(a string, list []string) bool
- func WriteFile(filepath string, buf []byte, perm os.FileMode) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractJWT ¶
ExtractJWT parses the http.Request and extract the JWT from it. It also check that the token signature is correct.
func GenerateJWT ¶
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 IsJWTValid ¶
IsJWTValid checks that the token is a well formed and not expired JWT
func IsOriginAllowed ¶
IsOriginAllowed returns True if the current Origin is one of the allowed one
func ReadFile ¶
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 ¶
Types ¶
This section is empty.