Documentation ¶
Index ¶
- func WithCtxRoot(c *Config, next http.Handler) http.Handler
- func WithEmpty(c *Config, next http.Handler) http.Handler
- func WithHeader(c *Config, next http.Handler) http.Handler
- func WithJWKValidation(c *Config, next http.Handler) http.Handler
- func WithJWT(c *Config, next http.Handler) http.Handler
- func WithLogging(c *Config, next http.Handler) http.Handler
- func WithMetrics(c *Config, next http.Handler) http.Handler
- func WithTracing(c *Config, next http.Handler) http.Handler
- func WithX509Validation(c *Config, next http.Handler) http.Handler
- type Config
- type JSONWebKey
- type JWKS
- type Middleware
- type Options
- type Proxy
- type Request
- func (r *Request) APIVer(v string) *Request
- func (r *Request) Body(b io.Reader) *Request
- func (r *Request) Delete() *Request
- func (r *Request) Do() (*http.Response, error)
- func (r *Request) DoWithContext(ctx context.Context) (*http.Response, error)
- func (r *Request) Get() *Request
- func (r *Request) Header(key string, values ...string) *Request
- func (r *Request) Headers(h http.Header) *Request
- func (r *Request) Into(obj interface{}) *Request
- func (r *Request) Method(m string) *Request
- func (r *Request) Name(n string) *Request
- func (r *Request) Namespace(ns string) *Request
- func (r *Request) Options() *Request
- func (r *Request) Path(p string) *Request
- func (r *Request) Post() *Request
- func (r *Request) Put() *Request
- func (r *Request) Query(q string) *Request
- func (r *Request) Resource(res string) *Request
- func (r *Request) URL() *url.URL
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithCtxRoot ¶
WithCtxRoot is a middleware that reads the url path params in the request and tries to determine which kubeconfig context to use for upstream api server requests. If a context is found in the URL path params, the request-context is populated with the value so that other handlers and middlewares may use the information
func WithHeader ¶
WithHeader is a middleware that reads the value of the HTTP header "Multikube-Context" in the request and, if found, sets it's value in the request context.
func WithJWKValidation ¶
WithJWKValidation is a middleware that validates a JWT token in the http request using RS256 signing method. It will do so using a JWK (Json Web Key) provided in c
func WithJWT ¶
WithJWT is a middleware that parses a JWT token from the requests and propagates the request context with a claim value.
func WithLogging ¶
WithLogging applies access log style logging to the HTTP server
func WithMetrics ¶
WithMetrics is an empty handler that does nothing
func WithTracing ¶
WithTracing is a middleware that starts a new span and populates the context
Types ¶
type Config ¶
type Config struct { OIDCIssuerURL string OIDCUsernameClaim string OIDCPollInterval time.Duration RS256PublicKey *x509.Certificate JWKS *JWKS }
Config holds a top-level configuration of an instance of Multikube. It is used to pass around configuration used by different packages within the project.
func (*Config) GetJWKSFromURL ¶
func (c *Config) GetJWKSFromURL() func()
GetJWKSFromURL fetches the keys of an OpenID Connect endpoint in a go routine. It polls the endpoint every n seconds. Returns a cancel function which can be called to stop polling and close the channel. The endpoint must support OpenID Connect discovery as per https://openid.net/specs/openid-connect-discovery-1_0.html
type JSONWebKey ¶
type JSONWebKey struct { Kty string `json:"kty"` Kid string `json:"kid"` Use string `json:"use"` N string `json:"n"` E string `json:"e"` X5c []string `json:"x5c"` }
JSONWebKey is a representation of a Json Web Key
type JWKS ¶
type JWKS struct {
Keys []JSONWebKey `json:"keys"`
}
JWKS is a representation of Json Web Key Store. It holds multiple JWK's in an array
func (*JWKS) Find ¶
func (j *JWKS) Find(s string) *JSONWebKey
Find will loop through the keys on the JWKS and return that which has a matching key id
type Middleware ¶
Middleware represents a multikube middleware
type Options ¶
Options embeds Cluster and AuthInfo from https://godoc.org/k8s.io/client-go/tools/clientcmd/api so that fields and methods are easily accessible from one type.
type Proxy ¶
type Proxy struct { CertChain *x509.Certificate Config *Config KubeConfig *api.Config // contains filtered or unexported fields }
Proxy implements an HTTP handler. It has a built-in transport with in-mem cache capabilities.
func NewProxy ¶
func NewProxy() *Proxy
NewProxy creates a new Proxy and initialises router and configuration
func NewProxyFrom ¶
NewProxyFrom creates an instance of Proxy
func (*Proxy) ServeHTTP ¶
func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP routes the request to an apiserver. It determines, resolves an apiserver using data in the request itsel such as certificate data, authorization bearer tokens, http headers etc.
func (*Proxy) Use ¶
func (p *Proxy) Use(mw ...Middleware) Middleware
Use chains all middlewares and applies a context to the request flow
type Request ¶
type Request struct { Transport http.RoundTripper // contains filtered or unexported fields }
Request is a simple type used to compose inidivudal requests to an HTTP server.
func NewRequest ¶
NewRequest will return a new Request object with the given URL
func (*Request) APIVer ¶
APIVer sets the api version to be used when building the URI for the request. Defaults to 'v1' if not set.
func (*Request) Delete ¶
Delete method sets the method on a request to DELETE. Delete will invoke Method(http.MethodDelete).
func (*Request) Do ¶
Do executes the request and returns an http.Response. The caller is responible of closing the Body.
func (*Request) DoWithContext ¶
DoWithContext executes the request and returns an http.Response. DoWithContext expect a context to be provided.
func (*Request) Get ¶
Get method sets the method on a request to GET. Get will invoke Method(http.MethodGet).
func (*Request) Headers ¶
Headers overrides the entire headers field of the http request. Use Header() method to set individual headers.
func (*Request) Name ¶
Name sets the name of the Kubernetes resource to be used when building the URI. For example setting the name to 'app-pod-1' will create an uri like /api/v1/namespaces/pods/app-pod-1.
func (*Request) Namespace ¶
Namespace sets the Kubernetes namespace to be used when building the URI. For example setting the namespace to 'default' will create an uri like /api/v1/namespaces/default.
func (*Request) Options ¶
Options method sets the method on a request to OPTIONS. Options will invoke Method(http.MethodOptions),
func (*Request) Post ¶
Post method sets the method on a request to POST. Post will invoke Method(http.MethodPost).
func (*Request) Put ¶
Put method sets the method on a request to PUT. Put will invoke Method(http.MethodPut).