policy

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PolicyAdmin     = "admin"
	PolicyReadWrite = "readwrite"
	PolicyReadOnly  = "readonly"
)

Built-in policy IDs

View Source
const (
	EffectAllow = "Allow"
	EffectDeny  = "Deny" // explicit deny wins over allow
)

Effects

View Source
const (
	ActionGet     = "get"
	ActionList    = "list"
	ActionCreate  = "create"
	ActionUpdate  = "update"
	ActionDelete  = "delete"
	ActionEnable  = "enable"
	ActionDisable = "disable"
	ActionReload  = "reload"
	ActionAction  = "action" // execute resource action
	ActionAll     = "*"
)

Common actions

View Source
const (
	ResourceGateway          = "gateway"
	ResourceNode             = "node"
	ResourceSource           = "source"
	ResourceField            = "field"
	ResourceTask             = "task"
	ResourceSchedule         = "schedule"
	ResourceHandler          = "handler"
	ResourceDashboard        = "dashboard"
	ResourceFirmware         = "firmware"
	ResourceForwardPayload   = "forwardpayload"
	ResourceDataRepository   = "datarepository"
	ResourceVirtualDevice    = "virtualdevice"
	ResourceVirtualAssistant = "virtualassistant"
	ResourceServiceAccount   = "serviceaccount"
	ResourceSettings         = "settings"
	ResourceBackup           = "backup"
	ResourceUser             = "user"
	ResourcePolicy           = "policy"
	ResourceMetric           = "metric"
	ResourceAction           = "action"
	ResourceStatus           = "status"
	ResourceQuickID          = "quickid"
	ResourceAll              = "*"
)

Common resource kinds (used in resource strings as kind:name)

Variables

This section is empty.

Functions

func FormatSettingsResource

func FormatSettingsResource(key string) string

FormatSettingsResource builds the resource string for one settings document, e.g. "settings:system_settings".

func NormalizeKind

func NormalizeKind(value string) string

NormalizeKind maps an api path segment or a storage entity name to a policy kind. Single source of truth: api paths use "forwardpayload", storage uses "forward_payload", policies use ResourceForwardPayload. Keeping one mapping prevents a kind from silently losing its access-control scope.

Types

type Policy

type Policy struct {
	ID          string               `json:"id" yaml:"id"`
	Description string               `json:"description" yaml:"description"`
	System      bool                 `json:"system" yaml:"system"` // built-in; protect from delete
	Statements  []Statement          `json:"statements" yaml:"statements"`
	Labels      cmap.CustomStringMap `json:"labels" yaml:"labels"`
	ModifiedOn  time.Time            `json:"modifiedOn" yaml:"modifiedOn"`
}

Policy is a named permission document attached to users (and optionally used when resolving access).

type Statement

type Statement struct {
	Effect    string   `json:"effect" yaml:"effect"` // Allow or Deny (Deny wins)
	Actions   []string `json:"actions" yaml:"actions"`
	Resources []string `json:"resources" yaml:"resources"`
}

Statement grants actions on resources. Resource format: "kind" | "kind:name" | "kind:name.*" | "*" Examples: "field:home-gw.living-room.dht.temperature", "node:home-gw.*", "gateway:*", "*"

Jump to

Keyboard shortcuts

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