Documentation ¶
Index ¶
Constants ¶
const ( // matches the access enum (TOKEN) from the db ACCESS_TOKEN_DB_ENUM = "access" // matches the refresh enum (TOKEN) from the db REFRESH_TOKEN_DB_ENUM = "refresh" )
Variables ¶
This section is empty.
Functions ¶
func GenerateAccessToken ¶
GenerateAccessToken generates an access token. Access tokens have 10 minutes of lifespan. This uses a transaction to insert the generated token in the database so that validation and invalidation can take place.
You must call tx.Commit for the changes to take effect and the token to be valid.
func GenerateRefreshToken ¶
GenerateRefreshToken generates a refresh token. Refresh tokens have 1 week of lifepspan. This uses a transaction to insert the generated token in the database so that validation and invalidation can take place.
You must call tx.Commit for the changes to take effect and the token to be valid.
Types ¶
type JwtClaims ¶
type JwtClaims struct { // UserId for easy identification of the user UserId string `json:"user_id"` // TokenType for a way to differentiate access and refresh tokens TokenType string `json:"token_type"` // jwt.RegisteredClaims are the default normal claims that a jwt should have jwt.RegisteredClaims }
JwtClaims represents the body of jwt tokens generated when a user signins.
func VerifyAccessToken ¶
VerifyAccessToken verifies the given access token.
func VerifyRefreshToken ¶
VerifyRefreshToken verifies the given refresh token.