Documentation
¶
Overview ¶
Package policybinding is the domain layer for the PolicyBinding entity: it applies one Policy to a set of accounts inside its owner's scope (the organization, a team, a project or a user). Accounts are the only subjects: a team-wide cap binds the team's account, a member's the member account. An account is held by at most one binding.
Authorization and the cross-row scope rules are app/authz's and app/refcheck's concern; this package validates shape only.
Index ¶
- Variables
- type PolicyBinding
- type Spec
- type Store
- func (s *Store) Delete(ctx context.Context, id string) error
- func (s *Store) Get(ctx context.Context, id string) (*PolicyBinding, error)
- func (s *Store) Holding(ctx context.Context, accountID string) (*PolicyBinding, error)
- func (s *Store) List(ctx context.Context) ([]*PolicyBinding, error)
- func (s *Store) Upsert(ctx context.Context, b *PolicyBinding) error
Constants ¶
This section is empty.
Variables ¶
var ErrAccountBound = errors.New("policybinding: account is already bound by another policy binding")
ErrAccountBound is a write naming an account another binding already holds: an account is bound to at most one policy.
Functions ¶
This section is empty.
Types ¶
type PolicyBinding ¶
type PolicyBinding struct {
Meta meta.Metadata `json:"metadata" yaml:"metadata"`
Spec Spec `json:"spec" yaml:"spec"`
}
PolicyBinding attaches Spec.PolicyID to Spec.AccountIDs inside the scope Meta.Owner names.
func (*PolicyBinding) IsEnabled ¶
func (b *PolicyBinding) IsEnabled() bool
IsEnabled returns true when Enabled is unset or explicitly true.
func (*PolicyBinding) ScopeKey ¶ added in v0.20.0
func (b *PolicyBinding) ScopeKey() string
ScopeKey names the owner scope ("team:<id>", "project:<id>", "user:<id>"), "" for the organization.
func (*PolicyBinding) Validate ¶
func (b *PolicyBinding) Validate() error
Validate runs intra-row rules via the shared meta.Validator and enforces:
- Owner.Kind is organization (no id; system, its earlier name, is read as it), or team, project or user with an id.
- no account is listed twice.
type Spec ¶
type Spec struct {
PolicyID string `json:"policyId" yaml:"policyId" validate:"required,uuid" doc:"Id of the policy the accounts are bound to."`
AccountIDs []string `` /* 239-byte string literal not displayed */
Enabled *bool `` /* 128-byte string literal not displayed */
}
Spec carries the policy, the accounts, and the enabled flag.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds a DB rather than Queries so Upsert can run a multi-table transaction.