interceptor

package
v0.0.0-...-eaa8db3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuthorizerHandler

func NewAuthorizerHandler(a HttpAuthorizer, wrapped http.Handler) http.Handler

NewAuthorizerHandler returns an HTTP handler which evaluates the Authorizer policy as an http middleware If the policy check fails StatusForbidden is returned, otherwise the wrapped handler is executed

func NewAuthorizerStreamServerInterceptor

func NewAuthorizerStreamServerInterceptor(a GrpcAuthorizer) grpc.StreamServerInterceptor

NewAuthorizerStreamServerInterceptor returns a StreamServerInterceptor which evaluates the Authorizer policy for each request If the policy check fails a PermissionDenied error code is returned, otherwise the request handler is executes as normal

func NewAuthorizerUnaryServerInterceptor

func NewAuthorizerUnaryServerInterceptor(a GrpcAuthorizer) grpc.UnaryServerInterceptor

NewAuthorizerUnaryServerInterceptor returns a UnaryServerInterceptor which evaluates the Authorizer policy for each request If the policy check fails a PermissionDenied error code is returned, otherwise the request handler is executes as normal

func NewGrpcAuthorizer

func NewGrpcAuthorizer(rule string, opts ...authorizerOption) (*grpcAuthorizer, error)

NewGrpcAuthorizer produces an Authorizer that can evaluate a CEL policy over Grpc requests The rule must evaluate to a bool

func NewHttpAuthorizer

func NewHttpAuthorizer(rule string, opts ...authorizerOption) (*httpAuthorizer, error)

NewHttpAuthorizer produces an Authorizer that can evaluate a CEL policy over Grpc requests The rule must evaluate to a bool

func WithTokenExtractor

func WithTokenExtractor(te TokenExtractor, requireToken bool) authorizerOption

WithTokenExtractor will populate the request.jwt field with the IDToken produced by the extractor If requireToken is set, the request will be denied if token extraction fails, without evaluating the policy If requireToken is false, JWT will be nil if token extraction fails and the policy will be evaluated

Types

type GrpcAuthorizer

type GrpcAuthorizer interface {
	Check(ctx context.Context, service string, method string) (bool, error)
}

type HttpAuthorizer

type HttpAuthorizer interface {
	Check(req *http.Request, method string) (bool, error)
}

type TokenExtractor

type TokenExtractor interface {
	// Extract returns a parsed IDToken from a set of request headers
	Extract(ctx context.Context, md map[string][]string) (*oidc.IDToken, error)
}

type TokenFormat

type TokenFormat int
const (
	TokenFormatInvalid TokenFormat = iota
	TokenFormatNone
	TokenFormatJWT
)

func ParseTokenFormat

func ParseTokenFormat(input string) (TokenFormat, error)

Jump to

Keyboard shortcuts

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