auth

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CtxPrincipalKey in ctx
	CtxPrincipalKey key = iota
)

Variables

This section is empty.

Functions

func CheckRequestIsAllowed

func CheckRequestIsAllowed(principal *model.Principal, requestType requestobjects.RequestType, project string) bool

CheckRequestIsAllowed check if user is allowed to perform request

Types

type AuthenticationMiddleware

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

AuthenticationMiddleware is a middleware for auth process

func NewAuthenticationMiddleware

func NewAuthenticationMiddleware(validator TokenValidator, principalRetriever PrincipalRetriever) (*AuthenticationMiddleware, error)

NewAuthenticationMiddleware return instance of AuthenticationMiddleware

func (*AuthenticationMiddleware) AddAuthentication

func (a *AuthenticationMiddleware) AddAuthentication(next http.HandlerFunc) http.HandlerFunc

AddAuthentication add new auth method

type PrincipalRetriever

type PrincipalRetriever interface {
	RetrieveCurrentPrincipal(ctxIn context.Context, r *http.Request) (*model.Principal, error)
}

PrincipalRetriever retriever to fetch principal of request

func NewPrincipalRetriever

func NewPrincipalRetriever(provider provider.PrincipalProvider) (PrincipalRetriever, error)

NewPrincipalRetriever

type TokenValidator

type TokenValidator interface {
	ValidateRequest(req *http.Request) error
}

tokenValidator defines operations for JWT token validation

func NewEmptyTokenValidator

func NewEmptyTokenValidator() TokenValidator

NewEmptyTokenValidator return instance of jwtTokenValidator

func NewTokenValidator

func NewTokenValidator(keyForToken string, audience string) (TokenValidator, error)

NewTokenValidator return instance of jwtTokenValidator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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