tokenutil

package
v0.0.0-...-20be120 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorNotFoundInRedis = "invalid token (not found in redis)"
	ErrorInvalidToken    = "invalid token"
	RefreshToken         = "refresh_token"
	AccessToken          = "access_token"
	VerificationEmail    = "verification_email"
	ForgotPassword       = "forgot_password"
	AnonymousRole        = "anonymous"
)

Variables

This section is empty.

Functions

func CreateAccessToken

func CreateAccessToken(user *domain.User, secret string, expiry int, accessTokenUsecase domain.AccessTokenUsecase) (accessToken string, err error)

func CreateForgotToken

func CreateForgotToken(user *domain.User, expiry int, forgotPasswordTokenUsecase domain.ForgotPasswordTokenUsecase) (forgotToken string, err error)

func CreateRefreshToken

func CreateRefreshToken(user *domain.User, secret string, expiry int, accessToken string, refreshTokenUsecase domain.RefreshTokenUsecase) (refreshToken string, err error)

func ExtractDataFromToken

func ExtractDataFromToken(requestToken string, secret string, tokenType string, accessTokenUsecase domain.AccessTokenUsecase, refreshTokenUsecase domain.RefreshTokenUsecase) (domain.TokenData, error)

func ExtractIDFromToken

func ExtractIDFromToken(requestToken string, secret string, tokenType string, accessTokenUsecase domain.AccessTokenUsecase, refreshTokenUsecase domain.RefreshTokenUsecase) (userId string, userRole string, err error)

func IsAuthorized

func IsAuthorized(requestToken string, secret string) (bool, error)

func IsExistTokenInDB

func IsExistTokenInDB(tokenData string, tokenType string, accessTokenUsecase domain.AccessTokenUsecase, refreshTokenUsecase domain.RefreshTokenUsecase) bool

func ParseJWTToken

func ParseJWTToken(requestToken string, secret string) (jwt.MapClaims, error)

func RevokeAll

func RevokeAll(accessToken string, secret string, accessTokenUsecase domain.AccessTokenUsecase, refreshTokenUsecase domain.RefreshTokenUsecase) error

func RevokeToken

func RevokeToken(accessToken string, secret string, accessTokenUsecase domain.AccessTokenUsecase, refreshTokenUsecase domain.RefreshTokenUsecase) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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