wsproxy

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Logger      slog.Logger
	Experiments codersdk.Experiments

	HTTPClient *http.Client
	// DashboardURL is the URL of the primary coderd instance.
	DashboardURL *url.URL
	// AccessURL is the URL of the WorkspaceProxy.
	AccessURL *url.URL

	// TODO: @emyrk We use these two fields in many places with this comment.
	//		Maybe we should make some shared options struct?
	// AppHostname should be the wildcard hostname to use for workspace
	// applications INCLUDING the asterisk, (optional) suffix and leading dot.
	// It will use the same scheme and port number as the access URL.
	// E.g. "*.apps.coder.com" or "*-apps.coder.com".
	AppHostname string
	// AppHostnameRegex contains the regex version of options.AppHostname as
	// generated by httpapi.CompileHostnamePattern(). It MUST be set if
	// options.AppHostname is set.
	AppHostnameRegex *regexp.Regexp

	RealIPConfig *httpmw.RealIPConfig

	Tracing            trace.TracerProvider
	PrometheusRegistry *prometheus.Registry

	APIRateLimit     int
	SecureAuthCookie bool
	DisablePathApps  bool

	ProxySessionToken string
	// AllowAllCors will set all CORs headers to '*'.
	// By default, CORs is set to accept external requests
	// from the dashboardURL. This should only be used in development.
	AllowAllCors bool
}

func (*Options) Validate

func (o *Options) Validate() error

type Server

type Server struct {
	Options *Options
	Handler chi.Router

	DashboardURL *url.URL
	AppServer    *workspaceapps.Server

	// Logging/Metrics
	Logger             slog.Logger
	TracerProvider     trace.TracerProvider
	PrometheusRegistry *prometheus.Registry

	// SDKClient is a client to the primary coderd instance authenticated with
	// the moon's token.
	SDKClient *wsproxysdk.Client
	// contains filtered or unexported fields
}

Server is an external workspace proxy server. This server can communicate directly with a workspace. It requires a primary coderd to establish a said connection.

func New

func New(ctx context.Context, opts *Options) (*Server, error)

New creates a new workspace proxy server. This requires a primary coderd instance to be reachable and the correct authorization access token to be provided. If the proxy cannot authenticate with the primary, this will fail.

func (*Server) Close

func (s *Server) Close() error

func (*Server) DialCoordinator added in v0.26.2

func (s *Server) DialCoordinator(ctx context.Context) (agpl.MultiAgentConn, error)

func (*Server) DialWorkspaceAgent

func (s *Server) DialWorkspaceAgent(id uuid.UUID) (*codersdk.WorkspaceAgentConn, error)

type TokenProvider

type TokenProvider struct {
	DashboardURL *url.URL
	AccessURL    *url.URL
	AppHostname  string

	Client      *wsproxysdk.Client
	SecurityKey workspaceapps.SecurityKey
	Logger      slog.Logger
}

func (*TokenProvider) FromRequest

func (p *TokenProvider) FromRequest(r *http.Request) (*workspaceapps.SignedToken, bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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