Skip to content

refactor(auth): acceso por rol con lista de permitidos - #9

Merged
bpstack merged 5 commits into
claude/compassionate-planck-gh6aoffrom
opencode/role-access
Oct 12, 2026
Merged

bpstack merged 5 commits into
claude/compassionate-planck-gh6aoffrom
opencode/role-access

Conversation

@bpstack

@bpstack bpstack commented Oct 12, 2026

Copy link
Copy Markdown
Owner

Cambios

  • Tests que fijan el acceso por rol de cada router antes del cambio.
  • excludeMantenimiento pasa de excluir mantenimiento a una lista de roles permitidos (FRONT_DESK_ROLES, compartida desde module-access.ts).
  • El 403 ya no dice «solo mantenimiento»; mocks de los tests tipados.
  • docs/TODO.md: se borra el punto, ya hecho.

Por qué

Con una lista de exclusión, cualquier rol nuevo entraba por defecto en parking, lista negra, grupos y demás.

- Test excludeMantenimiento with 4 roles + missing user + uppercase

- Test canOpenModule with 4 roles x 6 modules matrix

- Verify 9 routers use excludeMantenimiento middleware
- excludeMantenimiento now uses allowedRoles = ['admin', 'recepcionista', 'group-admin'] instead of blockedRoles = ['mantenimiento'], so unknown roles are denied by default
- module-access.ts: rename allButMaintenanceRole to frontDeskRoles with an explicit allowlist
- role-access.test.ts: add 'auditor' role case (403 in middleware, false in all 6 modules)
…ny role

- module-access.ts: export FRONT_DESK_ROLES and build frontDeskRoles on it.
- roleCheck.ts: excludeMantenimiento reads FRONT_DESK_ROLES instead of its
  own copy, and its 403 no longer says the role only reaches maintenance.

Why: the allowlist lived in two files that had to be kept in step, and
after the switch to an allowlist the old message was wrong for any role
other than mantenimiento.
- Remove the "excludeMantenimiento is an exclusion list" entry.

Why: the guard and module-access.ts share FRONT_DESK_ROLES, an allowlist;
role-access.test.ts pins the four roles and denies an unknown one.
@vercel

vercel Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
four-points Ready Ready Preview Oct 12, 2026 7:45am UTC

@bpstack
bpstack merged commit 47a95b5 into claude/compassionate-planck-gh6aof Oct 12, 2026
6 checks passed
@bpstack
bpstack deleted the opencode/role-access branch October 12, 2026 19:02

This branch was successfully deployed

1 active deployment
Preview — 4c1023a5 Deployed Oct 12, 2026 by vercel[bot]
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