handler

package
v4.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package handler provides an interface to handle K8s webhook requests, including authentication and authorization requests.

Index

Constants

View Source
const (
	// ProblemJSONContentType represents the media type of the error response
	ProblemJSONContentType = "application/problem+json"

	// HTTPStatusClientClosedRequest represents a non-standard status code meaning that the client closed the connection before the server answered the request
	HTTPStatusClientClosedRequest = 499

	// ErrMsgUnverified "unauthenticated/unauthorized"
	ErrMsgUnverified = "unauthenticated/unauthorized"

	// ErrGRPCMetadataNotFound "grpc metadata not found"
	ErrGRPCMetadataNotFound = "grpc metadata not found"

	// ErrRoleTokenNotFound "role token not found"
	ErrRoleTokenNotFound = "role token not found"
)

Variables

This section is empty.

Functions

func New

New creates a handler for handling different HTTP requests based on the given services. It also contains a reverse proxy for handling proxy request.

func NewGRPC added in v4.6.0

func NewGRPC(opts ...GRPCOption) (grpc.StreamHandler, io.Closer)

Types

type Func

type Func func(http.ResponseWriter, *http.Request) error

Func represents the a handle function type

type GRPCHandler added in v4.6.0

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

func (*GRPCHandler) Close added in v4.6.0

func (gh *GRPCHandler) Close() error

type GRPCOption added in v4.6.0

type GRPCOption func(*GRPCHandler)

Option represents a functional option for gRPC Handler

func WithAuthorizationd added in v4.6.0

func WithAuthorizationd(a service.Authorizationd) GRPCOption

WithAuthorizationd returns a authorizationd functional option

func WithProxyConfig added in v4.6.0

func WithProxyConfig(cfg config.Proxy) GRPCOption

WithProxyConfig returns a proxy config functional option

func WithRoleTokenConfig added in v4.6.0

func WithRoleTokenConfig(cfg config.RoleToken) GRPCOption

WithRoleTokenConfig returns a role token config functional option

type InvalidParam

type InvalidParam struct {
	Name   string `json:"name"`
	Reason string `json:"reason"`
}

InvalidParam represents the invalid parameters requested by the user.

type OAuthAccessTokenMock

type OAuthAccessTokenMock struct {
	PrincipalMock
	ClientIDFunc func() string
}

OAuthAccessTokenMock is a mock of OAuthAccessToken

func (*OAuthAccessTokenMock) ClientID

func (oat *OAuthAccessTokenMock) ClientID() string

ClientID is a mock implementation of OAuthAccessToken

type PrincipalMock

type PrincipalMock struct {
	NameFunc       func() string
	RolesFunc      func() []string
	DomainFunc     func() string
	IssueTimeFunc  func() int64
	ExpiryTimeFunc func() int64
}

PrincipalMock is a mock of Principal

func (*PrincipalMock) AuthorizedRoles added in v4.2.2

func (p *PrincipalMock) AuthorizedRoles() []string

AuthorizedRoles is a mock implementation of Principal

func (*PrincipalMock) Domain

func (p *PrincipalMock) Domain() string

Domain is a mock implementation of Principal

func (*PrincipalMock) ExpiryTime

func (p *PrincipalMock) ExpiryTime() int64

ExpiryTime is a mock implementation of Principal

func (*PrincipalMock) IssueTime

func (p *PrincipalMock) IssueTime() int64

IssueTime is a mock implementation of Principal

func (*PrincipalMock) Name

func (p *PrincipalMock) Name() string

Name is a mock implementation of Principal

func (*PrincipalMock) Roles

func (p *PrincipalMock) Roles() []string

Roles is a mock implementation of Principal

type RFC7807Error

type RFC7807Error struct {
	Type          string `json:"type"`
	Title         string `json:"title"`
	Status        int
	InvalidParams []InvalidParam `json:"invalid-params,omitempty"`
	Detail        string         `json:"detail"`
	Instance      string         `json:"instance"`
	RoleToken     string         `json:"role_token"`
}

RFC7807Error represents the error message fulfilling RFC7807 standard.

type RoundTripperMock

type RoundTripperMock struct {
	RoundTripFunc func(req *http.Request) (*http.Response, error)
}

RoundTripperMock is a mock of RoundTripper

func (*RoundTripperMock) RoundTrip

func (rt *RoundTripperMock) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip is a mock implementation of RoundTripper.RoundTrip

Jump to

Keyboard shortcuts

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