c30b663c5196048cf86b8a0dc8b3de608573f9bc
Lays the foundation for the `/api/admin/*` surface per ADR-0020.
This PR ships the guard, the `@RequireAdmin()` decorator, and a
self-test endpoint — no business routes yet.
- `AdminRoleGuard` (apps/portal-bff/src/admin/admin-role.guard.ts):
- No session → 401 (no audit; unauthenticated probes are noise).
- Session but `roles` lacks `admin` → 403 + `admin.access_denied`
audit row capturing actor hash, attempted route, and roles held.
- Session with `admin` → pass through.
- Audit-write failures propagate (no audit ⇒ no action,
consistent with the existing call sites in AuthController).
- `@RequireAdmin()` decorator wraps `@UseGuards(AdminRoleGuard)`
via `applyDecorators` so future composition (e.g. with the
upcoming `@RequireMfa()` for the admin entry route) is mechanical.
- `GET /api/admin/me` returns the public user payload + `roles` for
ops to verify the gate is wired correctly end-to-end. The handler
intentionally has no logic beyond the projection — the value of
the endpoint is the guard chain it forces traffic through.
- `AuditWriter.adminAccessDenied()` typed method keeps the salt
inside the audit module and matches the pattern of the existing
typed events. Uses the pre-existing `denied` outcome enum value.
Surface impact:
- No new env vars, no new dependencies.
- The shared portal-shell session is the auth source for this PR.
The distinct `__Host-portal_admin_session` cookie + admin auth
flow land in the next PR per the chantier sequence.
Tests: +11 specs (7 guard, 2 controller, 2 typed audit method).
Documentation index
This is the entry point to all project documentation. It is maintained automatically: any addition, rename, or removal of a .md file under docs/ must be reflected here in the same change.
Conventions
- Documentation is written in English.
- One topic per file. Group related files into a folder when there are three or more.
- Cross-reference with relative links so they keep working in GitHub, IDEs, and exported sites.
- For architectural decisions, do not add them here — they belong in decisions/ as MADR 4.0.0 ADRs.
Sections
Daily development
- development.md — repo layout, prerequisites, initial setup, daily commands, observability dev-loop (Jaeger UI, log ↔ trace correlation), dependency updates (Renovate), conventional commit cycle. Day-to-day reference for working on the project.
Architecture
- architecture.md — cross-cutting Mermaid diagrams: C4 system context, C4 containers, Nx module boundaries, CI/CD pipeline. Single-decision diagrams (auth sequence, ERD, etc.) live inline in their ADR.
Onboarding & environment
Setup guides for new contributors:
- setup/01-wsl-terminal-setup.md — modern WSL terminal (Zsh + Powerlevel10k + CLI tools)
- setup/02-dev-web-stack.md — Node via nvm, pnpm via corepack, Docker
- setup/03-angular-nx-monorepo.md — Angular + Nx monorepo bootstrap
Operations & runbooks
Empty — to be populated when we deploy.
Security, performance, accessibility
Empty — placeholders to be filled with rationale docs alongside their corresponding ADRs.
Description
Languages
TypeScript
85.3%
JavaScript
5.4%
SCSS
4.3%
HTML
3.9%
Shell
0.8%
Other
0.3%