Documentation
¶
Overview ¶
Package handler provides an interface to handle K8s webhook requests, including authentication and authorization requests.
Index ¶
- Constants
- func New(cfg config.Proxy, bp httputil.BufferPool, prov service.Authorizationd, ...) http.Handler
- func NewGRPC(opts ...GRPCOption) (grpc.StreamHandler, io.Closer)
- type Func
- type GRPCHandler
- type GRPCOption
- type InvalidParam
- type OAuthAccessTokenMock
- type PrincipalMock
- type RFC7807Error
- type RoundTripperMock
Constants ¶
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" // ErrInvalidProxyConfig "invalid proxy config". ErrInvalidProxyConfig = "invalid proxy config" )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(cfg config.Proxy, bp httputil.BufferPool, prov service.Authorizationd, metrics service.Metrics) http.Handler
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 ¶
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 ¶
type GRPCHandler struct {
// contains filtered or unexported fields
}
func (*GRPCHandler) Close ¶
func (gh *GRPCHandler) Close() error
type GRPCOption ¶
type GRPCOption func(*GRPCHandler)
Option represents a functional option for gRPC Handler
func WithAuthorizationd ¶
func WithAuthorizationd(a service.Authorizationd) GRPCOption
WithAuthorizationd returns a authorizationd functional option
func WithProxyConfig ¶
func WithProxyConfig(cfg config.Proxy) GRPCOption
WithProxyConfig returns a proxy config functional option
func WithRoleTokenConfig ¶
func WithRoleTokenConfig(cfg config.RoleToken) GRPCOption
WithRoleTokenConfig returns a role token config functional option
type InvalidParam ¶
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 ¶
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 ¶
RoundTripperMock is a mock of RoundTripper