tokens

package
v0.45.11 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTokenByID

func GetTokenByID(tokenID string, cache db.Cacher) (*models.Token, error)

GetTokenByID is a static function to export to other services.

func NewAccessToken

func NewAccessToken(claims UserClaims, secret string) (string, error)

NewAccessToken generates a new signed access token.

func NewRefreshToken

func NewRefreshToken(claims jwt.StandardClaims, secret string) (string, error)

NewRefreshToken generates a new signed refresh token.

func NewToken

func NewToken(user *models.User, r models.TokenRepositoryInterface) ([]string, error)

func NewTokenRepository

func NewTokenRepository(cache db.Cacher) models.TokenRepositoryInterface

func NewTokenService

func NewTokenService(tokenRepository models.TokenRepositoryInterface) models.TokenServiceInterface

func ParseRefreshToken

func ParseRefreshToken(refreshToken string, secret string) *jwt.StandardClaims

ParseRefreshToken decodes the refreshCookie value to get the StandardClaims payload.

Types

type TokenRepository

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

The implementation of pkg/models.TokenRepositoryInterface.

func (*TokenRepository) Delete

func (r *TokenRepository) Delete(tokenID string) error

func (*TokenRepository) GetAll added in v0.45.9

func (r *TokenRepository) GetAll() (*map[string]models.Token, error)

func (*TokenRepository) GetByID

func (r *TokenRepository) GetByID(tokenID string) (*models.Token, error)

func (*TokenRepository) Save

func (r *TokenRepository) Save(token *models.Token) error

type TokenService

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

func (*TokenService) Create

func (s *TokenService) Create(ctx context.Context, user *models.User) ([]string, error)

func (*TokenService) Delete

func (s *TokenService) Delete(ctx context.Context, tokenID string) error

func (*TokenService) FindByID

func (s *TokenService) FindByID(ctx context.Context, tokenID string) (*models.Token, error)

type UserClaims

type UserClaims struct {
	Nickname string `json:"nickname"`
	jwt.StandardClaims
}

UserClaims is a generic structure for a personal user's (access) token.

func ParseAccessToken

func ParseAccessToken(accessToken string, secret string) *UserClaims

ParseAccessToken decodes the accessCookie value to get the UserClaims payload.

Jump to

Keyboard shortcuts

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