Documentation
¶
Index ¶
- type CLIHandler
- type Manager
- func (m *Manager) AddPolicy(policy *Policy) error
- func (m *Manager) AddPolicySet(policySet *PolicySet) error
- func (m *Manager) AssignPolicySet(userID, policySetID string) error
- func (m *Manager) CheckResearchUserAction(userID, action, username string, profileID string) *PolicyResponse
- func (m *Manager) CheckTemplateAccess(userID, templateName string, profileID string) *PolicyResponse
- func (m *Manager) CreateDefaultPolicySets() error
- func (m *Manager) EvaluatePolicy(request *PolicyRequest) *PolicyResponse
- func (m *Manager) GetProfileUserID() string
- type Policy
- type PolicyEffect
- type PolicyRequest
- type PolicyResponse
- type PolicySet
- type PolicyType
- type ResearchUserPolicy
- type ResourceLimitsPolicy
- type Service
- func (s *Service) AssignResearcherPolicies() error
- func (s *Service) AssignStudentPolicies() error
- func (s *Service) CheckResearchUserCreation(username string) *PolicyResponse
- func (s *Service) CheckResearchUserDeletion(username string) *PolicyResponse
- func (s *Service) CheckTemplateAccess(templateName string) *PolicyResponse
- func (s *Service) CreateCustomPolicy(policy *Policy) error
- func (s *Service) GetCurrentUserPolicies() []string
- func (s *Service) GetManager() *Manager
- func (s *Service) GetPolicyViolationMessage(response *PolicyResponse, action string) string
- func (s *Service) IsEnabled() bool
- func (s *Service) ListAvailablePolicySets() map[string]*PolicySet
- func (s *Service) SetEnabled(enabled bool)
- func (s *Service) ValidateTemplateAccess(templates []string) ([]string, []string)
- type TemplateAccessPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CLIHandler ¶
type CLIHandler struct {
// contains filtered or unexported fields
}
CLIHandler provides command-line interface for policy management
func NewCLIHandler ¶
func NewCLIHandler(service *Service) *CLIHandler
NewCLIHandler creates a new CLI handler for policies
func (*CLIHandler) HandlePolicyCommand ¶
func (h *CLIHandler) HandlePolicyCommand(args []string) error
HandlePolicyCommand processes policy-related CLI commands
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles policy evaluation and enforcement
func (*Manager) AddPolicySet ¶
AddPolicySet adds a policy set to the manager
func (*Manager) AssignPolicySet ¶
AssignPolicySet assigns a policy set to a user
func (*Manager) CheckResearchUserAction ¶
func (m *Manager) CheckResearchUserAction(userID, action, username string, profileID string) *PolicyResponse
CheckResearchUserAction is a convenience method for checking research user actions
func (*Manager) CheckTemplateAccess ¶
func (m *Manager) CheckTemplateAccess(userID, templateName string, profileID string) *PolicyResponse
CheckTemplateAccess is a convenience method for checking template access
func (*Manager) CreateDefaultPolicySets ¶
CreateDefaultPolicySets creates example policy sets for different user types
func (*Manager) EvaluatePolicy ¶
func (m *Manager) EvaluatePolicy(request *PolicyRequest) *PolicyResponse
EvaluatePolicy evaluates a policy request and returns the decision
func (*Manager) GetProfileUserID ¶
GetProfileUserID returns a user identifier for policy evaluation This integrates with the existing profile system
type Policy ¶
type Policy struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Type PolicyType `json:"type" yaml:"type"`
Effect PolicyEffect `json:"effect" yaml:"effect"`
Conditions map[string]interface{} `json:"conditions,omitempty" yaml:"conditions,omitempty"`
Resources []string `json:"resources,omitempty" yaml:"resources,omitempty"`
Actions []string `json:"actions,omitempty" yaml:"actions,omitempty"`
CreatedAt time.Time `json:"created_at" yaml:"created_at"`
UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
Enabled bool `json:"enabled" yaml:"enabled"`
}
Policy represents a single policy rule
type PolicyEffect ¶
type PolicyEffect string
PolicyEffect determines whether a policy allows or denies access
const ( PolicyEffectAllow PolicyEffect = "allow" PolicyEffectDeny PolicyEffect = "deny" )
type PolicyRequest ¶
type PolicyRequest struct {
UserID string `json:"user_id"`
Action string `json:"action"`
Resource string `json:"resource"`
Context map[string]interface{} `json:"context,omitempty"`
ProfileID string `json:"profile_id,omitempty"`
}
PolicyRequest represents a request to check policy permissions
type PolicyResponse ¶
type PolicyResponse struct {
Allowed bool `json:"allowed"`
Reason string `json:"reason,omitempty"`
MatchedPolicies []string `json:"matched_policies,omitempty"`
Suggestions []string `json:"suggestions,omitempty"`
}
PolicyResponse represents the result of a policy evaluation
type PolicySet ¶
type PolicySet struct {
ID string `json:"id" yaml:"id"`
Name string `json:"name" yaml:"name"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Policies []*Policy `json:"policies" yaml:"policies"`
Tags map[string]string `json:"tags,omitempty" yaml:"tags,omitempty"`
CreatedAt time.Time `json:"created_at" yaml:"created_at"`
UpdatedAt time.Time `json:"updated_at" yaml:"updated_at"`
Enabled bool `json:"enabled" yaml:"enabled"`
}
PolicySet represents a collection of policies for a user or group
type PolicyType ¶
type PolicyType string
PolicyType represents different types of policies
const ( // PolicyTypeTemplateAccess controls which templates users can access PolicyTypeTemplateAccess PolicyType = "template_access" // PolicyTypeResourceLimits controls resource allocation limits PolicyTypeResourceLimits PolicyType = "resource_limits" // PolicyTypeResearchUser controls research user operations PolicyTypeResearchUser PolicyType = "research_user" // PolicyTypeInstance controls instance management PolicyTypeInstance PolicyType = "instance" )
type ResearchUserPolicy ¶
type ResearchUserPolicy struct {
AllowCreation bool `json:"allow_creation" yaml:"allow_creation"`
AllowDeletion bool `json:"allow_deletion" yaml:"allow_deletion"`
RequireApproval bool `json:"require_approval,omitempty" yaml:"require_approval,omitempty"`
MaxUsers int `json:"max_users,omitempty" yaml:"max_users,omitempty"`
AllowedShells []string `json:"allowed_shells,omitempty" yaml:"allowed_shells,omitempty"`
RequiredGroups []string `json:"required_groups,omitempty" yaml:"required_groups,omitempty"`
AllowSSHKeys bool `json:"allow_ssh_keys" yaml:"allow_ssh_keys"`
AllowSudoAccess bool `json:"allow_sudo_access,omitempty" yaml:"allow_sudo_access,omitempty"`
AllowDockerAccess bool `json:"allow_docker_access,omitempty" yaml:"allow_docker_access,omitempty"`
}
ResearchUserPolicy controls research user operations
type ResourceLimitsPolicy ¶
type ResourceLimitsPolicy struct {
MaxInstances int `json:"max_instances,omitempty" yaml:"max_instances,omitempty"`
MaxInstanceTypes []string `json:"max_instance_types,omitempty" yaml:"max_instance_types,omitempty"`
MaxCostPerHour float64 `json:"max_cost_per_hour,omitempty" yaml:"max_cost_per_hour,omitempty"`
MaxVolumes int `json:"max_volumes,omitempty" yaml:"max_volumes,omitempty"`
AllowedRegions []string `json:"allowed_regions,omitempty" yaml:"allowed_regions,omitempty"`
RequireSpot bool `json:"require_spot,omitempty" yaml:"require_spot,omitempty"`
Tags map[string]string `json:"required_tags,omitempty" yaml:"required_tags,omitempty"`
}
ResourceLimitsPolicy controls resource allocation
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides policy enforcement for Prism
func (*Service) AssignResearcherPolicies ¶
AssignResearcherPolicies assigns researcher-level policies to current user
func (*Service) AssignStudentPolicies ¶
AssignStudentPolicies assigns student-level policies to current user
func (*Service) CheckResearchUserCreation ¶
func (s *Service) CheckResearchUserCreation(username string) *PolicyResponse
CheckResearchUserCreation enforces research user creation policies
func (*Service) CheckResearchUserDeletion ¶
func (s *Service) CheckResearchUserDeletion(username string) *PolicyResponse
CheckResearchUserDeletion enforces research user deletion policies
func (*Service) CheckTemplateAccess ¶
func (s *Service) CheckTemplateAccess(templateName string) *PolicyResponse
CheckTemplateAccess enforces template access policies
func (*Service) CreateCustomPolicy ¶
CreateCustomPolicy allows users to create custom policies
func (*Service) GetCurrentUserPolicies ¶
GetCurrentUserPolicies returns the current user's assigned policies
func (*Service) GetManager ¶
GetManager returns the underlying policy manager for advanced operations
func (*Service) GetPolicyViolationMessage ¶
func (s *Service) GetPolicyViolationMessage(response *PolicyResponse, action string) string
GetPolicyViolationMessage returns user-friendly policy violation messages
func (*Service) ListAvailablePolicySets ¶
ListAvailablePolicySets returns available policy sets for assignment
func (*Service) SetEnabled ¶
SetEnabled controls whether policy enforcement is active
type TemplateAccessPolicy ¶
type TemplateAccessPolicy struct {
AllowedTemplates []string `json:"allowed_templates,omitempty" yaml:"allowed_templates,omitempty"`
DeniedTemplates []string `json:"denied_templates,omitempty" yaml:"denied_templates,omitempty"`
RequiredDomain string `json:"required_domain,omitempty" yaml:"required_domain,omitempty"`
MaxComplexity string `json:"max_complexity,omitempty" yaml:"max_complexity,omitempty"`
}
TemplateAccessPolicy controls access to specific templates