Skip to content

feat(roles): seed default group bindings to match test personas#462

Merged
larsgeorge-db merged 1 commit into
mainfrom
feat-seed-default-role-groups
May 29, 2026
Merged

feat(roles): seed default group bindings to match test personas#462
larsgeorge-db merged 1 commit into
mainfrom
feat-seed-default-role-groups

Conversation

@larsgeorge-db
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #459 (runtime test-user impersonation). Until now only the Admin role shipped with a default assigned_groups binding (driven by APP_ADMIN_DEFAULT_GROUPS). All other seeded roles were created with empty assigned_groups, so the runtime persona override would correctly impersonate the persona's identity but resolve to zero permissions — making the feature useless out of the box for anything except the Admin persona.

This patch bakes the conventional group names into both seed sources so every persona in src/backend/src/data/test_personas.yaml lands in the matching role on first run.

Bindings added

Role assigned_groups
Data Governance Officer data-governance-officers
Data Steward data-stewards
Data Producer data-producers
Data Consumer data-consumers
Security Officer security-officers

Group names match the personas in test_personas.yaml and the labels in the Test Persona dropdown.

Sources touched

  • src/backend/src/data/settings.yaml — the authoritative seed YAML.
  • DEFAULT_ROLES in src/backend/src/controller/settings_manager.py — the in-code fallback used when the YAML is missing. Also updated the generated_roles codepath that writes the YAML on first run, so a fresh deployment without settings.yaml also gets the bindings.

Why Admin is intentionally NOT touched

Admin's assigned_groups continue to come from APP_ADMIN_DEFAULT_GROUPS. Hardcoding it here would risk granting admin to whatever happens to be set on someone's local workspace by name collision. Production deployments keep explicit control via env var.

Migration

Existing deployments already have role records persisted to the database and will not be affected by this change (the seed only fires when records are missing). To pick up the new bindings on an existing install:

  • Recommended: Settings → Roles → edit each role → add the corresponding group from the table above.
  • Or: delete the affected role rows so they get re-seeded on next start.

Test plan

  • Fresh install (empty DB, no settings.yaml): role records pick up the new groups.
  • Fresh install (with shipped settings.yaml): role records pick up the new groups.
  • Existing install: role records remain unchanged (verifies we're not destructive).
  • With TEST_USER_TOKEN set: pick "Data Producer" from the Test Persona dropdown -> /api/user/permissions returns Producer's permission map (non-empty), not None across the board.

@larsgeorge-db larsgeorge-db requested a review from a team as a code owner May 28, 2026 11:06
Until now only the Admin role shipped with a default `assigned_groups`
binding (driven by `APP_ADMIN_DEFAULT_GROUPS`). The other seeded roles —
Data Governance Officer, Data Steward, Data Producer, Data Consumer,
Security Officer — were created with empty `assigned_groups`, which
meant the runtime persona override (added in #459 / e8bd863) would
correctly impersonate the persona's identity but resolve to *zero*
permissions until an operator manually added groups to each role in the
Settings UI.

This patch bakes the conventional group names into both seed sources so
the persona flow works end-to-end on first run:

  Data Governance Officer  <- data-governance-officers
  Data Steward             <- data-stewards
  Data Producer            <- data-producers
  Data Consumer            <- data-consumers
  Security Officer         <- security-officers

The group names match `src/backend/src/data/test_personas.yaml` and the
labels used in the Test Persona dropdown.

Sources touched:
- `src/backend/src/data/settings.yaml` (the authoritative seed YAML)
- `DEFAULT_ROLES` in `settings_manager.py` (in-code fallback used when
  the YAML is missing) — including the `generated_roles` codepath that
  writes the YAML on first run, so a fresh deployment without
  `settings.yaml` also gets the bindings.

Admin is intentionally NOT given a hardcoded default here — its
`assigned_groups` continue to come from `APP_ADMIN_DEFAULT_GROUPS` so
production deployments retain explicit control over admin assignment.

Migration note: existing deployments already have role records
persisted to the database and won't be affected by this change. To pick
up the new bindings, either edit roles via Settings → Roles and add the
groups listed above, or delete the affected role rows so they get
re-seeded on next start.
@larsgeorge-db larsgeorge-db force-pushed the feat-seed-default-role-groups branch from 121bb10 to 18dfcf7 Compare May 29, 2026 15:24
@larsgeorge-db larsgeorge-db merged commit c9a0f3e into main May 29, 2026
7 checks passed
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