httpcontext

package
v0.0.0-...-1592773 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2025 License: AGPL-3.0 Imports: 8 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestAuthInfo

func RequestAuthInfo(req *http.Request) (authentication.AuthInfo, bool)

RequestAuthInfo returns the AuthInfo associated with the request, if any, and a boolean indicating whether or not the request was authenticated.

func RequestModelUUID

func RequestModelUUID(ctx context.Context) (string, bool)

RequestModelUUID returns the model UUID associated with the given context provided from an httpRequest. No attempt is made to validate the model UUID; QueryModelHandler and BucketModelHandler does this, and ControllerModelHandler should always be supplied with a valid UUID.

Types

type AuthHandler

type AuthHandler struct {
	// NextHandler is the http handler to call after authentication has been
	// completed.
	NextHandler http.Handler

	// Authenticator is the Authenticator used for authenticating
	// the HTTP requests handled by this handler.
	Authenticator authentication.HTTPAuthenticator

	// Authorizer, if non-nil, will be called with the auth info
	// returned by the Authenticator, to validate it for the route.
	Authorizer authentication.Authorizer
}

AuthHandler is a http handler responsible for handling authz and authn for http requests coming into Juju. If a request both authenticates and authorizes then the authentication info is also padded into the http context and the next http handler is called.

func (*AuthHandler) ServeHTTP

func (h *AuthHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is part of the http.Handler interface and is responsible for performing AuthN and AuthZ on the subsequent http request.

type BucketModelHandler

type BucketModelHandler struct {
	http.Handler
	Query string
}

BucketModelHandler is an http.Handler that associates requests that it handles with a model UUID extracted from a specified query parameter that must be the objects storage :bucket which is formatted 'model-{modelUUID}'. The model UUID can then be extracted using the RequestModelUUID function in this package.

func (*BucketModelHandler) ServeHTTP

func (h *BucketModelHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is part of the http.Handler interface.

type ControllerModelHandler

type ControllerModelHandler struct {
	http.Handler
	ControllerModelUUID string
}

ControllerModelHandler is an http.Handler that associates requests that it handles with a specified controller model UUID. The controller model UUID can then be extracted using the RequestModelUUID function in this package.

func (*ControllerModelHandler) ServeHTTP

func (h *ControllerModelHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is part of the http.Handler interface.

type HTTPStrategicAuthenticator

type HTTPStrategicAuthenticator []authentication.HTTPAuthenticator

HTTPStrategicAuthenticator is responsible for trying multiple Authenticators until one succeeds or an error is returned that is not equal to NotFound.

type QueryModelHandler

type QueryModelHandler struct {
	http.Handler
	Query string
}

QueryModelHandler is an http.Handler that associates requests that it handles with a model UUID extracted from a specified query parameter. The model UUID can then be extracted using the RequestModelUUID function in this package.

func (*QueryModelHandler) ServeHTTP

func (h *QueryModelHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP is part of the http.Handler interface.

Jump to

Keyboard shortcuts

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