Documentation
¶
Index ¶
- Constants
- Variables
- func APIForRoles(roles []app.Role) (permissions.API, bool, error)
- func APIFromRole(role *app.Role) (permissions.API, bool, error)
- func CanCreate(ctx *gin.Context, objectID string) error
- func CanDelete(ctx *gin.Context, objectID string) error
- func CanRead(ctx *gin.Context, objectID string) error
- func CanUpdate(ctx *gin.Context, objectID string) error
- func CompatibilityRole(definition app.RoleDefinition) *app.Role
- func DeleteManagedServiceAccountRoles(tx *gorm.DB, accountIDs []string) error
- func DeletePrivateRoles(tx *gorm.DB, accountIDs []string) error
- func PrivateRoleBlockedAccounts(tx *gorm.DB, accountIDs []string) (map[string]struct{}, error)
- func ReconcileOrgRoles(ctx context.Context, db *gorm.DB, org app.Org) error
- func RequireNativeCutover(ctx context.Context, db *gorm.DB) error
- func RequireUserManaged(tx *gorm.DB, accountID string) error
- func ScopedRolePolicy(role *app.Role) (permissions.Policy, error)
- func WithAuthority(ctx context.Context, authority *Authority) context.Context
- type AccessContext
- func (a *AccessContext) Collection() (*Selection, error)
- func (a *AccessContext) Identity() Identity
- func (a *AccessContext) Matches(authority *Authority) bool
- func (a *AccessContext) Require(requirements ...Requirement) (*AccessContext, error)
- func (a *AccessContext) Requirements() []Requirement
- func (a *AccessContext) Select(operation permissions.OperationID, resources *Resources) (*AccessContext, error)
- func (a *AccessContext) Target(operation permissions.OperationID) (permissions.Target, error)
- type Authority
- func (a *Authority) Check(operation permissions.OperationID, target permissions.Target) permissions.PermissionMatch
- func (a *Authority) Require(requirements ...Requirement) (*AccessContext, error)
- func (a *Authority) RequireCollection(operation permissions.OperationID, resources *Resources) (*AccessContext, error)
- func (a *Authority) Select(operation permissions.OperationID, resources *Resources) (*Selection, error)
- type Client
- func (h *Client) AddAccountOrgRole(ctx context.Context, roleType app.RoleType, orgID, accountID string) error
- func (h *Client) AddAccountRoleByID(ctx context.Context, roleID, accountID string) error
- func (c *Client) AssignableRoles(ctx context.Context, orgID, roleContext string) ([]app.Role, error)
- func (c *Client) CreateOrgRoles(ctx context.Context, orgID string) error
- func (h *Client) EnsureLogStreamRole(ctx context.Context, orgID, logStreamID, accountID string) error
- func (h *Client) EnsureManagedServiceAccountRole(ctx context.Context, accountID string, want *app.Role) error
- func (h *Client) EnsurePhoneHomeRole(ctx context.Context, orgID, versionID, accountID string) error
- func (h *Client) EnsureRunnerJobRole(ctx context.Context, orgID, jobID, installID, accountID string) error
- func (h *Client) EnsureRunnerRole(ctx context.Context, orgID, installID, accountID string) error
- func (h *Client) EnsureStackInstallRole(ctx context.Context, orgID, installID, accountID string) error
- func (c *Client) EnsureStandardRoles(ctx context.Context, orgID string) error
- func (h *Client) EnsureTelemetryCollectorRole(ctx context.Context, orgID, installID, accountID string) error
- func (c *Client) LoadAccountPermissions(ctx context.Context, account *app.Account) (*permissions.AccountPermissions, error)
- func (c *Client) LoadAuthority(ctx context.Context, identity Identity) (*Authority, error)
- func (c *Client) LoadBindingGrants(ctx context.Context, orgID, accountID string) ([]*permissions.CompiledGrant, error)
- func (h *Client) RemoveAccountOrgRoleByType(ctx context.Context, roleType app.RoleType, orgID, accountID string) error
- func (h *Client) RemoveAccountOrgRoles(ctx context.Context, orgID, accountID string) error
- func (c *Client) RequireAnyOrgOperation(ctx context.Context, orgID string, operations ...permissions.OperationID) error
- func (c *Client) RequireOrgOperation(ctx context.Context, orgID string, operation permissions.OperationID) error
- func (c *Client) RequireOrgRoleGrant(ctx context.Context, orgID, roleID string) error
- func (c *Client) ResolveAssignableRole(ctx context.Context, orgID string, roleType app.RoleType, roleContext string) (*app.Role, error)
- func (h *Client) SetAccountOrgRole(ctx context.Context, orgID, accountID string, roleType app.RoleType) error
- func (c *Client) StandardRole(ctx context.Context, orgID string, key roles.Key) (*app.RoleDefinition, error)
- func (c *Client) ValidateBindingScope(ctx context.Context, binding app.RoleBinding) error
- type Identity
- type OrgRoleClassification
- type OrgRoleSnapshot
- type Params
- type Requirement
- type Resources
- type Selection
Constants ¶
const NativeCutoverMigration = "native_rbac_cutover"
NativeCutoverMigration is the completion record written by the offline data conversion after validating all cohorts, including an initially empty database.
Variables ¶
var ErrDenied = errors.New("authorization denied")
var ErrStandardRoleDrift = errors.New("standard role requires an explicit data migration")
ErrStandardRoleDrift reports a stored standard definition that no longer matches its code template.
Functions ¶
func APIForRoles ¶ added in v0.19.1273
func APIFromRole ¶ added in v0.19.1273
func CompatibilityRole ¶
func CompatibilityRole(definition app.RoleDefinition) *app.Role
func DeleteManagedServiceAccountRoles ¶ added in v0.19.1290
func DeletePrivateRoles ¶ added in v0.19.1289
func PrivateRoleBlockedAccounts ¶ added in v0.19.1290
func ReconcileOrgRoles ¶ added in v0.19.1115
ReconcileOrgRoles brings an org's managed roles in line with standardOrgRoles: missing roles are created (with their policies), and existing roles have their metadata (title, description, contexts, managed) updated to match the definition. Existing rows' policies are deliberately never modified.
func RequireUserManaged ¶ added in v0.19.1239
func ScopedRolePolicy ¶ added in v0.19.1293
func ScopedRolePolicy(role *app.Role) (permissions.Policy, error)
Types ¶
type AccessContext ¶
type AccessContext struct {
// contains filtered or unexported fields
}
AccessContext carries authorized operation/target pairs to downstream handlers. Handlers use the captured resource facts to act on the targets that were checked.
func (*AccessContext) Collection ¶
func (a *AccessContext) Collection() (*Selection, error)
func (*AccessContext) Identity ¶
func (a *AccessContext) Identity() Identity
func (*AccessContext) Matches ¶
func (a *AccessContext) Matches(authority *Authority) bool
Matches reports whether these checks used the given authority snapshot.
func (*AccessContext) Require ¶
func (a *AccessContext) Require(requirements ...Requirement) (*AccessContext, error)
Require extends the checked set without modifying the original. Every new check must pass, and repeated references to a resource must agree on its ancestry and relationships, even when checking different operations on that resource.
func (*AccessContext) Requirements ¶
func (a *AccessContext) Requirements() []Requirement
Requirements returns a deep copy of the checked resource facts, preserving the authorization snapshot when callers modify the returned values.
func (*AccessContext) Select ¶
func (a *AccessContext) Select(operation permissions.OperationID, resources *Resources) (*AccessContext, error)
func (*AccessContext) Target ¶
func (a *AccessContext) Target(operation permissions.OperationID) (permissions.Target, error)
Target returns the sole checked target for an operation. Multi-target consumers must use Requirements rather than implicitly selecting one target.
type Authority ¶
type Authority struct {
// contains filtered or unexported fields
}
Authority evaluates operations against a request-local snapshot of native grants. Load it again for each request so subsequent requests observe binding revocation.
func RequestAuthority ¶
func RequestAuthority(ctx cctx.ValueContext) (*Authority, error)
RequestAuthority retrieves the snapshot and verifies that its identity matches the request's authenticated account, credential and selected org.
func (*Authority) Check ¶
func (a *Authority) Check(operation permissions.OperationID, target permissions.Target) permissions.PermissionMatch
Check reports whether the snapshot grants the operation on the resolved target.
func (*Authority) Require ¶
func (a *Authority) Require(requirements ...Requirement) (*AccessContext, error)
Require checks every requirement and returns the checked targets for downstream use. An empty set is denied rather than treated as a successful check.
func (*Authority) RequireCollection ¶
func (a *Authority) RequireCollection(operation permissions.OperationID, resources *Resources) (*AccessContext, error)
func (*Authority) Select ¶
func (a *Authority) Select(operation permissions.OperationID, resources *Resources) (*Selection, error)
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) AddAccountOrgRole ¶
func (*Client) AddAccountRoleByID ¶
func (*Client) AssignableRoles ¶ added in v0.19.1115
func (c *Client) AssignableRoles(ctx context.Context, orgID, roleContext string) ([]app.Role, error)
AssignableRoles returns the org's roles offerable on the given assignment surface (see app.RoleContext*), ordered by role type.
func (*Client) CreateOrgRoles ¶
func (*Client) EnsureLogStreamRole ¶ added in v0.19.1289
func (*Client) EnsureManagedServiceAccountRole ¶ added in v0.19.1239
func (*Client) EnsurePhoneHomeRole ¶ added in v0.19.1299
func (*Client) EnsureRunnerJobRole ¶ added in v0.19.1299
func (h *Client) EnsureRunnerJobRole(ctx context.Context, orgID, jobID, installID, accountID string) error
EnsureRunnerJobRole grants one job, and the install its runner serves when installID is set, in a single private role.
func (*Client) EnsureRunnerRole ¶ added in v0.19.1299
func (*Client) EnsureStackInstallRole ¶ added in v0.19.1149
func (h *Client) EnsureStackInstallRole(ctx context.Context, orgID, installID, accountID string) error
EnsureStackInstallRole converges a stack account's install-scoped role: one role, one policy, on this install's stack object. Looked up through the account's own binding, since the account is already per-install.
func (*Client) EnsureStandardRoles ¶
EnsureStandardRoles seeds an org's standard role definitions from code templates. Drifted definitions are left untouched and reported after missing definitions are seeded. Changing or restoring them requires an explicit data migration.
func (*Client) EnsureTelemetryCollectorRole ¶ added in v0.19.1299
func (*Client) LoadAccountPermissions ¶ added in v0.19.1289
func (c *Client) LoadAccountPermissions(ctx context.Context, account *app.Account) (*permissions.AccountPermissions, error)
func (*Client) LoadAuthority ¶
LoadAuthority builds the request's authority from the account's native bindings in the selected org. It requires an authenticated identity: the caller validates the credential, its account association and its restrictions before loading.
func (*Client) LoadBindingGrants ¶
func (c *Client) LoadBindingGrants(ctx context.Context, orgID, accountID string) ([]*permissions.CompiledGrant, error)
LoadBindingGrants compiles live assignments from a consistent database snapshot. Invalid or stale bindings contribute no authority but remain stored for inspection and restoration. Database errors fail the whole load instead of returning partial grants.
func (*Client) RemoveAccountOrgRoleByType ¶ added in v0.19.1149
func (h *Client) RemoveAccountOrgRoleByType(ctx context.Context, roleType app.RoleType, orgID, accountID string) error
RemoveAccountOrgRoleByType drops one role binding, unlike RemoveAccountOrgRoles, which clears every binding in an org.
func (*Client) RemoveAccountOrgRoles ¶
func (*Client) RequireAnyOrgOperation ¶
func (c *Client) RequireAnyOrgOperation(ctx context.Context, orgID string, operations ...permissions.OperationID) error
RequireAnyOrgOperation authorizes org-level management when the caller has at least one listed capability scoped to the org.
func (*Client) RequireOrgOperation ¶
func (c *Client) RequireOrgOperation(ctx context.Context, orgID string, operation permissions.OperationID) error
func (*Client) RequireOrgRoleGrant ¶
RequireOrgRoleGrant verifies that the caller has org-wide authority for every operation in the role. Callers also authorize the management operation and hold the relevant locks through both checks and the mutation.
func (*Client) ResolveAssignableRole ¶ added in v0.19.1115
func (c *Client) ResolveAssignableRole(ctx context.Context, orgID string, roleType app.RoleType, roleContext string) (*app.Role, error)
ResolveAssignableRole validates that roleType is offerable on the given surface in the org and returns its role row. The error lists the roles that are assignable there.
func (*Client) SetAccountOrgRole ¶ added in v0.19.1075
func (h *Client) SetAccountOrgRole(ctx context.Context, orgID, accountID string, roleType app.RoleType) error
SetAccountOrgRole replaces an account's role(s) in an org with a single role of the given type. Unlike RemoveAccountOrgRoles it does not touch the account's OrgInvite records, so it is safe for in-place role changes.
func (*Client) StandardRole ¶
func (*Client) ValidateBindingScope ¶
type Identity ¶
Identity ties an authority snapshot to an authenticated credential and selected org.
type OrgRoleClassification ¶ added in v0.19.1295
type OrgRoleClassification struct {
Status string
Reason string
Permissions permissions.PermissionSet
LegacyAPI *permissions.API
Policy *permissions.Policy
}
func ClassifyOrgRole ¶ added in v0.19.1295
func ClassifyOrgRole(source OrgRoleSnapshot) (OrgRoleClassification, error)
type OrgRoleSnapshot ¶ added in v0.19.1295
type OrgRoleSnapshot struct {
Role app.Role
Bindings []app.AccountRole
}
type Requirement ¶
type Requirement struct {
Operation permissions.OperationID
Target permissions.Target
}
Requirement pairs an operation with a canonical target resolved by the caller. Target ownership and ancestry come from trusted resource lookups.
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
Resources describes a domain-owned query of live resources and their verified ancestry. The query projects id, org_id, app_id, install_id, runner_job_id and runner_id, using NULL for absent relationships and one row per association. Callers apply pagination and aggregation to the filtered consumer query.
func NewResources ¶
func NewResources(query *gorm.DB, kind permissions.ResourceKind, orgID string) (*Resources, error)
Source Files
¶
- access.go
- account_permissions.go
- add_account_role.go
- assignable_roles.go
- authority.go
- bindings.go
- client.go
- collection.go
- context.go
- create_org_roles.go
- ensure_runner_role.go
- ensure_stack_install_role.go
- managed_account.go
- managed_service_account_role.go
- management.go
- org_role_classification.go
- readiness.go
- reconcile_org_roles.go
- remove_account_role_by_type.go
- remove_account_roles.go
- role_api.go
- role_definitions.go
- scoped_role_policy.go
- set_account_role.go
- workload_roles.go
Directories
¶
| Path | Synopsis |
|---|---|
|
Package require applies existing RBAC permissions to HTTP routes and non-HTTP callers.
|
Package require applies existing RBAC permissions to HTTP routes and non-HTTP callers. |