server

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VARY_HEADER = "Vary"
	DRY_RUN_ARG = "dryRun"
	PROMOTE_ARG = "promote"
)
View Source
const (
	DEFAULT_CERT_FILE = "default.crt"
	DEFAULT_KEY_FILE  = "default.key"
)
View Source
const (
	PROVIDER_NAME_DELIMITER = "_"
	SESSION_COOKIE          = "clace_session"
	AUTH_KEY                = "authenticated"
	USER_ID_KEY             = "user"
	USER_EMAIL_KEY          = "email"
	PROVIDER_NAME_KEY       = "provider_name"
	REDIRECT_URL            = "redirect"
)
View Source
const (
	REALM = "clace"
)

Variables

View Source
var CL_HOME = os.ExpandEnv("$CL_HOME")

CL_HOME is the root directory for Clace logs and temp files

View Source
var (
	COMPRESSION_ENABLED_MIME_TYPES = []string{
		"text/html",
		"text/css",
		"text/plain",
		"text/xml",
		"text/x-component",
		"text/javascript",
		"application/x-javascript",
		"application/javascript",
		"application/json",
		"application/manifest+json",
		"application/vnd.api+json",
		"application/xml",
		"application/xhtml+xml",
		"application/rss+xml",
		"application/atom+xml",
		"application/vnd.ms-fontobject",
		"application/x-font-ttf",
		"application/x-font-opentype",
		"application/x-font-truetype",
		"image/svg+xml",
		"image/x-icon",
		"image/vnd.microsoft.icon",
		"font/ttf",
		"font/eot",
		"font/otf",
		"font/opentype",
	}
)

Functions

func AddVaryHeader

func AddVaryHeader(next http.Handler) http.Handler

func GenerateSelfSignedCertificate

func GenerateSelfSignedCertificate(certPath, keyPath string, validityDuration time.Duration) error

func ParseSpec added in v0.3.0

func ParseSpec(pathSpec string, apps []utils.AppPathDomain) ([]utils.AppPathDomain, error)

ParseSpec parses a path spec in the format of domain:path. If domain is not specified, it will match empty domain. glob patters are supported, *:** matches all apps.

func ParseSpecFromInfo added in v0.3.0

func ParseSpecFromInfo(pathSpec string, apps []utils.AppInfo) ([]utils.AppInfo, error)

ParseSpecFromInfo parses a path spec in the format of domain:path. If domain is not specified, it will match empty domain. glob patters are supported, *:** matches all apps.

Types

type AdminBasicAuth

type AdminBasicAuth struct {
	*utils.Logger
	// contains filtered or unexported fields
}

AdminBasicAuth implements basic auth for the admin user account. Cache the success auth header to avoid the bcrypt hash check penalty Basic auth is supported for admin user only, and changing it requires service restart. Caching the sha of the successful auth header allows us to skip the bcrypt check which significantly improves performance.

func NewAdminBasicAuth

func NewAdminBasicAuth(logger *utils.Logger, config *utils.ServerConfig) *AdminBasicAuth

func (*AdminBasicAuth) BasicAuth

func (a *AdminBasicAuth) BasicAuth(authHeader string) (username, password string, ok bool)

type AppStore

type AppStore struct {
	*utils.Logger
	// contains filtered or unexported fields
}

AppStore is a store of apps. Apps are initialized lazily, the first GetApp call on each app will load the app from the database.

func NewAppStore

func NewAppStore(logger *utils.Logger, server *Server) *AppStore

func (*AppStore) AddApp

func (a *AppStore) AddApp(app *app.App)

func (*AppStore) ClearAllAppCache added in v0.4.5

func (a *AppStore) ClearAllAppCache()

func (*AppStore) DeleteApps added in v0.3.0

func (a *AppStore) DeleteApps(pathDomain []utils.AppPathDomain)

func (*AppStore) DeleteLinkedApps added in v0.3.0

func (a *AppStore) DeleteLinkedApps(pathDomain utils.AppPathDomain) error

func (*AppStore) GetAllApps added in v0.4.5

func (a *AppStore) GetAllApps() ([]utils.AppInfo, error)

func (*AppStore) GetApp

func (a *AppStore) GetApp(pathDomain utils.AppPathDomain) (*app.App, error)

func (*AppStore) UpdateApps added in v0.3.0

func (a *AppStore) UpdateApps(apps []*app.App)

type Handler

type Handler struct {
	*utils.Logger
	// contains filtered or unexported fields
}

func NewTCPHandler

func NewTCPHandler(logger *utils.Logger, config *utils.ServerConfig, server *Server) *Handler

NewTCPHandler creates a new handler for HTTP/HTTPS requests. App API's are mounted amd authentication is enabled. It also mounts the internal APIs if admin over TCP is enabled

func NewUDSHandler

func NewUDSHandler(logger *utils.Logger, config *utils.ServerConfig, server *Server) *Handler

NewUDSHandler creates a new handler for admin APIs over the unix domain socket

type SSOAuth added in v0.5.0

type SSOAuth struct {
	*utils.Logger
	// contains filtered or unexported fields
}

