policy

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package policy decides whether a subject may run an action: allow, deny, confirm (the same person again), reauth (password or TOTP again) or approve (another person).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Roles map[string]Role   `yaml:"roles,omitempty" json:"roles,omitempty"`
	Bind  map[string]string `yaml:"bind,omitempty" json:"bind,omitempty"`
}

Config is rig.yaml's `policy:`. Bind maps user:<name>, group:<name> or ai to a role.

func (*Config) Decide

func (c *Config) Decide(req Request, envs map[string]Env) (Decision, string)

Decide answers req. For a subject no role binds, the local default applies: reads are allowed; a readonly environment takes no writes; the AI's writes need approval; an agent's writes are allowed unless dangerous, protected or matching its approve globs; danger and writes to a protected environment need confirming. With roles, the most restrictive matching rule wins, an allowed write to a protected environment still needs confirming, and nothing matching is denied.

type Decision

type Decision string
const (
	Allow   Decision = "allow"
	Deny    Decision = "deny"
	Confirm Decision = "confirm"
	Reauth  Decision = "reauth"
	Approve Decision = "approve"
)

type Env

type Env struct {
	Protected bool
	Readonly  bool
}

Env is what policy needs from an environment.

type Request

type Request struct {
	Subject identity.Subject
	// Action is the verb, such as runtime.restart.
	Action string
	// Effect is the action's protocol effect: read, write or danger.
	Effect string
	Env    string
}

type Role

type Role struct {
	Extends string   `yaml:"extends,omitempty" json:"extends,omitempty"`
	Allow   []string `yaml:"allow,omitempty" json:"allow,omitempty"`
	Deny    []string `yaml:"deny,omitempty" json:"deny,omitempty"`
	Confirm []string `yaml:"confirm,omitempty" json:"confirm,omitempty"`
	Reauth  []string `yaml:"reauth,omitempty" json:"reauth,omitempty"`
	Approve []string `yaml:"approve,omitempty" json:"approve,omitempty"`
}

Role lists rules as action:effect[@env/name] globs, such as *:write@env/local.

Jump to

Keyboard shortcuts

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