jwt

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: MPL-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

View Source
const (
	JwtDefaultSecret        string = "convoy-jwt"
	JwtDefaultRefreshSecret string = "convoy-refresh-jwt"
	JwtDefaultExpiry        int    = 1800  //seconds
	JwtDefaultRefreshExpiry int    = 86400 //seconds
)

Variables

View Source
var (
	ErrInvalidToken = errors.New("invalid token")
	ErrTokenExpired = errors.New("expired token")
)

Functions

This section is empty.

Types

type Jwt

type Jwt struct {
	Secret        string
	Expiry        int
	RefreshSecret string
	RefreshExpiry int
	// contains filtered or unexported fields
}

func NewJwt

func NewJwt(opts *config.JwtRealmOptions, cache cache.Cache) *Jwt

func (*Jwt) BlacklistToken

func (j *Jwt) BlacklistToken(verified *VerifiedToken, token string) error

func (*Jwt) EncodeToken

func (j *Jwt) EncodeToken(token string) string

func (*Jwt) GenerateToken

func (j *Jwt) GenerateToken(user *datastore.User) (Token, error)

func (*Jwt) ValidateAccessToken

func (j *Jwt) ValidateAccessToken(accessToken string) (*VerifiedToken, error)

func (*Jwt) ValidateRefreshToken

func (j *Jwt) ValidateRefreshToken(refreshToken string) (*VerifiedToken, error)

type JwtRealm

type JwtRealm struct {
	// contains filtered or unexported fields
}

func NewJwtRealm

func NewJwtRealm(userRepo datastore.UserRepository, opts *config.JwtRealmOptions, cache cache.Cache) *JwtRealm

func (*JwtRealm) Authenticate

func (j *JwtRealm) Authenticate(ctx context.Context, cred *auth.Credential) (*auth.AuthenticatedUser, error)

func (*JwtRealm) GetName

func (j *JwtRealm) GetName() string

type Token

type Token struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type VerifiedToken

type VerifiedToken struct {
	UserID string
	Expiry int64
}

Jump to

Keyboard shortcuts

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