Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPermission(ac *client.AlpaconClient, userID, permission string) (bool, error)
- func ExplainPermission(ac *client.AlpaconClient, userID, permission string) ([]byte, error)
- func GrantRole(ac *client.AlpaconClient, request BindingCreateRequest) error
- func HoldsWorkspaceRole(bindings []UserRoleResponse, roleName string) bool
- func IsDuplicateBinding(err error) bool
- func IsPlatformTier(roleName string) bool
- func RevokeRole(ac *client.AlpaconClient, bindingID, reason string) error
- func WorkspaceRoleNames(bindings []UserRoleResponse) []string
- type AuditActor
- type AuditPrincipal
- type BindingCreateRequest
- type BindingRevokeRequest
- type EffectivePermissionsResponse
- type EffectiveRole
- type EffectiveRoleAttributes
- type EffectiveSummary
- type GroupNested
- type PermissionCheckResponse
- type PermissionPatternAttributes
- type PermissionPatternsResponse
- type RoleAttributes
- type RoleAuditAttributes
- type RoleAuditLogResponse
- type RoleHolderAttributes
- type RoleNested
- type RoleResponse
- type RoleScopeAttributes
- type RoleScopeResource
- type RoleScopesResponse
- type TroubleshootRequest
- type UserRoleAttributes
- type UserRoleResponse
- func FindWorkspaceBinding(bindings []UserRoleResponse, roleID string) *UserRoleResponse
- func FindWorkspaceBindingByName(bindings []UserRoleResponse, roleName string) *UserRoleResponse
- func GetRoleHolders(ac *client.AlpaconClient, roleID string) ([]UserRoleResponse, error)
- func GetUserBindings(ac *client.AlpaconClient, userID string) ([]UserRoleResponse, error)
Constants ¶
const ( // Platform tiers: the server mirrors them onto the legacy is_staff/is_superuser flags, // creates the admin companion when superuser is granted, and refuses to leave a workspace // without a holder of either. RoleAdmin = "admin" RoleSuperuser = "superuser" CodeRoleAssignmentDuplicate = "rbac_role_assignment_duplicate" )
Variables ¶
var ErrBlankName = api.ErrBlankName
ErrBlankName is re-exported so a caller can tell ResolveRole's blank-name refusal from an ordinary not-found.
Functions ¶
func CheckPermission ¶
func CheckPermission(ac *client.AlpaconClient, userID, permission string) (bool, error)
Workspace-wide question only: a permission held through an object-scoped binding answers false here, because no object is named.
func ExplainPermission ¶
func ExplainPermission(ac *client.AlpaconClient, userID, permission string) ([]byte, error)
func GrantRole ¶
func GrantRole(ac *client.AlpaconClient, request BindingCreateRequest) error
func HoldsWorkspaceRole ¶
func HoldsWorkspaceRole(bindings []UserRoleResponse, roleName string) bool
func IsDuplicateBinding ¶
func IsPlatformTier ¶
func RevokeRole ¶
func RevokeRole(ac *client.AlpaconClient, bindingID, reason string) error
func WorkspaceRoleNames ¶
func WorkspaceRoleNames(bindings []UserRoleResponse) []string
Types ¶
type AuditActor ¶
type AuditPrincipal ¶
type BindingCreateRequest ¶
type BindingCreateRequest struct {
User string `json:"user"`
Role string `json:"role"`
ContentType *int `json:"content_type,omitempty"`
ObjectID []string `json:"object_id,omitempty"`
Reason string `json:"reason,omitempty"`
}
User and Role are scalars on purpose: more than one value in any of the three fields flips the server onto a bulk path that answers 201 with an empty body even when it created nothing, and never reports a duplicate. ContentType and ObjectID are unset for now, kept for later object-scoped writes.
type BindingRevokeRequest ¶
type BindingRevokeRequest struct {
Reason string `json:"reason"`
}
The justification rides the DELETE body, not a query parameter, so it stays out of access and proxy logs.
type EffectivePermissionsResponse ¶
type EffectivePermissionsResponse struct {
User types.UserSummary `json:"user"`
Summary EffectiveSummary `json:"summary"`
Roles []EffectiveRole `json:"roles"`
Permissions RoleScopesResponse `json:"permissions"`
}
Roles omits object-scoped bindings: their number grows with the number of objects, so the payload would be unbounded.
func GetEffectivePermissions ¶
func GetEffectivePermissions(ac *client.AlpaconClient, userID string) (*EffectivePermissionsResponse, error)
The IAM user endpoint, not /api/rbac/: an API token reaches it where the RBAC routes refuse one.
type EffectiveRole ¶
type EffectiveRole struct {
Role RoleNested `json:"role"`
// Source is "user" for a role bound directly, "group" for one inherited.
Source string `json:"source"`
Group *GroupNested `json:"group"`
// Scope is "global" or "content_type"; see EffectivePermissionsResponse.
Scope string `json:"scope"`
}
type EffectiveRoleAttributes ¶
type EffectiveRoleAttributes struct {
Role string `json:"role"`
Source string `json:"source"`
Group string `json:"group"`
Scope string `json:"scope"`
}
func EffectiveRoleAttributesFrom ¶
func EffectiveRoleAttributesFrom(roles []EffectiveRole) []EffectiveRoleAttributes
type EffectiveSummary ¶
type GroupNested ¶
type PermissionCheckResponse ¶
type PermissionCheckResponse struct {
Allowed bool `json:"allowed"`
}
GET /api/iam/users/{id}/permissions/ answers this when a permission query parameter is sent.
type PermissionPatternAttributes ¶
type PermissionPatternAttributes struct {
Permission string `json:"permission"`
Scope string `json:"scope"`
}
func PermissionPatternAttributesFrom ¶
func PermissionPatternAttributesFrom(patterns *PermissionPatternsResponse) []PermissionPatternAttributes
type PermissionPatternsResponse ¶
type PermissionPatternsResponse struct {
Global []string `json:"global"`
ObjectScoped []string `json:"object_scoped"`
}
ObjectScoped says the user holds the pattern somewhere, never on what object.
func GetPermissionPatterns ¶
func GetPermissionPatterns(ac *client.AlpaconClient, userID string) (*PermissionPatternsResponse, error)
type RoleAttributes ¶
func RoleAttributesFrom ¶
func RoleAttributesFrom(roles []RoleResponse) []RoleAttributes
type RoleAuditAttributes ¶
type RoleAuditAttributes struct {
Action string `json:"action"`
Role string `json:"role"`
Scope string `json:"scope"`
ChangedBy string `json:"changed_by" table:"Changed By"`
Reason string `json:"reason"`
At string `json:"at"`
}
func AuditAttributesFrom ¶
func AuditAttributesFrom(entries []RoleAuditLogResponse) []RoleAuditAttributes
type RoleAuditLogResponse ¶
type RoleAuditLogResponse struct {
ID string `json:"id"`
RecordClass string `json:"record_class"`
Action string `json:"action"`
Role *RoleNested `json:"role"`
RoleName string `json:"role_name"`
Principal *AuditPrincipal `json:"principal"`
Scope string `json:"scope"`
ChangedBy *AuditActor `json:"changed_by"`
Reason string `json:"reason"`
AddedAt time.Time `json:"added_at"`
}
The only surface carrying the justification and the actor—a binding read carries neither. Role, Principal and ChangedBy answer null where there is nothing left to name, so the row keeps value snapshots like RoleName.
func GetRoleHistory ¶
func GetRoleHistory(ac *client.AlpaconClient, userID string, limit int) ([]RoleAuditLogResponse, error)
type RoleHolderAttributes ¶
type RoleHolderAttributes struct {
User string `json:"user"`
Scope string `json:"scope"`
GrantedAt string `json:"granted_at" table:"Granted At"`
}
func HolderAttributesFrom ¶
func HolderAttributesFrom(bindings []UserRoleResponse, usernames map[string]string) []RoleHolderAttributes
A nil usernames map means names were never resolved, so the id—the value other commands accept—stands in; the display name is a fallback only when resolution ran and missed.
type RoleNested ¶
type RoleResponse ¶
type RoleResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
AddedAt time.Time `json:"added_at"`
UpdatedAt time.Time `json:"updated_at"`
}
func GetRoleCatalog ¶
func GetRoleCatalog(ac *client.AlpaconClient, autoAssigned *bool) ([]RoleResponse, error)
auto_assigned asks the server which roles it counts as assigned on its own; false is not a list of what the caller may grant. Which roles count differs by Alpacon release and the response carries no such field, so only the server can tell.
func ResolveRole ¶
func ResolveRole(ac *client.AlpaconClient, nameOrID string) (*RoleResponse, error)
type RoleScopeAttributes ¶
type RoleScopeAttributes struct {
Name string `json:"name" table:"Resource"`
Actions string `json:"actions"`
ACL string `json:"acl" table:"ACL"`
}
func ScopeAttributesFrom ¶
func ScopeAttributesFrom(scopes *RoleScopesResponse) []RoleScopeAttributes
Wildcards first: they subsume the concrete rows below them.
type RoleScopeResource ¶
type RoleScopesResponse ¶
type RoleScopesResponse struct {
Resources []RoleScopeResource `json:"resources"`
Wildcards []string `json:"wildcards"`
}
func GetRoleScopes ¶
func GetRoleScopes(ac *client.AlpaconClient, roleID string) (*RoleScopesResponse, error)
type TroubleshootRequest ¶
type TroubleshootRequest struct {
UserID string `json:"user_id"`
Permission string `json:"permission"`
}
POST /api/rbac/troubleshoot/ reads rather than writes, despite the verb.
type UserRoleAttributes ¶
type UserRoleAttributes struct {
Role string `json:"role"`
Scope string `json:"scope"`
GrantedAt string `json:"granted_at" table:"Granted At"`
}
func BindingAttributesFrom ¶
func BindingAttributesFrom(bindings []UserRoleResponse) []UserRoleAttributes
type UserRoleResponse ¶
type UserRoleResponse struct {
ID string `json:"id"`
User types.UserSummary `json:"user"`
Role RoleNested `json:"role"`
ContentType *int `json:"content_type"`
ObjectID *string `json:"object_id"`
AddedAt time.Time `json:"added_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Only a workspace-wide binding makes someone an admin or a superuser.
func FindWorkspaceBinding ¶
func FindWorkspaceBinding(bindings []UserRoleResponse, roleID string) *UserRoleResponse
The server refuses a second binding of the same role with both scope fields unset, so the first workspace-wide match is the only one.
func FindWorkspaceBindingByName ¶
func FindWorkspaceBindingByName(bindings []UserRoleResponse, roleName string) *UserRoleResponse
Matching by name lets a revoke find the admin companion without resolving a second role.
func GetRoleHolders ¶
func GetRoleHolders(ac *client.AlpaconClient, roleID string) ([]UserRoleResponse, error)
func GetUserBindings ¶
func GetUserBindings(ac *client.AlpaconClient, userID string) ([]UserRoleResponse, error)
The endpoint offers no scope filter, so the workspace-wide row is picked out here. The list is also narrowed to what the caller may see and answered 200, never 403, so an empty result reads exactly like "holds nothing"—no caller may take it as proof of absence.
func (UserRoleResponse) IsWorkspaceWide ¶
func (b UserRoleResponse) IsWorkspaceWide() bool
An unscoped binding answers null or an empty ObjectID, so a nil check alone would miss one.
func (UserRoleResponse) ScopeLabel ¶
func (b UserRoleResponse) ScopeLabel() string
Content types print as their numeric id: the CLI grants nothing object-scoped yet, so resolving names via /api/rbac/content-types/ would not earn a request.