jwt

package
v0.0.0-...-c791c95 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRefreshTokenRevoked

func CheckRefreshTokenRevoked(userID uint, iat int64, tokenString string) *errors.ErrorCode

CheckRefreshTokenRevoked checks if a refresh token has been revoked.

func RevokeRefreshToken

func RevokeRefreshToken(userID uint, tokenString string) *errors.ErrorCode

RevokeRefreshToken revokes the refresh token.

func RevokeRefreshTokenAllBefore

func RevokeRefreshTokenAllBefore(userID uint) *errors.ErrorCode

RevokeRefreshTokenAllBefore revokes all refresh token before now.

func Setup

func Setup() error

Setup loads the RSA keys used to sign/verify the JWT signature.

func ValidateToken

func ValidateToken(tokenString string) (*jwt.Token, *errors.ErrorCode)

ValidateToken checks if a token is valid.

Types

type AccessTokenClaims

type AccessTokenClaims struct {
	Iat    int64
	Exp    int64
	UserID uint
	Role   string
}

AccessTokenClaims holds the access token claims details.

func ParseAccessTokenClaims

func ParseAccessTokenClaims(token *jwt.Token) (AccessTokenClaims, *errors.ErrorCode)

ParseAccessTokenClaims parses the access token claims.

func (*AccessTokenClaims) IssueAccessToken

func (atc *AccessTokenClaims) IssueAccessToken() (string, *errors.ErrorCode)

IssueAccessToken issues an access token.

type RefreshTokenClaims

type RefreshTokenClaims struct {
	Iat    int64
	Exp    int64
	UserID uint
}

RefreshTokenClaims holds the refresh token claims details.

func ParseRefreshTokenClaims

func ParseRefreshTokenClaims(token *jwt.Token) (RefreshTokenClaims, *errors.ErrorCode)

ParseRefreshTokenClaims parses the refresh token claims.

func (*RefreshTokenClaims) IssueRefreshToken

func (rtc *RefreshTokenClaims) IssueRefreshToken() (string, *errors.ErrorCode)

IssueRefreshToken issues a refresh token.

Jump to

Keyboard shortcuts

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