Documentation
¶
Overview ¶
Package iam evaluates AWS-style JSON policies (§7): statements allow or deny actions ("service:ScaleService") on resources ("srn:syncloud:project/shop/env/production/service/web"), with optional conditions. An explicit Deny beats an Allow, which beats the implicit deny.
Index ¶
Constants ¶
const ( KeyMFAPresent = "syn:MFAPresent" // "true" | "false" KeySourceIP = "syn:SourceIp" // the caller's address KeyCredentialType = "syn:CredentialType" // session | token | access_key | role_session )
Condition keys (§7.1).
const Version = "2026-01"
Version is the only policy language version.
Variables ¶
This section is empty.
Functions ¶
func AllowsAny ¶
AllowsAny reports whether some statement could allow action on some resource (list endpoints, whose results are then filtered per item).
func Match ¶
Match reports whether a pattern with * (any run) and ? (one character) matches s. Action service names are matched case-sensitively, as written.
func ProjectResources ¶
ProjectResources are the resources of one project.
Types ¶
type Decision ¶
type Decision struct {
Allowed bool `json:"allowed"`
Reason string `json:"reason"` // "allowed by …", "explicitly denied by …", "no policy allows it"
By *Attached `json:"-"`
Policy string `json:"policy,omitempty"`
Sid string `json:"sid,omitempty"`
}
Decision is the result of an evaluation.
type Document ¶
Document is a policy.
func ManagedDocument ¶
ManagedDocument returns a managed policy's document: "ReadOnly", or "Developer:shop" for a project template.
type Managed ¶
type Managed struct {
Name string
Description string
// PerProject templates take a project; the others are global.
PerProject bool
// contains filtered or unexported fields
}
Managed policies (§7) are built in and cannot be edited. Project-scoped ones are templates: attaching ProjectOwner for "shop" uses the policy "ProjectOwner:shop".
func ManagedPolicies ¶
func ManagedPolicies() []Managed
ManagedPolicies lists the built-in policies.
type Statement ¶
type Statement struct {
Sid string `json:"Sid,omitempty"`
Effect string `json:"Effect"` // Allow | Deny
Action StringList `json:"Action"`
Resource StringList `json:"Resource"`
Condition map[string]map[string]StringList `json:"Condition,omitempty"`
}
Statement is one rule. Action and Resource accept a string or a list.
func (Statement) ConditionsHold ¶
ConditionsHold reports whether a statement's conditions hold for c.
type StringList ¶
type StringList []string
StringList unmarshals from a string or a list of strings.
func (*StringList) UnmarshalJSON ¶
func (l *StringList) UnmarshalJSON(b []byte) error