Documentation ¶
Index ¶
- type Instance
- func (instance Instance) CalculateExpirationTime() *jwt.NumericDate
- func (instance Instance) GenerateToken(_ context.Context, userID uint) (string, error)
- func (instance Instance) GetConnectedUserID(ctx context.Context, tokenHeader string) (uint, error)
- func (Instance) GetExpirationTime(token *jwt.Token) int64
- func (instance Instance) GetToken(_ context.Context, token string) (*jwt.Token, error)
- func (Instance) VerifyToken(token *jwt.Token) (uint, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Instance ¶
type Instance struct { ExpirationTimeInHours int // contains filtered or unexported fields }
func NewJWTInstance ¶
func NewJWTInstance(headerLen, expirationTime int, publicKey ed25519.PublicKey, privateKey ed25519.PrivateKey, ) Instance
NewJWTInstance return a new JwtInstance with the given parameters.
func (Instance) CalculateExpirationTime ¶
func (instance Instance) CalculateExpirationTime() *jwt.NumericDate
CalculateExpirationTime returns the expiration time.
func (Instance) GenerateToken ¶
GenerateToken generates a jwt token from a user id and returns the token and an error
It's signing method is defined in utils.JwtSigningMethod It's expiration time is defined in utils.GetExpirationTime It's secret key is defined in the environment variable SECRET_KEY see: utils/config.go for more information
func (Instance) GetConnectedUserID ¶
GetConnectedUserID gets the user id from a jwt token.
func (Instance) GetExpirationTime ¶
func (Instance) GetToken ¶
GetToken gets a jwt.Token token from a string and returns the jwt.Token and an error.
func (Instance) VerifyToken ¶
VerifyToken verifies a jwt token and returns the user id and an error.