You are viewing a plain text version of this content. The canonical link for it is here.
Posted to custos@airavata.apache.org by "lahirujayathilake (via GitHub)" <gi...@apache.org> on 2026/05/28 21:16:40 UTC
[PR] Add admin privileges and role-template layer [airavata-custos]
lahirujayathilake opened a new pull request, #484:
URL: https://github.com/apache/airavata-custos/pull/484
Adds an authorization model for Custos admins, fine-grained privileges plus named role bundles that group privileges together.
## Architecture
Two layers,
- **Privileges** - declared keys (`amie:read`, `hpc:write`, `privileges:grant`, `roles:manage`, etc.) granted directly to a user.
- **Roles** - named bundles of privileges. Granting a role to a user is shorthand for granting every privilege the role carries. Update to a role's bundle propagates to every holder.
A user's `effective set = direct grants UNION privileges` from every role they hold. The auth middleware caches this set per user.
## Models
- `user_privileges` - direct grants (revoke is DELETE; history in `audit_events`)
- `roles` - role definitions (`name`, `description`, `is_system`)
- `role_privileges` - many-to-many relationship
- `user_roles` - role assignments (revoke is DELETE; history in `audit_events`)
`audit_events` (existing core table) is the single source of grant/revoke history.
## Identification
Caller is identified via the `X-Custos-User-Id` header. A JWT-verification middleware (the planned implementation) will set this from the verified `sub` claim after validating against the IdP's JWKS endpoint.
## Bootstrap
If `CUSTOS_BOOTSTRAP_ADMIN_EMAIL` is set, the server idempotently creates a `super_admin` role carrying `privileges:grant` + `roles:manage` and grants it to the named user on first start.
## API contract
- `GET /user/privileges` - caller's effective set
- `GET /privileges/catalog` - declared privilege keys
- `GET|POST|DELETE /users/{id}/privileges...` - direct grant management
- `GET|POST|PUT|DELETE /roles...` - role CRUD + bundle management
- `GET|POST|DELETE /users/{id}/roles...` - role assignments
Privilege management endpoints gated on `privileges:grant`; role management gated on `roles:manage`.
## Dev tooling
- `dev-ops/compose/seeds/dev_users_and_roles.sql` - seeds 4 dev users (`dev-admin`, `dev-operator`, `dev-auditor`, `dev-researcher`) plus `operator` and `auditor` roles
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: custos-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add admin privileges and role-template layer [airavata-custos]
Posted by "DImuthuUpe (via GitHub)" <gi...@apache.org>.
DImuthuUpe merged PR #484:
URL: https://github.com/apache/airavata-custos/pull/484
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: custos-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Add admin privileges and role-template layer [airavata-custos]
Posted by "DImuthuUpe (via GitHub)" <gi...@apache.org>.
DImuthuUpe commented on code in PR #484:
URL: https://github.com/apache/airavata-custos/pull/484#discussion_r3348328466
##########
pkg/models/role.go:
##########
@@ -0,0 +1,44 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package models
+
+import "time"
+
+// SystemRoleSuperAdmin is the bootstrap role: carries privileges:grant
+// and roles:manage. Created on first server start.
+const SystemRoleSuperAdmin = "super_admin"
+
+// Role is a named bundle of privileges. Mutating the bundle propagates to
+// every holder.
+type Role struct {
+ ID string `json:"id" db:"id"`
+ Name string `json:"name" db:"name"`
+ Description *string `json:"description" db:"description"`
+ IsSystem bool `json:"is_system" db:"is_system"`
+ CreatedAt time.Time `json:"created_at" db:"created_at"`
+}
Review Comment:
@lahirujayathilake How do you bundle a set of privileges into a single role?
##########
pkg/models/privilege.go:
##########
@@ -0,0 +1,71 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package models
+
+import "time"
+
+// PrivilegeKey names a fine-grained admin capability. The set is closed and
+// declared in code; service-layer validation rejects grants of any key not
+// returned by KnownPrivileges.
+type PrivilegeKey string
+
+const (
+ PrivilegeAMIERead PrivilegeKey = "amie:read"
+ PrivilegeAMIEWrite PrivilegeKey = "amie:write"
+ PrivilegeHPCRead PrivilegeKey = "hpc:read"
+ PrivilegeHPCWrite PrivilegeKey = "hpc:write"
+ PrivilegeSignerRead PrivilegeKey = "signer:read"
+ PrivilegeSignerWrite PrivilegeKey = "signer:write"
+ PrivilegeGrant PrivilegeKey = "privileges:grant"
+ PrivilegeRolesManage PrivilegeKey = "roles:manage"
+)
+
+// KnownPrivileges returns the static catalog of declared privilege keys.
+func KnownPrivileges() []PrivilegeKey {
+ return []PrivilegeKey{
+ PrivilegeAMIERead,
+ PrivilegeAMIEWrite,
+ PrivilegeHPCRead,
+ PrivilegeHPCWrite,
+ PrivilegeSignerRead,
+ PrivilegeSignerWrite,
+ PrivilegeGrant,
+ PrivilegeRolesManage,
+ }
+}
+
+// IsKnownPrivilege reports whether p is in the declared catalog.
+func IsKnownPrivilege(p PrivilegeKey) bool {
+ for _, k := range KnownPrivileges() {
+ if k == p {
+ return true
+ }
+ }
+ return false
+}
+
+// UserPrivilege is one active grant in user_privileges. Revoked grants are
+// deleted from the table; their history lives in audit_events.
+type UserPrivilege struct {
+ ID string `json:"id" db:"id"`
+ UserID string `json:"user_id" db:"user_id"`
+ Privilege PrivilegeKey `json:"privilege" db:"privilege"`
+ GrantedBy *string `json:"granted_by" db:"granted_by"`
+ GrantedAt time.Time `json:"granted_at" db:"granted_at"`
+ Reason *string `json:"reason" db:"reason"`
+}
Review Comment:
@lahirujayathilake Shouldn't this be connected to the Role rather than the User? You already map the role into user
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@airavata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org