Documentation
¶
Overview ¶
Package gui provides the embedded HTTP server and app-layer adapters for the GUI.
Index ¶
- Variables
- func DefaultServerAuthConfigPath(divekitHome string) (string, error)
- func ResolveServerAuthConfigPath(configPath, divekitHome string) (string, error)
- func ResolveWorkspaceConfigPath(configPath, workingDir string) string
- func SaveServerAuthConfig(configPath string, cfg ServerAuthConfig) error
- func SaveWorkspaceConfig(configPath string, cfg WorkspaceConfig) error
- func WithAuthInfo(ctx context.Context, info AuthInfo) context.Context
- func WithWorkspace(ctx context.Context, workspace Workspace) context.Context
- type AuthInfo
- type Authenticator
- type DistributionAccess
- type Handler
- type HandlerOptions
- type Middleware
- type OriginBinding
- type ResourceShare
- type Role
- type ServerAuthBootstrapOptions
- type ServerAuthBootstrapResult
- type ServerAuthConfig
- type ServerAuthCredential
- type ServerAuthUser
- type ServerMode
- type SessionManager
- func (m *SessionManager) Create(info AuthInfo, activeWorkspaceID string) (string, error)
- func (m *SessionManager) Delete(token string)
- func (m *SessionManager) DeleteSubject(subject string)
- func (m *SessionManager) Lookup(token string) (AuthInfo, string, bool)
- func (m *SessionManager) SetActiveWorkspace(token, workspaceID string) bool
- type StaticBearerTokenOptions
- type Team
- type TeamMembership
- type Workspace
- type WorkspaceConfig
- type WorkspaceConfigEnsureOptions
- type WorkspaceMembership
Constants ¶
This section is empty.
Variables ¶
var ErrServerAuthConfigNotFound = newGUIPermanentError("gui server auth config not found", nil)
ErrServerAuthConfigNotFound indicates that the GUI auth config does not exist yet.
var ErrWorkspaceConfigNotFound = newGUIPermanentError("gui workspace config not found", nil)
ErrWorkspaceConfigNotFound indicates that the GUI workspace config does not exist yet.
Functions ¶
func DefaultServerAuthConfigPath ¶
DefaultServerAuthConfigPath returns the default GUI auth config path.
func ResolveServerAuthConfigPath ¶
ResolveServerAuthConfigPath resolves a custom or default GUI auth config path.
func ResolveWorkspaceConfigPath ¶
ResolveWorkspaceConfigPath resolves the GUI workspace config path.
func SaveServerAuthConfig ¶
func SaveServerAuthConfig(configPath string, cfg ServerAuthConfig) error
SaveServerAuthConfig validates and persists the GUI auth config in the SQLite store.
func SaveWorkspaceConfig ¶
func SaveWorkspaceConfig(configPath string, cfg WorkspaceConfig) error
SaveWorkspaceConfig validates and persists the GUI workspace config.
func WithAuthInfo ¶
WithAuthInfo stores auth info in the request context.
Types ¶
type AuthInfo ¶
type AuthInfo struct {
Mode ServerMode
Authenticated bool
Subject string
Username string
DisplayName string
Role Role
AuthMode string
}
AuthInfo captures the resolved authentication context for a request.
func AuthInfoFromContext ¶
AuthInfoFromContext returns auth info stored in the request context.
type Authenticator ¶
Authenticator validates a bearer token and returns the resolved auth info.
func NewServerAuthConfigAuthenticator ¶
func NewServerAuthConfigAuthenticator(config ServerAuthConfig) Authenticator
NewServerAuthConfigAuthenticator builds an authenticator backed by persisted GUI auth config.
func NewStaticBearerTokenAuthenticator ¶
func NewStaticBearerTokenAuthenticator(opts StaticBearerTokenOptions) Authenticator
NewStaticBearerTokenAuthenticator builds an authenticator for one static bearer token.
type DistributionAccess ¶
type DistributionAccess struct {
WorkspaceID string `json:"workspace_id"`
DistributionID string `json:"distribution_id"`
Visibility string `json:"visibility"`
TeamIDs []string `json:"team_ids,omitempty"`
}
DistributionAccess defines how a distribution is shared within a workspace.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler starts and manages the GUI server lifecycle.
func NewHandler ¶
func NewHandler(options *HandlerOptions) (*Handler, error)
NewHandler creates a GUI handler with validated options.
type HandlerOptions ¶
type HandlerOptions struct {
Host string
Port int
AssetsDir string
BrowserPath string
AuthConfigPath string
WorkspaceConfigPath string
DivekitHome string
OpenBrowser bool
WorkingDir string
Mode ServerMode
Authenticator Authenticator
WorkspaceBootstrapSubjects []string
AuthMiddleware Middleware
APIMiddlewares []Middleware
SecretStore secrets.Store
AuthenticationService authentication.Service
}
HandlerOptions configures the GUI server.
type Middleware ¶
Middleware wraps an HTTP handler with additional request processing.
func NewServerAuthConfigMiddleware ¶
func NewServerAuthConfigMiddleware(config ServerAuthConfig, realm string) Middleware
NewServerAuthConfigMiddleware creates bearer-token middleware backed by persisted GUI auth config.
func NewStaticBearerTokenMiddleware ¶
func NewStaticBearerTokenMiddleware(opts StaticBearerTokenOptions) Middleware
NewStaticBearerTokenMiddleware creates bearer-token middleware backed by a static token.
type OriginBinding ¶
type OriginBinding struct {
WorkspaceID string `json:"workspace_id"`
OriginID string `json:"origin_id"`
}
OriginBinding assigns an origin to a workspace.
type ResourceShare ¶
type ResourceShare struct {
}
ResourceShare grants additional subject or team access to a resource.
type ServerAuthBootstrapOptions ¶
type ServerAuthBootstrapOptions struct {
DivekitHome string
ConfigPath string
Subject string
Username string
DisplayName string
Password string
}
ServerAuthBootstrapOptions controls initial GUI auth bootstrapping.
type ServerAuthBootstrapResult ¶
type ServerAuthBootstrapResult struct {
ConfigPath string
Created bool
Reset bool
Subject string
Username string
DisplayName string
Role Role
Password string
PasswordGenerated bool
Token string
TokenGenerated bool
}
ServerAuthBootstrapResult describes the created bootstrap account.
func BootstrapServerAuthConfig ¶
func BootstrapServerAuthConfig(opts ServerAuthBootstrapOptions) (*ServerAuthBootstrapResult, error)
BootstrapServerAuthConfig creates a fresh GUI auth config with an admin user.
type ServerAuthConfig ¶
type ServerAuthConfig struct {
SchemaVersion int `json:"schema_version"`
Credentials []ServerAuthCredential `json:"credentials,omitempty"`
Users []ServerAuthUser `json:"users,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
ServerAuthConfig is the persisted GUI authentication configuration.
func LoadServerAuthConfig ¶
func LoadServerAuthConfig(configPath string) (ServerAuthConfig, error)
LoadServerAuthConfig loads and validates the GUI auth config from the SQLite store.
type ServerAuthCredential ¶
type ServerAuthCredential struct {
Subject string `json:"subject"`
Role Role `json:"role"`
TokenHash string `json:"token_hash"`
}
ServerAuthCredential stores a bearer-token credential entry.
type ServerAuthUser ¶
type ServerAuthUser struct {
Username string `json:"username"`
DisplayName string `json:"display_name,omitempty"`
Subject string `json:"subject,omitempty"`
Role Role `json:"role"`
PasswordHash string `json:"-"`
}
ServerAuthUser stores a password-based GUI user entry.
type ServerMode ¶
type ServerMode string
ServerMode controls how the GUI authenticates and scopes access.
const ( ServerModeLocalSingleUser ServerMode = "local-single-user" ServerModeAuthenticated ServerMode = "authenticated-server" ServerModeUnrestricted ServerMode = "unrestricted" )
Supported GUI server modes.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager stores in-memory GUI sessions.
func NewSessionManager ¶
func NewSessionManager() *SessionManager
NewSessionManager constructs a session manager with default TTLs.
func (*SessionManager) Create ¶
func (m *SessionManager) Create(info AuthInfo, activeWorkspaceID string) (string, error)
Create creates a session token for the provided auth info and workspace.
func (*SessionManager) Delete ¶
func (m *SessionManager) Delete(token string)
Delete removes a single session token.
func (*SessionManager) DeleteSubject ¶
func (m *SessionManager) DeleteSubject(subject string)
DeleteSubject removes all sessions belonging to a subject.
func (*SessionManager) Lookup ¶
func (m *SessionManager) Lookup(token string) (AuthInfo, string, bool)
Lookup resolves a session token and refreshes its idle expiry.
func (*SessionManager) SetActiveWorkspace ¶
func (m *SessionManager) SetActiveWorkspace(token, workspaceID string) bool
SetActiveWorkspace updates the active workspace for an existing session.
type StaticBearerTokenOptions ¶
StaticBearerTokenOptions configures static bearer-token authentication.
type Team ¶
type Team struct {
TeamID string `json:"team_id"`
WorkspaceID string `json:"workspace_id"`
Slug string `json:"slug"`
DisplayName string `json:"display_name"`
Description string `json:"description,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
Team defines a workspace team entry.
type TeamMembership ¶
type TeamMembership struct {
TeamID string `json:"team_id"`
Subject string `json:"subject"`
Role string `json:"role"`
CreatedAt time.Time `json:"created_at,omitempty"`
UpdatedAt time.Time `json:"updated_at,omitempty"`
}
TeamMembership assigns a subject to a team.
type Workspace ¶
type Workspace struct {
WorkspaceID string `json:"workspace_id"`
Slug string `json:"slug"`
DisplayName string `json:"display_name"`
Kind string `json:"kind"`
Implicit bool `json:"implicit"`
}
Workspace describes the workspace resolved for the current request.
func WorkspaceFromContext ¶
WorkspaceFromContext returns the workspace stored in the request context.
type WorkspaceConfig ¶
type WorkspaceConfig struct {
SchemaVersion int `json:"schema_version"`
Workspaces []Workspace `json:"workspaces"`
Memberships []WorkspaceMembership `json:"memberships"`
Origins []OriginBinding `json:"origins,omitempty"`
Distributions []DistributionAccess `json:"distributions,omitempty"`
Teams []Team `json:"teams,omitempty"`
TeamMembers []TeamMembership `json:"team_members,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
WorkspaceConfig is the persisted GUI workspace and access configuration.
func EnsureWorkspaceConfig ¶
func EnsureWorkspaceConfig(opts WorkspaceConfigEnsureOptions) (WorkspaceConfig, error)
EnsureWorkspaceConfig loads or bootstraps the GUI workspace config.
func LoadWorkspaceConfig ¶
func LoadWorkspaceConfig(configPath string) (WorkspaceConfig, error)
LoadWorkspaceConfig loads and validates the GUI workspace config from disk.
type WorkspaceConfigEnsureOptions ¶
type WorkspaceConfigEnsureOptions struct {
ConfigPath string
WorkingDir string
DefaultWorkspace Workspace
BootstrapSubjects []string
DefaultMemberRole string
}
WorkspaceConfigEnsureOptions controls default workspace config bootstrapping.
type WorkspaceMembership ¶
type WorkspaceMembership struct {
WorkspaceID string `json:"workspace_id"`
Subject string `json:"subject"`
Role string `json:"role"`
}
WorkspaceMembership assigns a subject role inside a workspace.
Source Files
¶
- actions.go
- auth.go
- auth_config.go
- auth_config_store.go
- error.go
- handler.go
- handler_auth.go
- handler_distribution_repositories.go
- handler_distributions.go
- handler_factories.go
- handler_helpers.go
- handler_managed_users.go
- handler_misc.go
- handler_origin_repositories.go
- handler_origin_scripts.go
- handler_origin_workspace.go
- handler_runs_actions.go
- handler_settings.go
- handler_sharing.go
- handler_system.go
- handler_team_helpers.go
- handler_teams.go
- handler_types.go
- handler_workspace_helpers.go
- handler_workspaces.go
- login_limiter.go
- managed_users.go
- middleware.go
- openapi_fallback_routes.gen.go
- openapi_server_adapter.go
- resource_access.go
- session.go
- workspace.go
- workspace_config.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package openapi provides primitives to interact with the openapi HTTP API.
|
Package openapi provides primitives to interact with the openapi HTTP API. |
|
Package runtime wires the GUI command entry points to the shared server runtime.
|
Package runtime wires the GUI command entry points to the shared server runtime. |