Documentation
¶
Overview ¶
Package research provides the multi-user foundation for Prism Phase 5A.
This package implements the research user architecture with dual-user system supporting both system users (from templates) and research users (persistent across instances) for collaborative research environments.
Index ¶
- Constants
- func GetResearchUserGIDRange() (min, max int)
- func GetResearchUserUIDRange() (min, max int)
- func IsResearchUserGID(gid int) bool
- func IsResearchUserUID(uid int) bool
- type CompatibilityReport
- type CreateResearchUserOptions
- type DefaultKeyGenerator
- type DualUserIntegration
- type DualUserSystem
- type EnvironmentPolicy
- type FileKeyStore
- func (fks *FileKeyStore) DeletePublicKey(profileID, username, keyID string) error
- func (fks *FileKeyStore) GetPublicKeys(profileID, username string) (map[string][]byte, error)
- func (fks *FileKeyStore) ListKeyFingerprints(profileID, username string) ([]string, error)
- func (fks *FileKeyStore) StorePublicKey(profileID, username, keyID string, publicKey []byte) error
- type InstanceCompatibilityInfo
- type IntegrationStrategy
- type KeyGenerator
- type KeyStore
- type ProfileManager
- type ProfileManagerAdapter
- type ProfileUIDMapper
- func (mapper *ProfileUIDMapper) GetCurrentProfileUIDGID(username string) (*UIDGIDAllocation, error)
- func (mapper *ProfileUIDMapper) GetProfileUIDGID(profileID, username string) (*UIDGIDAllocation, error)
- func (mapper *ProfileUIDMapper) ListCurrentProfileAllocations() ([]*UIDGIDAllocation, error)
- func (mapper *ProfileUIDMapper) UpdateUsage(username, instanceID string) error
- type ProvisionInstanceRequest
- type ProvisioningJob
- type ProvisioningJobManager
- type ProvisioningJobStatus
- type ResearchUserConfig
- type ResearchUserManager
- func (rum *ResearchUserManager) CreateResearchUser(profileID, username string, fullName, email string) (*ResearchUserConfig, error)
- func (rum *ResearchUserManager) DeleteResearchUser(profileID, username string) error
- func (rum *ResearchUserManager) GenerateUserProvisioningScript(req *UserProvisioningRequest) (string, error)
- func (rum *ResearchUserManager) GetOrCreateResearchUser(username string) (*ResearchUserConfig, error)
- func (rum *ResearchUserManager) GetResearchUser(profileID, username string) (*ResearchUserConfig, error)
- func (rum *ResearchUserManager) ListResearchUsers() ([]*ResearchUserConfig, error)
- func (rum *ResearchUserManager) ListResearchUsersForProfile(profileID string) ([]*ResearchUserConfig, error)
- func (rum *ResearchUserManager) UpdateResearchUser(profileID string, user *ResearchUserConfig) error
- type ResearchUserProvisioner
- func (rp *ResearchUserProvisioner) ExtractSystemUsersFromTemplate(templateUserData string) []SystemUser
- func (rp *ResearchUserProvisioner) GetResearchUserStatus(ctx context.Context, instanceIP, username, sshKeyPath string) (*ResearchUserStatus, error)
- func (rp *ResearchUserProvisioner) ProvisionMultipleUsers(ctx context.Context, instanceReq *UserProvisioningRequest, usernames []string) ([]*UserProvisioningResponse, error)
- func (rp *ResearchUserProvisioner) ProvisionResearchUser(ctx context.Context, req *UserProvisioningRequest) (*UserProvisioningResponse, error)
- type ResearchUserSSHKeyManager
- func (ruskm *ResearchUserSSHKeyManager) DeleteKey(username, keyID string) error
- func (ruskm *ResearchUserSSHKeyManager) GenerateKeyPair(username, keyType string) (*SSHKeyConfig, []byte, error)
- func (ruskm *ResearchUserSSHKeyManager) ImportPublicKey(username, publicKey, comment string) (*SSHKeyConfig, error)
- func (ruskm *ResearchUserSSHKeyManager) ListKeys(username string) (map[string]*SSHKeyConfig, error)
- type ResearchUserSSHManager
- type ResearchUserService
- func (rus *ResearchUserService) CreateResearchUser(username string, options *CreateResearchUserOptions) (*ResearchUserConfig, error)
- func (rus *ResearchUserService) DeleteResearchUser(profileID, username string) error
- func (rus *ResearchUserService) ExtendTemplateWithResearchUser(templateName string, researchUserTemplate *ResearchUserTemplate) error
- func (rus *ResearchUserService) GenerateResearchUserScript(templateName, username string, options *ScriptGenerationOptions) (string, error)
- func (rus *ResearchUserService) GenerateUserProvisioningScript(req *UserProvisioningRequest) (string, error)
- func (rus *ResearchUserService) GetOrCreateResearchUser(username string) (*ResearchUserConfig, error)
- func (rus *ResearchUserService) GetRecommendedDualUserConfig(templateName string) (*DualUserSystem, error)
- func (rus *ResearchUserService) GetResearchUser(username string) (*ResearchUserConfig, error)
- func (rus *ResearchUserService) GetResearchUserHomeDirectory(username string) string
- func (rus *ResearchUserService) GetResearchUserStatus(ctx context.Context, instanceIP, username, sshKeyPath string) (*ResearchUserStatus, error)
- func (rus *ResearchUserService) GetUIDGIDForUser(username string) (*UIDGIDAllocation, error)
- func (rus *ResearchUserService) ListResearchUsers() ([]*ResearchUserConfig, error)
- func (rus *ResearchUserService) ManageSSHKeys() *ResearchUserSSHKeyManager
- func (rus *ResearchUserService) MigrateExistingUser(instanceIP, existingUser, newResearchUser, sshKeyPath string) error
- func (rus *ResearchUserService) ProvisionUserOnInstance(ctx context.Context, req *ProvisionInstanceRequest) (*UserProvisioningResponse, error)
- func (rus *ResearchUserService) UpdateResearchUser(profileID string, user *ResearchUserConfig) error
- func (rus *ResearchUserService) ValidateInstanceCompatibility(instanceInfo *InstanceCompatibilityInfo) (*CompatibilityReport, error)
- type ResearchUserServiceConfig
- type ResearchUserStatus
- type ResearchUserTemplate
- type SSHKeyConfig
- type SSHKeyManager
- func (skm *SSHKeyManager) DeletePublicKey(profileID, username, keyID string) error
- func (skm *SSHKeyManager) GenerateSSHKeyPair(profileID, username, keyType string) (*SSHKeyConfig, []byte, error)
- func (skm *SSHKeyManager) GetAuthorizedKeysContent(profileID, username string) (string, error)
- func (skm *SSHKeyManager) GetPublicKeysForUser(profileID, username string) (map[string]*SSHKeyConfig, error)
- func (skm *SSHKeyManager) ImportSSHPublicKey(profileID, username, publicKeyData, comment string) (*SSHKeyConfig, error)
- func (skm *SSHKeyManager) ListKeyFingerprints(profileID, username string) ([]string, error)
- func (skm *SSHKeyManager) UpdateKeyUsage(profileID, username, keyID string) error
- type SSHKeyType
- type ScriptGenerationOptions
- type SystemUser
- type UIDGIDAllocation
- type UIDGIDAllocator
- func (allocator *UIDGIDAllocator) AllocateUIDGID(profileID, username string) (*UIDGIDAllocation, error)
- func (allocator *UIDGIDAllocator) GetAllAllocations() ([]*UIDGIDAllocation, error)
- func (allocator *UIDGIDAllocator) GetAllocation(profileID, username string) (*UIDGIDAllocation, error)
- func (allocator *UIDGIDAllocator) ListAllocations(profileID string) ([]*UIDGIDAllocation, error)
- func (allocator *UIDGIDAllocator) ReleaseAllocation(profileID, username string) error
- func (allocator *UIDGIDAllocator) UpdateLastUsed(profileID, username, instanceID string) error
- func (allocator *UIDGIDAllocator) ValidateAllocation(uid, gid int, excludeKey string) error
- type UserIntegrationConfig
- type UserIntegrationStrategy
- type UserProvisioningRequest
- type UserProvisioningResponse
Constants ¶
const ( // Research user UID range: 5000-5999 (1000 users) ResearchUserBaseUID = 5000 ResearchUserMaxUID = 5999 // Research user GID range: 5000-5999 (matches UID) ResearchUserBaseGID = 5000 ResearchUserMaxGID = 5999 // Default group names ResearchUserGroup = "research" // Primary group for all research users ResearchAdminGroup = "research-admin" // Admin group for research user management EFSAccessGroup = "efs-users" // Group for EFS access )
UID/GID Allocation Strategy
Variables ¶
This section is empty.
Functions ¶
func GetResearchUserGIDRange ¶
func GetResearchUserGIDRange() (min, max int)
GetResearchUserGIDRange returns the GID range for research users
func GetResearchUserUIDRange ¶
func GetResearchUserUIDRange() (min, max int)
GetResearchUserUIDRange returns the UID range for research users
func IsResearchUserGID ¶
IsResearchUserGID checks if a GID is in the research user range
func IsResearchUserUID ¶
IsResearchUserUID checks if a UID is in the research user range
Types ¶
type CompatibilityReport ¶
CompatibilityReport provides the results of compatibility checking
type CreateResearchUserOptions ¶
type CreateResearchUserOptions struct {
FullName string // Full name for the user (auto-generated from username if empty)
Email string // Email address for the user (auto-generated if empty)
GenerateSSHKey bool // Automatically generate SSH key pair
ImportSSHKey string // Import existing public key
SSHKeyComment string // Comment for imported SSH key
}
CreateResearchUserOptions provides options for creating research users
type DefaultKeyGenerator ¶
type DefaultKeyGenerator struct{}
DefaultKeyGenerator implements KeyGenerator interface
func (*DefaultKeyGenerator) GenerateKeyPair ¶
func (dkg *DefaultKeyGenerator) GenerateKeyPair(keyType string, keySize int) (privateKey, publicKey []byte, err error)
GenerateKeyPair generates a new SSH key pair
func (*DefaultKeyGenerator) GetFingerprint ¶
func (dkg *DefaultKeyGenerator) GetFingerprint(publicKey []byte) (string, error)
GetFingerprint returns the SHA256 fingerprint of a public key
func (*DefaultKeyGenerator) ValidatePublicKey ¶
func (dkg *DefaultKeyGenerator) ValidatePublicKey(publicKey []byte) error
ValidatePublicKey validates that a public key is valid
type DualUserIntegration ¶
type DualUserIntegration struct {
Strategy IntegrationStrategy `json:"strategy" yaml:"strategy"`
PrimaryUser string `json:"primary_user" yaml:"primary_user"` // "research" or system user name
ServiceOwnership map[string]string `json:"service_ownership" yaml:"service_ownership"` // service -> user mapping
}
DualUserIntegration defines how research users integrate with system users
type DualUserSystem ¶
type DualUserSystem struct {
// System users (from template)
SystemUsers []SystemUser `json:"system_users" yaml:"system_users"`
// Research user (persistent across instances)
ResearchUser *ResearchUserConfig `json:"research_user" yaml:"research_user"`
// Integration settings
PrimaryUser string `json:"primary_user" yaml:"primary_user"` // Which user gets primary access
EnvironmentHandling EnvironmentPolicy `json:"environment_handling" yaml:"environment_handling"` // How to merge environments
}
DualUserSystem represents the combined system + research user configuration
type EnvironmentPolicy ¶
type EnvironmentPolicy string
EnvironmentPolicy defines how environment variables are handled
const ( // EnvironmentPolicyMerged merges template and research user environments EnvironmentPolicyMerged EnvironmentPolicy = "merged" // EnvironmentPolicyResearchPrimary prioritizes research user environment EnvironmentPolicyResearchPrimary EnvironmentPolicy = "research-primary" // EnvironmentPolicyTemplatePrimary prioritizes template environment EnvironmentPolicyTemplatePrimary EnvironmentPolicy = "template-primary" )
type FileKeyStore ¶
type FileKeyStore struct {
// contains filtered or unexported fields
}
FileKeyStore implements KeyStore interface using filesystem storage
func (*FileKeyStore) DeletePublicKey ¶
func (fks *FileKeyStore) DeletePublicKey(profileID, username, keyID string) error
DeletePublicKey removes a public key from storage
func (*FileKeyStore) GetPublicKeys ¶
func (fks *FileKeyStore) GetPublicKeys(profileID, username string) (map[string][]byte, error)
GetPublicKeys retrieves all public keys for a user
func (*FileKeyStore) ListKeyFingerprints ¶
func (fks *FileKeyStore) ListKeyFingerprints(profileID, username string) ([]string, error)
ListKeyFingerprints returns fingerprints for all keys for a user
func (*FileKeyStore) StorePublicKey ¶
func (fks *FileKeyStore) StorePublicKey(profileID, username, keyID string, publicKey []byte) error
StorePublicKey stores a public key to the filesystem
type InstanceCompatibilityInfo ¶
type InstanceCompatibilityInfo struct {
MinAvailableUID int
MaxAvailableUID int
SupportsEFS bool
HasSSHAccess bool
OSType string
KernelVersion string
}
InstanceCompatibilityInfo holds information about an instance for compatibility checking
type IntegrationStrategy ¶
type IntegrationStrategy string
IntegrationStrategy defines how research and system users work together
const ( // IntegrationStrategyPrimary - Research user is primary, system users for services only IntegrationStrategyPrimary IntegrationStrategy = "research_primary" // IntegrationStrategyCoexist - Both users coexist with shared access IntegrationStrategyCoexist IntegrationStrategy = "coexist" // IntegrationStrategySystemFirst - System user primary, research user secondary IntegrationStrategySystemFirst IntegrationStrategy = "system_first" )
type KeyGenerator ¶
type KeyGenerator interface {
GenerateKeyPair(keyType string, keySize int) (privateKey, publicKey []byte, err error)
GetFingerprint(publicKey []byte) (string, error)
ValidatePublicKey(publicKey []byte) error
}
KeyGenerator interface for generating SSH key pairs
type KeyStore ¶
type KeyStore interface {
StorePublicKey(profileID, username, keyID string, publicKey []byte) error
GetPublicKeys(profileID, username string) (map[string][]byte, error)
DeletePublicKey(profileID, username, keyID string) error
ListKeyFingerprints(profileID, username string) ([]string, error)
}
KeyStore interface for storing and retrieving SSH keys
type ProfileManager ¶
type ProfileManager interface {
GetCurrentProfile() (string, error)
GetProfileConfig(profileID string) (interface{}, error)
UpdateProfileConfig(profileID string, config interface{}) error
}
ProfileManager interface for integration with existing profile system
type ProfileManagerAdapter ¶
type ProfileManagerAdapter struct {
// contains filtered or unexported fields
}
ProfileManagerAdapter adapts the existing profile.Manager to the ProfileManager interface
func (*ProfileManagerAdapter) GetCurrentProfile ¶
func (pma *ProfileManagerAdapter) GetCurrentProfile() (string, error)
func (*ProfileManagerAdapter) GetProfileConfig ¶
func (pma *ProfileManagerAdapter) GetProfileConfig(profileID string) (interface{}, error)
func (*ProfileManagerAdapter) UpdateProfileConfig ¶
func (pma *ProfileManagerAdapter) UpdateProfileConfig(profileID string, config interface{}) error
type ProfileUIDMapper ¶
type ProfileUIDMapper struct {
// contains filtered or unexported fields
}
ProfileUIDMapper provides a higher-level interface for profile-based UID mapping
func NewProfileUIDMapper ¶
func NewProfileUIDMapper(profileMgr ProfileManager) *ProfileUIDMapper
NewProfileUIDMapper creates a new profile-based UID mapper
func (*ProfileUIDMapper) GetCurrentProfileUIDGID ¶
func (mapper *ProfileUIDMapper) GetCurrentProfileUIDGID(username string) (*UIDGIDAllocation, error)
GetCurrentProfileUIDGID gets UID/GID for a username in the current profile
func (*ProfileUIDMapper) GetProfileUIDGID ¶
func (mapper *ProfileUIDMapper) GetProfileUIDGID(profileID, username string) (*UIDGIDAllocation, error)
GetProfileUIDGID gets UID/GID for a username in a specific profile
func (*ProfileUIDMapper) ListCurrentProfileAllocations ¶
func (mapper *ProfileUIDMapper) ListCurrentProfileAllocations() ([]*UIDGIDAllocation, error)
ListCurrentProfileAllocations lists all UID/GID allocations for the current profile
func (*ProfileUIDMapper) UpdateUsage ¶
func (mapper *ProfileUIDMapper) UpdateUsage(username, instanceID string) error
UpdateUsage updates usage tracking for a user allocation
type ProvisionInstanceRequest ¶
type ProvisionInstanceRequest struct {
// Instance information
InstanceID string
InstanceName string
PublicIP string
// Template information
TemplateName string
SystemUsers []SystemUser
// Research user
Username string
// EFS integration
EFSVolumeID string
EFSMountPoint string
// SSH connection
SSHKeyPath string
SSHUser string
}
ProvisionInstanceRequest represents a request to provision a research user on an instance
type ProvisioningJob ¶
type ProvisioningJob struct {
ID string `json:"id"`
Status ProvisioningJobStatus `json:"status"`
StartTime time.Time `json:"start_time"`
EndTime *time.Time `json:"end_time,omitempty"`
Request *UserProvisioningRequest `json:"request"`
Response *UserProvisioningResponse `json:"response,omitempty"`
Error string `json:"error,omitempty"`
Progress float64 `json:"progress"` // 0.0 to 1.0
}
ProvisioningJob represents an asynchronous provisioning job
type ProvisioningJobManager ¶
type ProvisioningJobManager struct {
// contains filtered or unexported fields
}
ProvisioningJobManager manages asynchronous provisioning jobs
func NewProvisioningJobManager ¶
func NewProvisioningJobManager(provisioner *ResearchUserProvisioner) *ProvisioningJobManager
NewProvisioningJobManager creates a new provisioning job manager
func (*ProvisioningJobManager) GetJob ¶
func (pjm *ProvisioningJobManager) GetJob(jobID string) (*ProvisioningJob, error)
GetJob retrieves a provisioning job by ID Returns a copy of the job to avoid data races when reading job fields
func (*ProvisioningJobManager) ListJobs ¶
func (pjm *ProvisioningJobManager) ListJobs() []*ProvisioningJob
ListJobs lists all provisioning jobs Returns copies of jobs to avoid data races when reading job fields
func (*ProvisioningJobManager) SubmitProvisioningJob ¶
func (pjm *ProvisioningJobManager) SubmitProvisioningJob(req *UserProvisioningRequest) (*ProvisioningJob, error)
SubmitProvisioningJob submits a new asynchronous provisioning job Returns a copy of the job to avoid data races when reading job fields
type ProvisioningJobStatus ¶
type ProvisioningJobStatus string
ProvisioningJobStatus represents the status of a provisioning job
const ( ProvisioningJobStatusPending ProvisioningJobStatus = "pending" ProvisioningJobStatusRunning ProvisioningJobStatus = "running" ProvisioningJobStatusCompleted ProvisioningJobStatus = "completed" ProvisioningJobStatusFailed ProvisioningJobStatus = "failed" ProvisioningJobStatusCanceled ProvisioningJobStatus = "canceled" )
type ResearchUserConfig ¶
type ResearchUserConfig struct {
// Basic user information
Username string `json:"username" yaml:"username"`
UID int `json:"uid" yaml:"uid"` // Consistent across instances
GID int `json:"gid" yaml:"gid"` // Primary group ID
FullName string `json:"full_name" yaml:"full_name"`
Email string `json:"email" yaml:"email"`
// Home directory configuration
HomeDirectory string `json:"home_directory" yaml:"home_directory"` // Path on EFS volume
EFSVolumeID string `json:"efs_volume_id" yaml:"efs_volume_id"` // EFS volume for home dir
EFSMountPoint string `json:"efs_mount_point" yaml:"efs_mount_point"` // Where EFS is mounted
Shell string `json:"shell" yaml:"shell"` // Default shell
CreateHomeDir bool `json:"create_home_dir" yaml:"create_home_dir"` // Auto-create home directory
// SSH key management
SSHPublicKeys []string `json:"ssh_public_keys" yaml:"ssh_public_keys"` // Authorized public keys
SSHKeyFingerprint string `json:"ssh_key_fingerprint" yaml:"ssh_key_fingerprint"` // Primary key fingerprint
// Groups and permissions
SecondaryGroups []string `json:"secondary_groups" yaml:"secondary_groups"` // Additional groups
SudoAccess bool `json:"sudo_access" yaml:"sudo_access"` // Sudo permissions
DockerAccess bool `json:"docker_access" yaml:"docker_access"` // Docker group access
// Research environment preferences
DefaultEnvironment map[string]string `json:"default_environment" yaml:"default_environment"` // Environment variables
DotfileRepo string `json:"dotfile_repo" yaml:"dotfile_repo"` // Git repo for dotfiles
// Metadata
CreatedAt time.Time `json:"created_at" yaml:"created_at"`
LastUsed *time.Time `json:"last_used" yaml:"last_used"`
ProfileOwner string `json:"profile_owner" yaml:"profile_owner"` // Profile that owns this user
}
ResearchUserConfig represents the configuration for a research user that persists across instances and EFS volumes
type ResearchUserManager ¶
type ResearchUserManager struct {
// contains filtered or unexported fields
}
ResearchUserManager handles research user lifecycle management
func NewResearchUserManager ¶
func NewResearchUserManager(profileMgr ProfileManager, configDir string) *ResearchUserManager
NewResearchUserManager creates a new research user manager
func (*ResearchUserManager) CreateResearchUser ¶
func (rum *ResearchUserManager) CreateResearchUser(profileID, username string, fullName, email string) (*ResearchUserConfig, error)
CreateResearchUser creates a new research user for the specified profile
func (*ResearchUserManager) DeleteResearchUser ¶
func (rum *ResearchUserManager) DeleteResearchUser(profileID, username string) error
DeleteResearchUser removes a research user configuration
func (*ResearchUserManager) GenerateUserProvisioningScript ¶
func (rum *ResearchUserManager) GenerateUserProvisioningScript(req *UserProvisioningRequest) (string, error)
GenerateUserProvisioningScript generates a shell script to provision the research user on an instance
func (*ResearchUserManager) GetOrCreateResearchUser ¶
func (rum *ResearchUserManager) GetOrCreateResearchUser(username string) (*ResearchUserConfig, error)
GetOrCreateResearchUser gets or creates a research user for the current profile
func (*ResearchUserManager) GetResearchUser ¶
func (rum *ResearchUserManager) GetResearchUser(profileID, username string) (*ResearchUserConfig, error)
GetResearchUser retrieves a research user for the specified profile
func (*ResearchUserManager) ListResearchUsers ¶
func (rum *ResearchUserManager) ListResearchUsers() ([]*ResearchUserConfig, error)
ListResearchUsers lists all research users for the current profile
func (*ResearchUserManager) ListResearchUsersForProfile ¶
func (rum *ResearchUserManager) ListResearchUsersForProfile(profileID string) ([]*ResearchUserConfig, error)
ListResearchUsersForProfile lists all research users for a specific profile
func (*ResearchUserManager) UpdateResearchUser ¶
func (rum *ResearchUserManager) UpdateResearchUser(profileID string, user *ResearchUserConfig) error
UpdateResearchUser updates an existing research user
type ResearchUserProvisioner ¶
type ResearchUserProvisioner struct {
// contains filtered or unexported fields
}
ResearchUserProvisioner handles provisioning research users on instances
func NewResearchUserProvisioner ¶
func NewResearchUserProvisioner(userMgr *ResearchUserManager, uidMapper *ProfileUIDMapper, sshKeyMgr *SSHKeyManager) *ResearchUserProvisioner
NewResearchUserProvisioner creates a new research user provisioner
func (*ResearchUserProvisioner) ExtractSystemUsersFromTemplate ¶
func (rp *ResearchUserProvisioner) ExtractSystemUsersFromTemplate(templateUserData string) []SystemUser
ExtractSystemUsersFromTemplate extracts system user information from template user data
func (*ResearchUserProvisioner) GetResearchUserStatus ¶
func (rp *ResearchUserProvisioner) GetResearchUserStatus(ctx context.Context, instanceIP, username, sshKeyPath string) (*ResearchUserStatus, error)
GetResearchUserStatus checks the status of a research user on an instance
func (*ResearchUserProvisioner) ProvisionMultipleUsers ¶
func (rp *ResearchUserProvisioner) ProvisionMultipleUsers(ctx context.Context, instanceReq *UserProvisioningRequest, usernames []string) ([]*UserProvisioningResponse, error)
ProvisionMultipleUsers provisions multiple research users on an instance
func (*ResearchUserProvisioner) ProvisionResearchUser ¶
func (rp *ResearchUserProvisioner) ProvisionResearchUser(ctx context.Context, req *UserProvisioningRequest) (*UserProvisioningResponse, error)
ProvisionResearchUser provisions a research user on an instance
type ResearchUserSSHKeyManager ¶
type ResearchUserSSHKeyManager struct {
// contains filtered or unexported fields
}
ResearchUserSSHKeyManager provides SSH key management operations
func (*ResearchUserSSHKeyManager) DeleteKey ¶
func (ruskm *ResearchUserSSHKeyManager) DeleteKey(username, keyID string) error
DeleteKey removes an SSH key
func (*ResearchUserSSHKeyManager) GenerateKeyPair ¶
func (ruskm *ResearchUserSSHKeyManager) GenerateKeyPair(username, keyType string) (*SSHKeyConfig, []byte, error)
GenerateKeyPair generates a new SSH key pair for a research user
func (*ResearchUserSSHKeyManager) ImportPublicKey ¶
func (ruskm *ResearchUserSSHKeyManager) ImportPublicKey(username, publicKey, comment string) (*SSHKeyConfig, error)
ImportPublicKey imports an existing SSH public key
func (*ResearchUserSSHKeyManager) ListKeys ¶
func (ruskm *ResearchUserSSHKeyManager) ListKeys(username string) (map[string]*SSHKeyConfig, error)
ListKeys lists all SSH keys for a research user
type ResearchUserSSHManager ¶
type ResearchUserSSHManager struct {
// contains filtered or unexported fields
}
ResearchUserSSHManager provides high-level SSH key management for research users
func NewResearchUserSSHManager ¶
func NewResearchUserSSHManager(sshKeyMgr *SSHKeyManager, userMgr *ResearchUserManager) *ResearchUserSSHManager
NewResearchUserSSHManager creates a new research user SSH manager
func (*ResearchUserSSHManager) GetSSHKeysForProvisioning ¶
func (rusm *ResearchUserSSHManager) GetSSHKeysForProvisioning(profileID, username string) ([]string, error)
GetSSHKeysForProvisioning gets SSH keys formatted for provisioning scripts
func (*ResearchUserSSHManager) SetupSSHKeysForUser ¶
func (rusm *ResearchUserSSHManager) SetupSSHKeysForUser(profileID, username string) error
SetupSSHKeysForUser sets up SSH keys for a research user
type ResearchUserService ¶
type ResearchUserService struct {
// contains filtered or unexported fields
}
ResearchUserService provides the main service layer for research user management This integrates all research user components into a single, easy-to-use interface
func CreateDefaultResearchUserService ¶
func CreateDefaultResearchUserService(profileMgr interface {
GetCurrentProfile() (*profile.Profile, error)
GetProfile(name string) (*profile.Profile, error)
UpdateProfile(profile *profile.Profile) error
}) *ResearchUserService
CreateDefaultResearchUserService creates a research user service with default configuration
func NewResearchUserService ¶
func NewResearchUserService(config *ResearchUserServiceConfig) *ResearchUserService
NewResearchUserService creates a new research user service with all components integrated
func (*ResearchUserService) CreateResearchUser ¶
func (rus *ResearchUserService) CreateResearchUser(username string, options *CreateResearchUserOptions) (*ResearchUserConfig, error)
CreateResearchUser creates a new research user with full setup
func (*ResearchUserService) DeleteResearchUser ¶
func (rus *ResearchUserService) DeleteResearchUser(profileID, username string) error
DeleteResearchUser provides access to the underlying user manager functionality
func (*ResearchUserService) ExtendTemplateWithResearchUser ¶
func (rus *ResearchUserService) ExtendTemplateWithResearchUser(templateName string, researchUserTemplate *ResearchUserTemplate) error
ExtendTemplateWithResearchUser extends a template configuration to include research user support
func (*ResearchUserService) GenerateResearchUserScript ¶
func (rus *ResearchUserService) GenerateResearchUserScript(templateName, username string, options *ScriptGenerationOptions) (string, error)
GenerateResearchUserScript generates a complete provisioning script for an instance
func (*ResearchUserService) GenerateUserProvisioningScript ¶
func (rus *ResearchUserService) GenerateUserProvisioningScript(req *UserProvisioningRequest) (string, error)
GenerateUserProvisioningScript provides access to provisioning script generation
func (*ResearchUserService) GetOrCreateResearchUser ¶
func (rus *ResearchUserService) GetOrCreateResearchUser(username string) (*ResearchUserConfig, error)
GetOrCreateResearchUser provides access to the underlying user manager functionality
func (*ResearchUserService) GetRecommendedDualUserConfig ¶
func (rus *ResearchUserService) GetRecommendedDualUserConfig(templateName string) (*DualUserSystem, error)
GetRecommendedDualUserConfig returns recommended dual user configuration for a template
func (*ResearchUserService) GetResearchUser ¶
func (rus *ResearchUserService) GetResearchUser(username string) (*ResearchUserConfig, error)
GetResearchUser retrieves a research user for the current profile
func (*ResearchUserService) GetResearchUserHomeDirectory ¶
func (rus *ResearchUserService) GetResearchUserHomeDirectory(username string) string
GetResearchUserHomeDirectory returns the EFS home directory path for a research user
func (*ResearchUserService) GetResearchUserStatus ¶
func (rus *ResearchUserService) GetResearchUserStatus(ctx context.Context, instanceIP, username, sshKeyPath string) (*ResearchUserStatus, error)
GetResearchUserStatus gets the status of a research user on an instance
func (*ResearchUserService) GetUIDGIDForUser ¶
func (rus *ResearchUserService) GetUIDGIDForUser(username string) (*UIDGIDAllocation, error)
GetUIDGIDForUser gets the consistent UID/GID for a research user
func (*ResearchUserService) ListResearchUsers ¶
func (rus *ResearchUserService) ListResearchUsers() ([]*ResearchUserConfig, error)
ListResearchUsers lists all research users for the current profile
func (*ResearchUserService) ManageSSHKeys ¶
func (rus *ResearchUserService) ManageSSHKeys() *ResearchUserSSHKeyManager
ManageSSHKeys provides SSH key management functionality
func (*ResearchUserService) MigrateExistingUser ¶
func (rus *ResearchUserService) MigrateExistingUser(instanceIP, existingUser, newResearchUser, sshKeyPath string) error
MigrateExistingUser migrates an existing system user to research user
func (*ResearchUserService) ProvisionUserOnInstance ¶
func (rus *ResearchUserService) ProvisionUserOnInstance(ctx context.Context, req *ProvisionInstanceRequest) (*UserProvisioningResponse, error)
ProvisionUserOnInstance provisions a research user on a specific instance
func (*ResearchUserService) UpdateResearchUser ¶
func (rus *ResearchUserService) UpdateResearchUser(profileID string, user *ResearchUserConfig) error
UpdateResearchUser provides access to the underlying user manager functionality
func (*ResearchUserService) ValidateInstanceCompatibility ¶
func (rus *ResearchUserService) ValidateInstanceCompatibility(instanceInfo *InstanceCompatibilityInfo) (*CompatibilityReport, error)
ValidateInstanceCompatibility checks if an instance is compatible with research users
type ResearchUserServiceConfig ¶
type ResearchUserServiceConfig struct {
ConfigDir string // Base configuration directory
ProfileMgr ProfileManager // Profile manager interface
}
ResearchUserServiceConfig holds configuration for the research user service
type ResearchUserStatus ¶
type ResearchUserStatus struct {
Username string `json:"username"`
InstanceID string `json:"instance_id"`
InstanceName string `json:"instance_name"`
HomeDirectoryPath string `json:"home_directory_path"`
EFSMounted bool `json:"efs_mounted"`
SSHAccessible bool `json:"ssh_accessible"`
LastLogin *time.Time `json:"last_login"`
ActiveProcesses int `json:"active_processes"`
DiskUsage int64 `json:"disk_usage"` // Bytes
}
ResearchUserStatus represents the current status of a research user on an instance
type ResearchUserTemplate ¶
type ResearchUserTemplate struct {
// Auto-create research user if not exists
AutoCreate bool `json:"auto_create" yaml:"auto_create"`
// Research user defaults for this template
DefaultShell string `json:"default_shell" yaml:"default_shell"`
DefaultGroups []string `json:"default_groups" yaml:"default_groups"`
DefaultEnvironment map[string]string `json:"default_environment" yaml:"default_environment"`
// EFS integration
RequireEFS bool `json:"require_efs" yaml:"require_efs"`
EFSMountPoint string `json:"efs_mount_point" yaml:"efs_mount_point"`
EFSHomeSubdirectory string `json:"efs_home_subdirectory" yaml:"efs_home_subdirectory"`
// SSH configuration
InstallSSHKeys bool `json:"install_ssh_keys" yaml:"install_ssh_keys"`
// Integration with system users
UserIntegration DualUserIntegration `json:"user_integration" yaml:"user_integration"`
}
ResearchUserTemplate represents research user configuration in templates
type SSHKeyConfig ¶
type SSHKeyConfig struct {
KeyID string `json:"key_id"`
ProfileID string `json:"profile_id"` // Which profile owns this key
Username string `json:"username"` // Username this key belongs to
KeyType SSHKeyType `json:"key_type"` // Type of SSH key (rsa, ed25519)
Fingerprint string `json:"fingerprint"`
PublicKey string `json:"public_key"`
Comment string `json:"comment"`
CreatedAt time.Time `json:"created_at"`
LastUsed *time.Time `json:"last_used"`
FromProfile string `json:"from_profile"` // Which profile added this key
AutoGenerated bool `json:"auto_generated"` // Was this key auto-generated
}
SSHKeyConfig represents SSH key configuration for a research user
type SSHKeyManager ¶
type SSHKeyManager struct {
// contains filtered or unexported fields
}
SSHKeyManager handles SSH key generation, storage, and distribution for research users
func NewSSHKeyManager ¶
func NewSSHKeyManager(basePath string) *SSHKeyManager
NewSSHKeyManager creates a new SSH key manager
func (*SSHKeyManager) DeletePublicKey ¶
func (skm *SSHKeyManager) DeletePublicKey(profileID, username, keyID string) error
DeletePublicKey removes a public key for a research user
func (*SSHKeyManager) GenerateSSHKeyPair ¶
func (skm *SSHKeyManager) GenerateSSHKeyPair(profileID, username, keyType string) (*SSHKeyConfig, []byte, error)
GenerateSSHKeyPair generates a new SSH key pair for a research user
func (*SSHKeyManager) GetAuthorizedKeysContent ¶
func (skm *SSHKeyManager) GetAuthorizedKeysContent(profileID, username string) (string, error)
GetAuthorizedKeysContent generates authorized_keys file content for a research user
func (*SSHKeyManager) GetPublicKeysForUser ¶
func (skm *SSHKeyManager) GetPublicKeysForUser(profileID, username string) (map[string]*SSHKeyConfig, error)
GetPublicKeysForUser retrieves all public keys for a research user
func (*SSHKeyManager) ImportSSHPublicKey ¶
func (skm *SSHKeyManager) ImportSSHPublicKey(profileID, username, publicKeyData, comment string) (*SSHKeyConfig, error)
ImportSSHPublicKey imports an existing SSH public key for a research user
func (*SSHKeyManager) ListKeyFingerprints ¶
func (skm *SSHKeyManager) ListKeyFingerprints(profileID, username string) ([]string, error)
ListKeyFingerprints returns a list of key fingerprints for a user
func (*SSHKeyManager) UpdateKeyUsage ¶
func (skm *SSHKeyManager) UpdateKeyUsage(profileID, username, keyID string) error
UpdateKeyUsage updates the last used timestamp for a key
type SSHKeyType ¶
type SSHKeyType string
SSHKeyType represents the type of SSH key
const ( // SSHKeyTypeEd25519 represents Ed25519 SSH keys SSHKeyTypeEd25519 SSHKeyType = "ed25519" // SSHKeyTypeRSA represents RSA SSH keys SSHKeyTypeRSA SSHKeyType = "rsa" )
type ScriptGenerationOptions ¶
type ScriptGenerationOptions struct {
InstanceID string
InstanceName string
EFSVolumeID string
EFSMountPoint string
GenerateSSHKeys bool
}
ScriptGenerationOptions provides options for script generation
type SystemUser ¶
type SystemUser struct {
Name string `json:"name" yaml:"name"`
UID int `json:"uid" yaml:"uid"` // May vary by instance
GID int `json:"gid" yaml:"gid"`
Groups []string `json:"groups" yaml:"groups"`
Shell string `json:"shell" yaml:"shell"`
HomeDirectory string `json:"home_directory" yaml:"home_directory"`
Environment map[string]string `json:"environment" yaml:"environment"`
Purpose string `json:"purpose" yaml:"purpose"` // e.g., "jupyter", "system", "application"
TemplateCreated bool `json:"template_created" yaml:"template_created"` // Created by template vs system
}
SystemUser represents a user created by the template (e.g., ubuntu, researcher, rocky)
type UIDGIDAllocation ¶
type UIDGIDAllocation struct {
ProfileID string `json:"profile_id"`
Username string `json:"username"`
UID int `json:"uid"`
GID int `json:"gid"`
AllocatedAt int64 `json:"allocated_at"`
LastUsed int64 `json:"last_used"`
InstancesUsed []string `json:"instances_used,omitempty"`
}
UIDGIDAllocation represents an allocated UID/GID pair
type UIDGIDAllocator ¶
type UIDGIDAllocator struct {
// contains filtered or unexported fields
}
UIDGIDAllocator manages consistent UID/GID allocation across instances
func NewUIDGIDAllocator ¶
func NewUIDGIDAllocator() *UIDGIDAllocator
NewUIDGIDAllocator creates a new UID/GID allocator
func (*UIDGIDAllocator) AllocateUIDGID ¶
func (allocator *UIDGIDAllocator) AllocateUIDGID(profileID, username string) (*UIDGIDAllocation, error)
AllocateUIDGID allocates a consistent UID/GID for a profile/username combination
func (*UIDGIDAllocator) GetAllAllocations ¶
func (allocator *UIDGIDAllocator) GetAllAllocations() ([]*UIDGIDAllocation, error)
GetAllAllocations returns all allocations across all profiles
func (*UIDGIDAllocator) GetAllocation ¶
func (allocator *UIDGIDAllocator) GetAllocation(profileID, username string) (*UIDGIDAllocation, error)
GetAllocation retrieves an existing UID/GID allocation
func (*UIDGIDAllocator) ListAllocations ¶
func (allocator *UIDGIDAllocator) ListAllocations(profileID string) ([]*UIDGIDAllocation, error)
ListAllocations returns all allocations for a profile
func (*UIDGIDAllocator) ReleaseAllocation ¶
func (allocator *UIDGIDAllocator) ReleaseAllocation(profileID, username string) error
ReleaseAllocation removes an allocation (for cleanup)
func (*UIDGIDAllocator) UpdateLastUsed ¶
func (allocator *UIDGIDAllocator) UpdateLastUsed(profileID, username, instanceID string) error
UpdateLastUsed updates the last used timestamp and instance list for an allocation
func (*UIDGIDAllocator) ValidateAllocation ¶
func (allocator *UIDGIDAllocator) ValidateAllocation(uid, gid int, excludeKey string) error
ValidateAllocation checks if a UID/GID allocation is valid and available
type UserIntegrationConfig ¶
type UserIntegrationConfig struct {
Strategy UserIntegrationStrategy `json:"strategy"`
PreserveExisting bool `json:"preserve_existing"`
EnableSudo bool `json:"enable_sudo"`
}
UserIntegrationConfig defines integration configuration
type UserIntegrationStrategy ¶
type UserIntegrationStrategy string
UserIntegrationStrategy defines how to integrate research users
const ( // UserIntegrationStrategyDualUser combines system and research users UserIntegrationStrategyDualUser UserIntegrationStrategy = "dual-user" // UserIntegrationStrategyResearchOnly uses only research users UserIntegrationStrategyResearchOnly UserIntegrationStrategy = "research-only" )
type UserProvisioningRequest ¶
type UserProvisioningRequest struct {
// Instance information
InstanceID string `json:"instance_id"`
InstanceName string `json:"instance_name"`
PublicIP string `json:"public_ip"`
// Template information
TemplateName string `json:"template_name"`
SystemUsers []SystemUser `json:"system_users"`
// Research user to provision
ResearchUser *ResearchUserConfig `json:"research_user"`
// EFS integration
EFSVolumeID string `json:"efs_volume_id"`
EFSMountPoint string `json:"efs_mount_point"`
// SSH connection info
SSHKeyPath string `json:"ssh_key_path"`
SSHUser string `json:"ssh_user"` // Initial user for connection (e.g., ubuntu)
}
UserProvisioningRequest represents a request to provision a research user on an instance
type UserProvisioningResponse ¶
type UserProvisioningResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
CreatedUsers []string `json:"created_users"`
ConfiguredEFS bool `json:"configured_efs"`
SSHKeysInstalled bool `json:"ssh_keys_installed"`
ErrorDetails string `json:"error_details,omitempty"`
}
UserProvisioningResponse represents the result of user provisioning