A member can hold capabilities on top of their bundle. They live in the
Keycloak user attribute extra_capabilities, which the tenant-context
mapper puts into the token; the registry writes it like org_roles and
clears it when the member leaves.
- POST/DELETE /v1/tenants/{id}/members/{uid}/capabilities[/{cap}]
- a person who holds registry:members.manage grants, never on
themselves, and only what they hold themselves
- an administration capability waits for a second person: open
requests in capability_requests (0029), approve or reject under
/v1/tenants/{id}/capability-requests
- a role change keeps the extras; the principal parses the claim, the
registry's own checks still go by org_roles
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014aRnCGqELxoix5TfpX8Ejf
29 lines
1.0 KiB
Go
29 lines
1.0 KiB
Go
package store
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
"time"
|
|
)
|
|
|
|
// CapabilityRequest is a grant of an administration capability to one
|
|
// member that waits for a second person (RBAC step 3, four-eyes; 0029).
|
|
type CapabilityRequest struct {
|
|
ID string `json:"id"`
|
|
TenantID string `json:"tenant_id"`
|
|
UserID string `json:"user_id"`
|
|
UserEmail string `json:"user_email"`
|
|
Capability string `json:"capability"`
|
|
RequestedBy string `json:"requested_by"`
|
|
RequestedEmail string `json:"requested_email"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
// capabilityRE is the shape of a capability code, as the table checks it.
|
|
var capabilityRE = regexp.MustCompile(`^[a-z]+:[a-z0-9-]+\.[a-z0-9-]+$`)
|
|
|
|
func (r CapabilityRequest) valid() bool {
|
|
return r.TenantID != "" && r.UserID != "" && len(r.UserID) <= 200 && capabilityRE.MatchString(r.Capability) &&
|
|
strings.TrimSpace(r.RequestedBy) != "" && len(r.RequestedBy) <= 200 && len(r.UserEmail) <= 320 && len(r.RequestedEmail) <= 320
|
|
}
|