Skip to content

fix: role grants, admin audit and OIDC settings - #787

Merged
catinspace-au merged 1 commit into
mainfrom
fix/engine-followups
Oct 10, 2026
Merged

catinspace-au merged 1 commit into
mainfrom
fix/engine-followups

Conversation

@catinspace-au

Copy link
Copy Markdown
Contributor

Four engine defects found reading rbac.md against the code. All small, all in auth.

  • data_analyst could not compile or test a transform. Its grant was transforms:*, the routes check transform:compile and transform:test, so only admin passed. Same shape for infra_viewer's service-surface:read vs the catalogue's service_surface:read. Both grants now name the catalogue's actions.
    • API_ENFORCED_ACTIONS also listed the plural, plus config:read and query:write, which no route enforces. Gone.
    • New test: every built-in grant must name a domain the catalogue defines, and every exact grant must be an action it lists. A third test keeps API_ENFORCED_ACTIONS inside the scope constants, so the plural cannot sneak back in through it.
  • Account, group, API key and role writes left no audit trail. Every mutating route under /api/v1/auth/{accounts,groups,api-keys,roles} now emits one event: actor, change, target. Details carry roles, groups, members or permissions, and contact field NAMES only. Never a password, hash, attribute value or the secret half of a key. audit_role_change is new.
  • auth.oidc.providers_dir, sync_enabled and sync_on_startup parsed and did nothing. Removed. The providers dir is always <auth_dir>/oidc-providers and oidc_group_sync_enabled already gates the sync. A config file still carrying auth.oidc loads fine.
  • DFE_AUTH_OIDC_GROUP_SYNC_ENABLED and DFE_AUTH_OIDC_GROUP_SYNC_TICK_SECONDS were documented and never read. Now routed, and in the docstring the env-var guard test parses.

Existing deployments keep the old grants. The engine seeds rbac/roles.yaml once and never rewrites it, and the API refuses edits to built-in roles, so a running deployment picks up the fixed data_analyst grant only when someone edits that file. rbac.md now says so.

Done when CI is green and data_analyst can hit /api/v1/transforms/compile on a fresh deployment.

data_analyst held transforms:* and infra_viewer service-surface:read, but the routes check transform:compile, transform:test and service_surface:read, so neither grant matched anything and only admin could compile or test a transform. The grants now name the catalogue's actions, and API_ENFORCED_ACTIONS drops the plural transform actions plus config:read and query:write, which no route enforces. A new test fails when a built-in grant names a domain or exact action the catalogue does not define.

Account, group, API key and role writes under /api/v1/auth now each emit one audit event with the actor, the change and the target. Details carry the roles, groups, members or permissions written and the names of contact fields changed, never a password, a hash, an attribute value or the secret half of an API key. audit_role_change is new; the account, group and API key helpers take an optional details dict.

auth.oidc.providers_dir, sync_enabled and sync_on_startup are removed: nothing read them, the providers directory is always <auth_dir>/oidc-providers, and oidc_group_sync_enabled already gates the background sync. A config file still carrying auth.oidc loads unchanged.

DFE_AUTH_OIDC_GROUP_SYNC_ENABLED and DFE_AUTH_OIDC_GROUP_SYNC_TICK_SECONDS were named in field help but never read. Both are now routed in the env overrides and listed in the AuthSettings docstring, where the existing guard test checks them.

rbac.md matches: the transform grant, the new audit events, the env vars, and the fact that an existing rbac/roles.yaml is never rewritten, so a changed built-in grant reaches a running deployment only by editing that file.
@catinspace-au
catinspace-au merged commit e8f98c7 into main Oct 10, 2026
20 checks passed
@catinspace-au
catinspace-au deleted the fix/engine-followups branch October 10, 2026 08:17
@github-actions

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant