jwtparser

package
v4.34.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 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 TODO: See note for GetUserInfo about user impersonation

func (RealJWTReader) GetUserInfo

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

GetUserInfo - Get User Info TODO: When a user is impersonating another, this still returns the real users details

from the JWT. This is unfortunate but seemed more effort than it's worth to fix
because we'll mainly test with science team members who have similar auth0
permissions, similar groups, similar access to datasets. If we do encounter
issues we can look at adding a map of userid->UserInfo structs containing the
impersonated users details, and return that from here

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