singlecommandpermission

package
v0.0.42 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeCommand  = "command"
	TypeRedirect = "redirect"
)

Permission types.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChangeNotifier

type ChangeNotifier interface {
	NotifySingleCommandPermissionChange(projectID string)
}

ChangeNotifier is called after permission creates/updates/deletes to push updates to connected Agent Managers so they can refresh their caches.

type Repository

type Repository interface {
	// Create stores a new permission rule.
	Create(ctx context.Context, p *SingleCommandPermission) error

	// Get returns a single permission rule by ID.
	// Returns an error if the rule does not exist.
	Get(ctx context.Context, id string) (*SingleCommandPermission, error)

	// List returns all permission rules for a project.
	List(ctx context.Context, projectID string) ([]*SingleCommandPermission, error)

	// FindByPatternAndType returns all permission rules that match the given
	// projectID, pattern, and type combination. Returns an empty slice if none
	// found. Results are sorted by CreatedAt ascending (oldest first).
	FindByPatternAndType(ctx context.Context, projectID, pattern, permType string) ([]*SingleCommandPermission, error)

	// Update replaces an existing permission rule.
	Update(ctx context.Context, p *SingleCommandPermission) error

	// Delete removes a permission rule by ID.
	Delete(ctx context.Context, id string) error
}

Repository provides persistence for single-command permission rules.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server implements the SingleCommandPermissionService RPC handlers.

func NewServer

func NewServer(repo Repository, notifier ChangeNotifier) *Server

NewServer creates a new single-command permission service server.

func (*Server) CreateSingleCommandPermission

CreateSingleCommandPermission adds a new wildcard permission rule. If a rule with the same pattern+type already exists in the project, the existing rule is updated (label overwrite) and any extra duplicates are removed. This makes the operation idempotent and cleans up legacy duplicates.

func (*Server) DeleteSingleCommandPermission

DeleteSingleCommandPermission removes a permission rule.

func (*Server) ListSingleCommandPermissions

ListSingleCommandPermissions returns all rules for a project.

func (*Server) UpdateSingleCommandPermission

UpdateSingleCommandPermission modifies an existing permission rule.

type SingleCommandPermission

type SingleCommandPermission struct {
	ID        string    `yaml:"id"`
	ProjectID string    `yaml:"project_id"`
	Pattern   string    `yaml:"pattern"` // wildcard pattern (e.g. "git status" or "git *")
	Type      string    `yaml:"type"`    // "command" or "redirect"
	Label     string    `yaml:"label"`   // human-readable label (e.g. "git status")
	CreatedAt time.Time `yaml:"created_at"`
}

SingleCommandPermission represents a wildcard-based permission rule that matches against individual shell commands (not full one-liners). The pattern uses wildcard syntax where `*` matches zero or more arbitrary characters.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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