Documentation ¶
Index ¶
Constants ¶
const JWTAccessKey = "JWT_ACCESS_KEY"
JWTAccessKey ust be set in .env
const JWTAuthCodeKey = "JWT_AUTHORIZATION_CODE_KEY"
JWTAuthCodeKey must be set in .env
const JWTRefreshKey = "JWT_REFRESH_KEY"
JWTRefreshKey must be set in .env
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
CheckPasswordHash checks hash of password
func ExtractToken ¶
ExtractToken extracts token from Bearer
func HashPassword ¶
HashPassword hashes password with bcrypt
func IsEmailValid ¶
IsEmailValid checks if the email provided passes the required structure and length.
Types ¶
type TokenClaims ¶
type TokenClaims struct {
jwt.StandardClaims
}
TokenClaims is claims for jwt token
type TokenDetails ¶
type TokenDetails struct { Token *jwt.Token Claims TokenClaims }
TokenDetails combines token string and claims
func CreateAccessToken ¶
func CreateAccessToken() (*TokenDetails, error)
CreateAccessToken creates acces token and returns it
func CreateAuthorizationCode ¶
func CreateAuthorizationCode(userID primitive.ObjectID) (*TokenDetails, error)
CreateAuthorizationCode creates authorization code
func CreateRefreshToken ¶
func CreateRefreshToken() (*TokenDetails, error)
CreateRefreshToken creates acces token and returns it
func VerifyToken ¶
func VerifyToken(strtoken string, secretEnv string) (*TokenDetails, error)
VerifyToken verifyes jwt token, secretEnv must be some enviroent variable
type TokenPair ¶
type TokenPair struct { AccessToken TokenDetails RefreshToken TokenDetails }
TokenPair combins both access token and refresh token
func CreateTokenPair ¶
CreateTokenPair creates accessToken and refreshToken