mirror of
https://github.com/cozystack/cozystack.git
synced 2026-11-22 12:43:32 +09:00
Real bug caught by an end-to-end OIDC login test on dev3: apiserver accepts the JWT (auth succeeds) but the RBAC check fails with 403 because the CRB `User:` subject was `alice-oidc@test3.example` (from `users[].email`) but the apiserver-visible identity was `alice-oidc` (from `preferred_username`, which in the cozy realm is the Keycloak *username*, not the email). The design proposal example used `claim: preferred_username`, but the operator-facing `users[].email` field explicitly asks for the email address. In the cozy realm — verified — `preferred_username` is the Keycloak username (`kvaps`, `i.okhotnikov`), so the two do NOT coincide. Every user whose Keycloak username differs from their email would silently 403 after a successful OIDC handshake. Switch the AuthenticationConfiguration `claimMappings.username.claim` to `email`, aligning the apiserver-visible identity with the operator-declared `users[].email`. Every conformant OIDC provider emits `email` — cozy realm does (verified), and any BYO `CustomConfig` issuer that follows OIDC does too. The switch is invisible to installers where `preferred_username` already equals the email (a common Keycloak setup); for installers where it doesn't, this fix is required for RBAC to work at all. Signed-off-by: Ivan Okhotnikov <ivan.okhotnikov@aenix.io>
How to test packages local
cd packages/core/installer
make image-cozystack REGISTRY=YOUR_CUSTOM_REGISTRY
make apply
kubectl delete po -l app=source-controller -n cozy-fluxcd