auth

package
v0.0.0-...-3779236 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound       = errors.New("user not found")
	ErrInvalidCredentials = errors.New("invalid authentication credentials")
)
View Source
var (
	ErrInvalidJWT = errors.New("invalid jwt")
	ErrExpiredJWT = errors.New("expired jwt")
)

Functions

func Authenticate

func Authenticate(hashed, plain, salt string) bool

func NewEncodedClaims

func NewEncodedClaims(id, uid, secrets string, issueAt, expireAt time.Time) (string, error)

Types

type JWTClaims

type JWTClaims struct {
	jwt.Claims
	UserID string `json:"uid,omitempty"`
}

JWTClaims represents the claims of a JWT.

func NewClaims

func NewClaims(id, uid string, issueAt, expireAt time.Time) *JWTClaims

func ParseJWT

func ParseJWT(jwtStr, accessSecret string) (*JWTClaims, error)

ParseJWT parses the token string and validates the signature.

func UnsafeParseJWT

func UnsafeParseJWT(jwtStr string) (*JWTClaims, error)

UnsafeParseJWT parses the token string but no signature validation.

Jump to

Keyboard shortcuts

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