auth

package
v0.0.0-...-eccf771 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Scope   key = 0
	Subject key = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTValidator

type JWTValidator struct {
	Issuer                     string
	AccessTokenExpiryDuration  time.Duration
	RefreshTokenExpiryDuration time.Duration
	// contains filtered or unexported fields
}

func New

func New(privateKeyPath string) JWTValidator

func WithKey

func WithKey(privateKeyBytes []byte) JWTValidator

func (*JWTValidator) AuthMiddleware

func (j *JWTValidator) AuthMiddleware(next http.Handler) http.Handler

func (*JWTValidator) Generate

func (j *JWTValidator) Generate(user user.User) (Token, error)

func (*JWTValidator) RefreshToken

func (j *JWTValidator) RefreshToken(token string) (Token, error)

func (*JWTValidator) Verify

func (j *JWTValidator) Verify(signedJWT string) (*TokenClaims, error)

func (*JWTValidator) VerifyRefreshToken

func (j *JWTValidator) VerifyRefreshToken(token string) (int, error)

type Token

type Token struct {
	AccessToken  string `json:"accessToken" validate:"nonzero"`
	RefreshToken string `json:"refreshToken" validate:"nonzero"`
}

type TokenClaims

type TokenClaims struct {
	jwt.StandardClaims
	Scope string
}

Jump to

Keyboard shortcuts

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