opshandler

package
v0.0.0-...-3bfe646 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NeedsAuth

func NeedsAuth(devmode bool, backend storage.Backend, operator ops.Operator, authenticator users.Authenticator, usersService users.Identity, fn ServiceHandle) httprouter.Handle

NeedsAuth is authentication wrapper for ops handlers

Types

type HandlerContext

type HandlerContext struct {
	// Operator is the operator service
	Operator ops.Operator
	// SiteKey is the request cluster key
	SiteKey ops.SiteKey
	// User is the authenticated user
	User storage.User
	// Identity is the users service
	Identity users.Identity
	// Checker is used for ACL checks
	Checker teleservices.AccessChecker
	// Context is the request context
	Context context.Context
}

HandlerContext is the request context that gets passed into each handler function

func GetHandlerContext

func GetHandlerContext(w http.ResponseWriter, r *http.Request, backend storage.Backend, operator ops.Operator, authenticator users.Authenticator, usersService users.Identity) (*HandlerContext, error)

GetHandlerContext authenticates the user that made the request and returns the appropriate handler context

type ServiceHandle

ServiceHandle defines an ops handler function type

type WebHandler

type WebHandler struct {
	httprouter.Router
	// contains filtered or unexported fields
}

func NewWebHandler

func NewWebHandler(cfg WebHandlerConfig) (*WebHandler, error)

func (*WebHandler) GetConfig

func (h *WebHandler) GetConfig() WebHandlerConfig

GetConfig returns config web handler was initialized with

func (*WebHandler) ServeHTTP

func (h *WebHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP lets the authentication middleware serve the request before passing it through to the router.

type WebHandlerConfig

type WebHandlerConfig struct {
	// Backend is the process backend
	Backend storage.Backend
	// Users is the process users service
	Users users.Identity
	// Operator is the underlying ops service
	Operator ops.Operator
	// Applications is the apps service
	Applications app.Applications
	// Packages is the pack service
	Packages pack.PackageService
	// Authenticator is used to authenticate web requests
	Authenticator users.Authenticator
	// Devmode is whether the process is started in dev mode
	Devmode bool
	// PublicAdvertiseAddr is the process public advertise address
	PublicAdvertiseAddr teleutils.NetAddr
}

WebHandlerConfig is the ops web handler configuration

func (*WebHandlerConfig) CheckAndSetDefaults

func (c *WebHandlerConfig) CheckAndSetDefaults() error

CheckAndSetDefaults validates the config and sets some defaults.

Jump to

Keyboard shortcuts

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