jwtparser

package
v4.10.3 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitJWTValidator

func InitJWTValidator(auth0Domain string, configBucket string, pemPath string, fs fileaccess.FileAccess) (*auth0.JWTValidator, error)

func ReadPermissions

func ReadPermissions(claims map[string]interface{}) (map[string]bool, error)

Types

type IJWTReader

type IJWTReader interface {
	GetValidator() JWTInterface
	GetUserInfo(*http.Request) (JWTUserInfo, error)
}

IJWTReader - User ID getter from HTTP request

type JWTInterface

type JWTInterface interface {
	ValidateRequest(r *http.Request) (*jwt.JSONWebToken, error)
	Claims(r *http.Request, token *jwt.JSONWebToken, values ...interface{}) error
}

Implements a JWT validation and claim extraction interface

type JWTUserInfo

type JWTUserInfo struct {
	Name        string          `json:"name"`
	UserID      string          `json:"user_id"`
	Email       string          `json:"email"`
	Permissions map[string]bool `json:"-" bson:"-"` // This is a lookup - we don't want this in JSON sent out of API though!
}

type MockJWTValidator

type MockJWTValidator struct {
}

func (*MockJWTValidator) Claims

func (v *MockJWTValidator) Claims(r *http.Request, token *jwt.JSONWebToken, values ...interface{}) error

func (*MockJWTValidator) ValidateRequest

func (v *MockJWTValidator) ValidateRequest(r *http.Request) (*jwt.JSONWebToken, error)

type RealJWTReader

type RealJWTReader struct {
	Validator JWTInterface
}

RealJWTReader - Reader

func (RealJWTReader) GetSimpleUserInfo

func (j RealJWTReader) GetSimpleUserInfo(r *http.Request) (JWTUserInfo, error)

GetSimpleUserInfo - Get Simple User Info

func (RealJWTReader) GetUserInfo

func (j RealJWTReader) GetUserInfo(r *http.Request) (JWTUserInfo, error)

GetUserInfo - Get User Info

func (RealJWTReader) GetValidator

func (j RealJWTReader) GetValidator() JWTInterface

Jump to

Keyboard shortcuts

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