Documentation ¶
Index ¶
- Constants
- type Claims
- type GinMiddleware
- type JWT
- type JWTToken
- func (t *JWTToken) DeleteRefreshToken(ctx context.Context, sub, jti string) (err error)
- func (t *JWTToken) GenerateToken(ctx context.Context, userID string, sub string) (accessToken, refreshToken, csrfSecret string, expiresAt int64, err error)
- func (t *JWTToken) RenewToken(ctx context.Context, oldAccessTokenString string, ...) (newAuthTokenString, newRefreshTokenString, newCsrfSecret string, ...)
- func (t *JWTToken) VerifyToken(authToken string) (*Claims, error)
- type RedisRepository
- func (r RedisRepository) DeleteRefreshToken(ctx context.Context, jti string) error
- func (r RedisRepository) FindAllRefreshTokens(ctx context.Context) ([]RefreshToken, error)
- func (r RedisRepository) FindRefreshToken(ctx context.Context, jti string) (sub string, err error)
- func (r RedisRepository) StoreRefreshToken(ctx context.Context, sub, jti string) error
- type RefreshToken
- type RefreshTokenClaims
- type Repository
Constants ¶
View Source
const ( ErrExpiredToken apperror.ErrorType = "ER0002 the token is expired" ErrTokenAlreadyRefreshed apperror.ErrorType = "ER0003 the token is already refreshed" ErrRefreshTokenNotFoundInDatabase apperror.ErrorType = "ER0004 refresh token not found in database" ErrReadingJWTClaims apperror.ErrorType = "ER0005 error reading jwt claims" ErrFetchingJWTClaims apperror.ErrorType = "ER0006 error fetching claims" ErrParsingRefreshTokenWithClaims apperror.ErrorType = "ER0007 could not parse refresh token with claims" ErrReadingRefreshTokenClaims apperror.ErrorType = "ER0008 could not read refresh token claims" )
View Source
const (
TableName = "refresh_token"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Claims ¶
type Claims struct { UserID string `json:"user_id"` Csrf string `json:"csrf"` jwt.StandardClaims }
type GinMiddleware ¶
type GinMiddleware struct {
// contains filtered or unexported fields
}
func NewGinMiddleware ¶
func NewGinMiddleware(log logger.Logger) GinMiddleware
func (GinMiddleware) Authentication ¶
func (g GinMiddleware) Authentication(jwt JWT) gin.HandlerFunc
func (GinMiddleware) GetAccessTokenFromHeader ¶
func (g GinMiddleware) GetAccessTokenFromHeader(c *gin.Context) (token string, err error)
type JWT ¶
type JWT interface { GenerateToken(ctx context.Context, userId string, sub string) (accessToken, refreshToken, csrfSecret string, expiresAt int64, err error) RenewToken(ctx context.Context, oldAccessTokenString string, oldRefreshTokenString, oldCsrfSecret string) (newAccessToken, newRefreshToken, newCsrfSecret string, expiresAt int64, userId string, err error) DeleteRefreshToken(ctx context.Context, sub string, jti string) error VerifyToken(token string) (*Claims, error) }
func NewHS256JWT ¶
type JWTToken ¶
type JWTToken struct {
// contains filtered or unexported fields
}
func (*JWTToken) DeleteRefreshToken ¶
func (*JWTToken) GenerateToken ¶
func (*JWTToken) RenewToken ¶
type RedisRepository ¶
type RedisRepository struct {
// contains filtered or unexported fields
}
func NewRedisRepository ¶
func NewRedisRepository(addr, pass string) *RedisRepository
func (RedisRepository) DeleteRefreshToken ¶
func (r RedisRepository) DeleteRefreshToken(ctx context.Context, jti string) error
func (RedisRepository) FindAllRefreshTokens ¶
func (r RedisRepository) FindAllRefreshTokens(ctx context.Context) ([]RefreshToken, error)
func (RedisRepository) FindRefreshToken ¶
func (RedisRepository) StoreRefreshToken ¶
func (r RedisRepository) StoreRefreshToken(ctx context.Context, sub, jti string) error
type RefreshToken ¶
type RefreshTokenClaims ¶
type RefreshTokenClaims struct { Csrf string `json:"csrf"` jwt.StandardClaims }
type Repository ¶
Click to show internal directories.
Click to hide internal directories.