PH0.4 — Keycloak auth: JWKS bearer validation, require_role, GET /me, LDAP smoke test #7
Labels
No labels
in-progress
in-review
ready-for-agent
seam-request
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Depends on
Reference
patrick/Polaris#7
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
Row PH0.4 in
docs/12-implementation-plan.md(branch, owned paths and doc section are defined there).What to build
API requests carry a Keycloak bearer token that is validated against the realm's JWKS with an audience check; endpoints declare the roles they need;
GET /mereturns the caller's subject, username, roles and locale. A compose-level smoke test proves the LDAP group → realm role mapping for all five users.Acceptance criteria
require_rolereturns 403 for a caller lacking the roleGET /mereturnssub,preferred_username, roles andlocale/meshows exactly that user's roleBlocked by
Starting PH0.4 on branch
feature/auth-keycloak.Owns (per docs/12-implementation-plan.md row PH0.4):
backend/src/polaris/api/auth.py,backend/src/polaris/api/routers/me/**,backend/tests/**/auth*.Note:
maindid not yet have the PH0.2 API skeleton merged -- PR #51 mergedfeature/api-skeletonintodevelop, notmain, sobackend/was missing frommain. Branched fromorigin/mainand mergedorigin/developin (disjoint paths, no conflicts) to getbackend/polaris.api/polaris.dbto build on. Flagging this in casedevelop->mainneeds a separate sync; my PR still targetsmainper the ticket instructions.Delivering: JWKS-validated bearer auth (
polaris.api.auth) against the realm frominfra/keycloak/realm-polaris.json,audcheck,require_role(...)dependency,GET /me(sub,preferred_username, roles,locale), a unit test with a locally-signed token, and a compose-level smoke test logging in as each of the 5 LDAP users and asserting/me's role.PR opened: #56 (
feature/auth-keycloak->main). All four acceptance criteria checked above.Note on the earlier
main/developsplit I flagged when starting: while this was in flight,mainpicked up a merge ofdevelopand retired the two-branch gitflow in favour of a single trunk (see updatedCLAUDE.md/docs/10-dev-workflow.md) -- so that concern is resolved upstream now. I merged the freshmaininto this branch (clean, doc-only conflict-free merge) so the PR is mergeable.ruff,ruff format --check,mypy --strictand the fullpytestsuite (46 tests) are green. The LDAP smoke test (backend/tests/integration/api/auth_smoke_test.py, markersmoke) was run against a realdocker compose -f infra/compose/docker-compose.yml up db openldap ldap-init keycloakin this session -- all five bootstrap users (admin,planner,technician,viewer,ingest) log in viapolaris-web's PKCE flow andGET /mereturns exactly their own realm role. Stack torn down afterwards.Not merging myself per the workflow -- ready for review.