auth

package
v0.0.0-...-564de18 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID string

func (*ID) UnmarshalJSON

func (n *ID) UnmarshalJSON(b []byte) error

type UserAuthenticator

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

func NewUserAuthenticator

func NewUserAuthenticator(secret string) *UserAuthenticator

func (*UserAuthenticator) IsUser

func (u *UserAuthenticator) IsUser(token string, userID string) bool

IsUser is a simpler version of Validate, throwing away the error

func (*UserAuthenticator) UserClaims

func (u *UserAuthenticator) UserClaims(tokenString string) (*UserClaims, error)

Claims returns the complete JWT claims object

func (*UserAuthenticator) UserID

func (u *UserAuthenticator) UserID(token string) (string, error)

UserID retrieves the `user_id` claim from the JWT token

func (*UserAuthenticator) Validate

func (u *UserAuthenticator) Validate(token string, userID string) (bool, error)

Validate just checks if the JWT claims match an userID

type UserClaims

type UserClaims struct {
	UserID ID `json:"user_id"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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