security

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateJWT

func GenerateJWT(user model.User, config GenerateJWTConfig) (string, error)

GenerateJWT returns token string that was created from user data and given expire time in Unix seconds. Uses defaultSigningKey if not provided.

func JWTClaimsFieldValueByName

func JWTClaimsFieldValueByName(claims jwt.Claims, fieldName string) (interface{}, error)

JWTClaimsFieldValueByName returns field value from the jwt claims by its name.

func ParseJWTStringIntoUser

func ParseJWTStringIntoUser(jwtStr string, signingKey interface{}) (model.User, error)

ParseJWTStringIntoUser extracts data from raw JWT string and returns it as a User model. Uses defaultSigningKey if not provided.

func RefreshJWT

func RefreshJWT(w http.ResponseWriter, r *http.Request, jwtConfig GenerateJWTConfig) error

RefreshJWT refreshes token with the given constraints from config.

Types

type GenerateJWTConfig

type GenerateJWTConfig struct {
	ExpireTime int64
	SigningKey interface{}
}

GenerateJWTConfig holds variables for generating new jwt token.

Jump to

Keyboard shortcuts

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