jwt

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

README

go-jwt

JWT with blacklist

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenRevoked            = errors.NewHTTP(http.StatusUnauthorized, "token is revoked")
	ErrTokenMalformed          = errors.NewHTTP(http.StatusUnauthorized, "malformed token")
	ErrTokenExpired            = errors.NewHTTP(http.StatusUnauthorized, "token is expired")
	ErrTokenNotValidYet        = errors.NewHTTP(http.StatusUnauthorized, "token is not active yet")
	ErrAuthTokenMissed         = errors.NewHTTP(http.StatusUnauthorized, "missed authorization token")
	ErrBlacklistNotSpecified   = errors.New("blacklist adapter is not specified")
	ErrUnexpectedSigningMethod = errors.New("unexpected signing method")
	ErrCouldNotRefresh         = errors.NewHTTP(http.StatusUnauthorized, "could not refresh token, log in again")
)

Predefined JWT errors

Functions

This section is empty.

Types

type Claims

type Claims interface {
	jwt.Claims
	ID() string
	ExpAt() int64
	Refresh(ttl int64) Claims
}

Claims interface

type DefaultClaims

type DefaultClaims struct {
	UserID        string `json:"uid,omitempty"`
	ApplicationID string `json:"aid,omitempty"`
	Role          string `json:"rol,omitempty"`
	jwt.StandardClaims
}

DefaultClaims struct

func (DefaultClaims) ExpAt

func (c DefaultClaims) ExpAt() int64

ExpAt getter function returns expiration time in seconds

func (DefaultClaims) ID

func (c DefaultClaims) ID() string

ID getter function

func (DefaultClaims) Refresh

func (c DefaultClaims) Refresh(ttl int64) Claims

Refresh claims

type Interactor

type Interactor interface {
	New(uid, aid, role string) (string, error)
	NewWithClaims(Claims) (string, error)
	Parse(token string, claims Claims) error
	ParseFromRequest(r *http.Request, claims Claims) error
	ParseExpired(tokenString string, claims Claims) error
	GetTokenStringFromRequest(r *http.Request) (string, error)
	Revoke(tokenID string) error
	IsRevoked(tokenID string) bool
	RefreshToken(claims Claims) (string, error)
	RefreshTokenFromString(tokenString string) (string, error)
}

Interactor interface

func NewInteractor

func NewInteractor(signingKey string, ttl, refreshTTL int64, bl blacklist.Blacklist) (Interactor, error)

NewInteractor factory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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