Documentation
¶
Overview ¶
Package gui provides the embedded HTTP server and app-layer adapters for the GUI.
Index ¶
- Constants
- Variables
- func DefaultServerAuthConfigPath(divekitHome string) (string, error)
- func GenerateSetupCode() (string, error)
- func ResolveManagedStatePaths(options HandlerOptions) ([]string, error)
- func ResolveServerAuthConfigPath(configPath, divekitHome string) (string, error)
- func ResolveWorkspaceConfigPath(configPath, workingDir string) string
- func SaveServerAuthConfig(ctx context.Context, 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 ExecutionAuthorityResolver
- 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) DeleteAll()
- 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 ¶
const DefaultSetupCodeTTL = 30 * time.Minute
DefaultSetupCodeTTL is how long a first-admin setup code stays valid.
Variables ¶
var ErrServerAuthConfigLegacyUnreadable error = serverAuthLegacyUnreadableSentinel{}
ErrServerAuthConfigLegacyUnreadable identifies malformed or otherwise unreadable legacy auth bytes. A valid destination is not silently accepted while this source remains present; explicit reset or source repair is required.
var ErrServerAuthConfigMigrationConflict error = serverAuthMigrationConflictSentinel{}
ErrServerAuthConfigMigrationConflict identifies a legacy and destination auth state that require an explicit operator choice.
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 GenerateSetupCode ¶
GenerateSetupCode returns a random one-time setup code such as "K7QXM-4PD2R-WN9HT-E3VBC" (about 99 bits of entropy).
func ResolveManagedStatePaths ¶
func ResolveManagedStatePaths(options HandlerOptions) ([]string, error)
ResolveManagedStatePaths returns every exact user-state path that managed startup may touch before the HTTP server begins serving requests. The caller owns these paths through coordination.ManagedOwnerRegistry before auth bootstrap or workspace initialization starts.
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(ctx context.Context, configPath string, cfg ServerAuthConfig) error
SaveServerAuthConfig validates and persists the GUI auth config in the SQLite store. Direct saves receive the same short exact-path admission as migration; callers with an outer home/auth lease reuse both claims.
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
// LoginAuthMode is the AuthMode of the credential a session was signed in
// with. A session request reports AuthMode "session", which hides whether
// a shared token or a personal password stands behind it.
LoginAuthMode string
AuthReference 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 ExecutionAuthorityResolver ¶
type ExecutionAuthorityResolver func(ctx context.Context, subject, authMode, authReference string) (Role, error)
ExecutionAuthorityResolver resolves the current non-secret authority for a queued actor. Auth references identify an auth record without persisting a password, bearer token, or token hash.
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
ResolveExecutionAuthority ExecutionAuthorityResolver
AuthMiddleware Middleware
APIMiddlewares []Middleware
SecretStore secretstore.Store
AuthenticationService authentication.Service
// OwnerRegistry is supplied by managed runtime startup after it has
// claimed every state path touched by auth and workspace bootstrap.
OwnerRegistry *coordination.ManagedOwnerRegistry
// SetupCode, when set in authenticated mode, gates the first-admin
// bootstrap of a server that starts without users. SetupCodeTTL bounds
// its lifetime (default DefaultSetupCodeTTL).
SetupCode string
SetupCodeTTL time.Duration
}
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(ctx context.Context, 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(ctx context.Context, configPath string) (ServerAuthConfig, error)
LoadServerAuthConfig loads and validates the GUI auth config from the SQLite store. The exact auth path is admitted here for direct callers. Managed callers already hold the same claim and reuse it through the context.
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) DeleteAll ¶
func (m *SessionManager) DeleteAll()
DeleteAll removes every active session.
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
¶
- access_memberships.go
- access_module_adapter.go
- access_rules.go
- access_store.go
- access_subjects.go
- access_teams.go
- actions.go
- assessment_reads.go
- assets.go
- auth.go
- auth_config.go
- auth_config_errors.go
- auth_config_migration.go
- auth_config_store.go
- bounded_compute.go
- coordination.go
- error.go
- handler.go
- handler_assessment_balance.go
- handler_assessment_decisions.go
- handler_assessment_results.go
- handler_auth.go
- handler_distribution_activity.go
- handler_distribution_assessments.go
- handler_distribution_group_paths.go
- handler_distribution_overrides.go
- handler_distribution_passcheck.go
- handler_distribution_repositories.go
- handler_distribution_scope.go
- handler_distribution_series.go
- handler_distributions.go
- handler_factories.go
- handler_feedback.go
- handler_feedback_update.go
- handler_helpers.go
- handler_individuals.go
- handler_managed_users.go
- handler_members.go
- handler_misc.go
- handler_origin_check.go
- handler_origin_file_open.go
- handler_origin_repositories.go
- handler_origin_scripts.go
- handler_origin_summary.go
- handler_origin_workspace.go
- handler_override_plan.go
- handler_plan_actions.go
- handler_plugin_plans.go
- handler_plugin_sources.go
- handler_plugin_wizard.go
- handler_plugins.go
- handler_plugins_overview.go
- handler_repository_actions.go
- handler_runs_actions.go
- handler_settings.go
- handler_settlement.go
- handler_setup_code.go
- handler_sharing.go
- handler_system.go
- handler_team_helpers.go
- handler_teams.go
- handler_template_files.go
- handler_types.go
- handler_workspace_helpers.go
- handler_workspaces.go
- login_limiter.go
- managed_state_paths.go
- managed_users.go
- middleware.go
- openapi_action_input.go
- openapi_dispatch.gen.go
- openapi_fallback_routes.gen.go
- openapi_run_views.go
- openapi_server_adapter.go
- origin_file_path.go
- origin_insights.go
- plan_broker.go
- plan_broker_feedback.go
- plan_broker_layout.go
- plan_broker_override.go
- plan_broker_purge.go
- plan_store.go
- plugin_plan_store.go
- plugins_errors.go
- plugins_types.go
- queued_action_authorization.go
- render_cache.go
- resource_access.go
- response_compression.go
- response_deadline.go
- session.go
- setup_code.go
- workspace.go
- workspace_config.go
- workspace_state.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 starts the GUI server from explicit process options.
|
Package runtime starts the GUI server from explicit process options. |