func NewSSOAuth added in v0.5.0

func NewSSOAuth(logger *utils.Logger, config *utils.ServerConfig) *SSOAuth

func (*SSOAuth) CheckAuth added in v0.5.0

func (s *SSOAuth) CheckAuth(w http.ResponseWriter, r *http.Request, appProvider string, updateRedirect bool) (bool, error)

func (*SSOAuth) RegisterRoutes added in v0.5.0

func (s *SSOAuth) RegisterRoutes(mux *chi.Mux)

func (*SSOAuth) Setup added in v0.5.0

func (s *SSOAuth) Setup() error

func (*SSOAuth) ValidateAuthType added in v0.5.0

func (s *SSOAuth) ValidateAuthType(authType string) bool

func (*SSOAuth) ValidateProviderName added in v0.5.0

func (s *SSOAuth) ValidateProviderName(provider string) bool

type Server

type Server struct {
	*utils.Logger
	// contains filtered or unexported fields
}

Server is the instance of the Clace Server

func NewServer

func NewServer(config *utils.ServerConfig) (*Server, error)

NewServer creates a new instance of the Clace Server

func (*Server) CheckAppValid added in v0.3.0

func (s *Server) CheckAppValid(domain, matchPath string) (string, error)

func (*Server) CompleteTransaction added in v0.3.0

func (s *Server) CompleteTransaction(ctx context.Context, tx metadata.Transaction, entries []utils.AppPathDomain, dryRun bool) error

func (*Server) CreateApp added in v0.2.0

func (s *Server) CreateApp(ctx context.Context, appPath string, approve, dryRun bool, appRequest utils.CreateAppRequest) (*utils.AppCreateResponse, error)

func (*Server) DeleteApps added in v0.3.0

func (s *Server) DeleteApps(ctx context.Context, pathSpec string, dryRun bool) (*utils.AppDeleteResponse, error)

func (*Server) FilterApps added in v0.3.0

func (s *Server) FilterApps(appPathSpec string, includeInternal bool) ([]utils.AppInfo, error)

func (*Server) GetApp

func (s *Server) GetApp(pathDomain utils.AppPathDomain, init bool) (*app.App, error)

func (*Server) GetAppApi added in v0.4.0

func (s *Server) GetAppApi(ctx context.Context, appPath string) (*utils.AppGetResponse, error)

func (*Server) GetAppEntry added in v0.3.0

func (s *Server) GetAppEntry(ctx context.Context, tx metadata.Transaction, pathDomain utils.AppPathDomain) (*utils.AppEntry, error)

func (*Server) GetApps added in v0.3.0

func (s *Server) GetApps(ctx context.Context, pathSpec string, internal bool) ([]utils.AppResponse, error)

func (*Server) MatchApp

func (s *Server) MatchApp(hostHeader, matchPath string) (utils.AppInfo, error)

func (*Server) PreviewApp added in v0.3.0

func (s *Server) PreviewApp(ctx context.Context, mainAppPath, commitId string, approve, dryRun bool) (*utils.AppPreviewResponse, error)

func (*Server) PromoteApps added in v0.3.0

func (s *Server) PromoteApps(ctx context.Context, pathSpec string, dryRun bool) (*utils.AppPromoteResponse, error)

func (*Server) ReloadApps added in v0.3.0

func (s *Server) ReloadApps(ctx context.Context, pathSpec string, approve, dryRun, promote bool, branch, commit, gitAuth string) (*utils.AppReloadResponse, error)

func (*Server) StagedUpdate added in v0.4.1

func (s *Server) StagedUpdate(ctx context.Context, pathSpec string, dryRun, promote bool, handler stagedUpdateHandler, args map[string]any) (*utils.AppStagedUpdateResponse, error)

func (*Server) StagedUpdateAppsTx added in v0.4.1

func (s *Server) StagedUpdateAppsTx(ctx context.Context, tx metadata.Transaction, pathSpec string, promote bool, handler stagedUpdateHandler, args map[string]any) ([]any, []utils.AppPathDomain, []utils.AppPathDomain, error)

func (*Server) Start

func (s *Server) Start() error

Start starts the Clace Server

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop stops the Clace Server

func (*Server) UpdateAppSettings added in v0.3.0

func (s *Server) UpdateAppSettings(ctx context.Context, pathSpec string, dryRun bool, updateAppRequest utils.UpdateAppRequest) (*utils.AppUpdateSettingsResponse, error)

func (*Server) VersionFiles added in v0.4.1

func (s *Server) VersionFiles(ctx context.Context, mainAppPath, version string) (*utils.AppVersionFilesResponse, error)

func (*Server) VersionList added in v0.4.1

func (s *Server) VersionList(ctx context.Context, mainAppPath string) (*utils.AppVersionListResponse, error)

func (*Server) VersionSwitch added in v0.4.1

func (s *Server) VersionSwitch(ctx context.Context, mainAppPath string, dryRun bool, version string) (*utils.AppVersionSwitchResponse, error)

Jump to

Keyboard shortcuts

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