Documentation ¶
Index ¶
- func GenerateJWT(user model.User, config GenerateJWTConfig) (string, error)
- func JWTClaimsFieldValueByName(claims jwt.Claims, fieldName string) (interface{}, error)
- func ParseJWTStringIntoUser(jwtStr string, signingKey interface{}) (model.User, error)
- func RefreshJWT(w http.ResponseWriter, r *http.Request, jwtConfig GenerateJWTConfig) error
- type GenerateJWTConfig
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 ¶
JWTClaimsFieldValueByName returns field value from the jwt claims by its name.
func ParseJWTStringIntoUser ¶
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.
Click to show internal directories.
Click to hide internal directories.