authenticator

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAccessToken

func CreateAccessToken(id int, uid uuid.UUID) (string, error)

func ExtractExpiresAtFromToken added in v0.0.8

func ExtractExpiresAtFromToken(accessToken string) (*jwt.NumericDate, error)

func ExtractExpiresAtFromTokenInString added in v0.0.8

func ExtractExpiresAtFromTokenInString(accessToken string) (string, error)

func ExtractUserIDFromToken

func ExtractUserIDFromToken(accessToken string) (int, uuid.UUID, error)

Types

type AuthClaims

type AuthClaims struct {
	User   int       `json:"user"`
	UUID   uuid.UUID `json:"uuid"`
	Random string    `json:"rnd"`
	jwt.RegisteredClaims
}

type Authenticator

type Authenticator struct {
	Storage *model.Storage
	Cache   *model.Cache
}

func NewAuthenticator

func NewAuthenticator(storage *model.Storage, cache *model.Cache) *Authenticator

func (*Authenticator) DoesAccessTokenExpiredAtAvaliable added in v0.0.8

func (a *Authenticator) DoesAccessTokenExpiredAtAvaliable(user *model.User, accessToken string) (bool, error)

for logout case

func (*Authenticator) JWTAuth

func (a *Authenticator) JWTAuth() gin.HandlerFunc

func (*Authenticator) ManualAuth

func (a *Authenticator) ManualAuth(accessToken string) (bool, error)

func (*Authenticator) ValidateAccessToken

func (a *Authenticator) ValidateAccessToken(accessToken string) (bool, error)

func (*Authenticator) ValidateUser

func (a *Authenticator) ValidateUser(user *model.User, id int, uid uuid.UUID) (bool, error)

Jump to

Keyboard shortcuts

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