Documentation
¶
Index ¶
Constants ¶
const ( PolicyAdmin = "admin" PolicyReadWrite = "readwrite" PolicyReadOnly = "readonly" )
Built-in policy IDs
const ( EffectAllow = "Allow" EffectDeny = "Deny" // explicit deny wins over allow )
Effects
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
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 ¶
FormatSettingsResource builds the resource string for one settings document, e.g. "settings:system_settings".
func NormalizeKind ¶
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:*", "*"