Documentation ¶
Overview ¶
Package webapi implements web proxy handler that provides various helpers for web UI, so it's OK to put UI specific stuff here
Index ¶
- func NewTCPAddr(a string) net.Addr
- func ServeStaticFiles(wh *WebHandler, path string, root http.FileSystem)
- type AuthContext
- type CallbackParams
- type Config
- type ForwardRequest
- type Forwarder
- type ForwarderConfig
- type Handler
- func (m *Handler) CallbackHandler(w http.ResponseWriter, r *http.Request, p CallbackParams) error
- func (m *Handler) GetConfig() Config
- func (m *Handler) GetHandlerContext(w http.ResponseWriter, r *http.Request) (*AuthContext, error)
- func (m *Handler) Resources(ctx *AuthContext) (resources.Resources, error)
- func (m *Handler) SetPlugin(plugin Plugin)
- type Plugin
- type PodParams
- type PodTerminalRequest
- type Providers
- type ValidateInput
- type ValidateOutput
- type ValidateVariables
- type WebHandler
- type WebHandlerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServeStaticFiles ¶
func ServeStaticFiles(wh *WebHandler, path string, root http.FileSystem)
ServeStaticFiles serves static files such as js/css/images. https://github.com/julienschmidt/httprouter/issues/40 (this is as is copy of julienschmidt ServerFile method that adds security headers)
Types ¶
type AuthContext ¶
type AuthContext struct { // Context is the request context Context context.Context // User is a current user User storage.User // Checkers is access checker Checker teleservices.AccessChecker // Operator is the interface to operations service Operator *ops.OperatorACL // Applications is the interface to application management service Applications app.Applications // Packages is the interface to package management service Packages pack.PackageService // Identity is identity service Identity users.Identity // SessionContext is a current session context SessionContext *teleweb.SessionContext }
type CallbackParams ¶
type CallbackParams struct { // Username is the name of the authenticated user Username string // Identity is the external identity of the authenticated user Identity teleservices.ExternalIdentity // Session is the created web session Session teleservices.WebSession // Cert is the generated SSH certificate Cert []byte // TLSCert is the generated TLS certificate TLSCert []byte // HostSigners is a list of signing host public keys trusted by proxy HostSigners []teleservices.CertAuthority // Type is the original request type Type string // CreateWebSession indicates sign in via UI CreateWebSession bool // CSRFToken the original request CSRF token CSRFToken string // PublicKey is an optional public key to sign in case of successful authentication PublicKey []byte // ClientRedirectURL is where successfully authenticated client is redirected ClientRedirectURL string }
CallbackParams combines necessary parameters for OAuth2 callback handler
type Config ¶
type Config struct { // Identity is identity service provided by web api Identity users.Identity // PrefixURL is a prefix redirect URL for this PrefixURL string // Auth is a client to authentication service Auth teleauth.ClientI // WebAuthenticator is used to authenticate web sessions WebAuthenticator httplib.Authenticator // Operator is the interface to operations service Operator ops.Operator // Applications is the interface to application management service Applications app.Applications // Packages is the interface to package management service Packages pack.PackageService // Providers defines cloud provider-specific functionality Providers Providers // Tunnel provides access to remote server Tunnel reversetunnel.Server // Clients provides access to clients for remote clusters such as operator or apps Clients *clients.ClusterClients // Converter converts objects to UI representation Converter ui.Converter // Mode is the mode the process is running in Mode string // Backend is storage backend Backend storage.Backend // ProxyHost is the address of Teleport proxy ProxyHost string // ServiceUser specifies the service user to use to // create a cluster with for wizard-based installation ServiceUser systeminfo.User // InstallToken specifies the token to install cluster with. // The token is used to authenticate agents during the install operation InstallToken string }
Config represents web handler configuration parameters
type ForwardRequest ¶
type ForwardRequest struct { // ClusterName is the name of the cluster to forward the request to ClusterName string // ServiceName is the name of the service to forward the request to ServiceName string // ServicePort is the service port ServicePort int // ServiceNamespace is the namespace where the service resides ServiceNamespace string // URL is the request URL URL string }
ForwardRequest encapsulates parameters for request forwarding
type Forwarder ¶
type Forwarder interface { // ForwardToKube forwards the request to the authenticated k8s API, // Requires operator bound to current user to function properly ForwardToKube(w http.ResponseWriter, r *http.Request, siteName, URL string) error // ForwardToService forwards the request to a Kubernetes service ForwardToService(w http.ResponseWriter, r *http.Request, req ForwardRequest) error }
Forwarder allows to forward HTTP requests from OpsCenter or gravity site to a service running inside deployed k8s cluster
func NewForwarder ¶
func NewForwarder(cfg ForwarderConfig) (Forwarder, error)
NewForwarder creates a new forwarder
type ForwarderConfig ¶
type ForwarderConfig struct { // Tunnel is the teleport reverse tunnel Tunnel rt.Server // User specifies an optional override for Common Name // to use when requesting certificates for kubernetes User string }
ForwarderConfig is a config for a forwarder
type Handler ¶
type Handler struct { httprouter.Router log.FieldLogger // contains filtered or unexported fields }
Handler is HTTP web API handler
func (*Handler) CallbackHandler ¶
func (m *Handler) CallbackHandler(w http.ResponseWriter, r *http.Request, p CallbackParams) error
CallbackHandler is the generic OAuth2 provider callback handler
func (*Handler) GetHandlerContext ¶
func (m *Handler) GetHandlerContext(w http.ResponseWriter, r *http.Request) (*AuthContext, error)
GetHandlerContext authenticates the session user and returns an appropriate handler context
type Plugin ¶
type Plugin interface { // Resources returns resource controller Resources(*AuthContext) (resources.Resources, error) // CallbackHandler is the OAuth2 provider callback handler CallbackHandler(http.ResponseWriter, *http.Request, CallbackParams) error }
Plugin allows to customize handler behavior
type PodParams ¶
type PodParams struct { // Namespace is a pod namespace Namespace string `json:"namespace"` // Name is a pod name Name string `json:"name"` // Container is a container name Container string `json:"container"` }
PodParams specifies parameters to connect to a Pod
type PodTerminalRequest ¶
type PodTerminalRequest struct { // User is linux username to connect as Login string `json:"login"` // Term sets PTY params like width and height Term telesession.TerminalParams `json:"term"` // Pod specifies pod to connect to Pod PodParams `json:"pod"` // SessionID is a teleport session ID to join as SessionID telesession.ID `json:"sid"` }
PodTerminalRequest describes a request to create a web-based terminal to a remote Pod via SSH server
type Providers ¶
type Providers interface { // Validate verifies certain aspects of the specified cloud provider // and obtains basic metadata Validate(ctx context.Context, req *ValidateInput) (*ValidateOutput, error) }
Providers defines interface to a set of supported cloud providers
func NewProviders ¶
func NewProviders(applications app.Applications) Providers
NewProviders creates a new instance of Providers implementation
type ValidateInput ¶
type ValidateInput struct { // Provider defines the specific cloud provider to work with Provider string `json:"provider"` // Variables is a provider-specific input Variables ValidateVariables `json:"variables"` // Application defines the application package being installed Application packageLocator `json:"application"` }
ValidateInput defines the input to provider validation
type ValidateOutput ¶
type ValidateOutput struct { // AWS defines the output of the AWS provider AWS *aws.ValidateOutput `json:"aws"` }
ValidateOutput defines the output of provider validation
type ValidateVariables ¶
type ValidateVariables struct { // AccessKey is AWS access key AccessKey string `json:"access_key"` // SecretKey is AWS secret key SecretKey string `json:"secret_key"` // SessionToken is an AWS session token SessionToken string `json:"session_token"` }
ValidateVariables contains provider-specific variables for validation request
type WebHandler ¶
type WebHandler struct { // Router is used to route web requests httprouter.Router // FieldLogger allows handler to log messages log.FieldLogger // contains filtered or unexported fields }
WebHandler serves web UI
func NewHandler ¶
func NewHandler(cfg WebHandlerConfig) *WebHandler
NewHandler returns a new instance of NewHandler
type WebHandlerConfig ¶
type WebHandlerConfig struct { // AssetsDir is the directory containing web assets AssetsDir string // Mode is the gravity process mode Mode string // Wizard is whether this process is install wizard Wizard bool // TeleportConfig is the teleport configuration TeleportConfig *service.Config // Identity is the cluster user service Identity users.Identity // Operator is the cluster operator service Operator ops.Operator // Authenticator is used to authenticate web requests Authenticator httplib.Authenticator // Forwarder is used to forward web requests to clusters Forwarder Forwarder // Backend is the cluster backend Backend storage.Backend // Clients provides access to remote cluster client Clients *clients.ClusterClients }
WebHandlerConfig defines a configuration object for the handler