fix(BA-6955): grant kernel scheduling-history read alongside session read#13000
fix(BA-6955): grant kernel scheduling-history read alongside session read#13000jopemachine wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…read The scoped kernel scheduling-history endpoint is registered with auth_required and its action declares kernel:history as the entity being read, yet every non-superadmin caller -- including the owner of the kernel -- was rejected, because nothing ever granted kernel:history read: - Migration a1c4e7b93f22 mirrored grants from entity_type 'kernel', which nothing creates (kernels are reached through their owning session), so its SELECT matched zero rows. The empty result also masked the INSERT omitting the NOT NULL permission column. - Runtime scope-role creation never included kernel:history either, so even a corrected backfill would have left users created afterwards without access. Per the BEP-1048 scope-chain model, the subject of the check is the entity being read, with grants expected at ancestor scopes -- so the fix supplies the grants rather than changing the action: - Rewrite the (unreleased) migration to mirror session READ grants, carrying the source permission bits. Reading a session is what carries kernel visibility, so its history follows the same boundary. - Make the downgrade a documented no-op: once roles receive the grant natively at creation, a mirror-based DELETE cannot tell backfilled rows from native ones (same rationale as f2b9a4c7e103). - Grant kernel:history READ natively in the user owner, project admin, project member, and domain admin scope roles, following the *_admin_page precedent. Verified on a live stack: a freshly created user's role receives kernel:history read natively; the backfill inserts mirrored rows idempotently; the kernel owner passes the scoped query while deleting the rows makes the same query fail with NotEnoughPermission. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
8a5bc35 to
4a9e0c2
Compare
|
Reopened with a reworked scope. The earlier close comment claimed the migration approach itself was wrong — re-verification against What the earlier attempt was actually missing was the runtime half: scope roles created after the backfill also need the grant, following the |
|
This will be addressed when we introduce virtual scopes and add the permission migration for kernel records. For now, I'll work around the issue by changing the entity type itself to |
|
For the record: the design owner confirmed that kernel-entity permission records are intentionally kept empty, so this PR's grant-seeding approach (backfill + native role-creation grants) contradicts the intended data model and stays closed. The kernel-owner 403 is fixed in #12866 by authorizing the scoped search through |
Resolves #12999 (BA-6955)
Summary
POST /v2/scheduling-history/kernels/scoped/search(and thescopedKernelSchedulingHistoriesGQL query) is registered withauth_requiredand its action declareskernel:historyas the entity being read, yet every non-superadmin caller — including the owner of the kernel — was rejected, because nothing ever grantedkernel:historyread:a1c4e7b93f22mirrored grants fromentity_type = 'kernel', which nothing creates (kernels are reached through their owning session), so itsSELECTmatched zero rows. The empty result also masked theINSERTomitting theNOT NULLpermissioncolumn.kernel:historyeither, so even a corrected backfill would have left users created afterwards without access.Per the scope-chain model in
proposals/BEP-1048/permission-check-scope-chain-examples.md§2, the subject of the check is the entity being read, with grants expected at ancestor scopes — so the fix supplies the grants rather than changing the action's entity type:sessionREAD grants, carrying the sourcepermissionbits21159a293dfband the other migrate-to-rbac backfillskernel:historyREAD natively in the user owner, project admin, project member, and domain admin scope roles*_admin_pageentries in the sameentity_operations()methodsf2b9a4c7e103Reading a session is what carries kernel visibility (
search_kernel.pyauthorizes viasession), so kernel scheduling history follows the same boundary: it is exactly as visible as the session it belongs to, including domain-scopedsessionread grants.Test plan
Verified on a live stack (kernel
f53384a7…owned byuser@lablup.com):kernel:history read (permission=1)natively, with no migration involvedON CONFLICT DO NOTHING)kernel:historyrows makes the same owner query fail withNotEnoughPermission; restoring them makes it pass — the check is enforced by exactly these rowsentity_operations()changes (tests/unit/manager/data/{user,group,domain}/test_types.py)🤖 Generated with Claude Code