TokenService

package
v0.0.0-...-a36a601 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessTokenCache

type AccessTokenCache struct {
	UserID      int    `json:"userId"`
	RefreshUUID string `json:"refreshUuid"`
}

type AccessTokenClaims

type AccessTokenClaims struct {
	AccessUUID string `json:"accessUuid"`
	UserID     int    `json:"userId"`
	Exp        int    `json:"exp"`
	jwt.StandardClaims
}

type RefreshTokenClaims

type RefreshTokenClaims struct {
	RefreshUUID string `json:"refreshUuid"`
	UserID      int    `json:"userId"`
	Exp         int    `json:"exp"`
	jwt.StandardClaims
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(cache *redis.Client) *Service

func (*Service) CreateCacheKey

func (r *Service) CreateCacheKey(userID int, td *TokenDetails) error

CreateCacheKey function that will be used to save the JWTs metadata in Redis

func (*Service) CreateToken

func (r *Service) CreateToken(userid int) (*TokenDetails, error)

CreateToken returns JWT Token

func (*Service) DecodeAccessToken

func (r *Service) DecodeAccessToken(tokenString string) (*AccessTokenClaims, error)

func (*Service) DecodeRefreshToken

func (r *Service) DecodeRefreshToken(tokenString string) (*RefreshTokenClaims, error)

func (*Service) DropCacheKey

func (r *Service) DropCacheKey(UUID string) error

DropCacheKey function that will be used to drop the JWTs metadata from Redis

func (*Service) DropCacheTokens

func (r *Service) DropCacheTokens(accessTokenClaims AccessTokenClaims) error

func (*Service) GetCacheValue

func (r *Service) GetCacheValue(UUID string) (*string, error)

type TokenDetails

type TokenDetails struct {
	AccessToken  string
	RefreshToken string
	AccessUuid   uuid.UUID
	RefreshUuid  uuid.UUID
	AtExpires    int64
	RtExpires    int64
}

TokenDetails is the structure which holds data with JWT tokens

Jump to

Keyboard shortcuts

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