Fix OmniAuth redirect_uri for Keycloak login #167
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/redirect-uri"
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?
Summary
omniauth_openid_connectv0.8.0 does NOT auto-deriveredirect_uri— setting it tonilomits the param entirelyredirect_uriexplicitly usingAPP_URLenv var (defaults to prod URL), matchingpal-enterprisespatternChanges
config/initializers/omniauth.rb: replaceredirect_uri: nilwith explicit URL built fromAPP_URLenv var.env.example: addAPP_URLwith dev default and documentationTest Plan
landscaping-dev.tail5b443a.ts.netwithAPP_URLset in.envReview Checklist
Related Notes
project-landscaping-assistant— main projectReview — LGTM
Diff: 2 files, +5/-1. Minimal and targeted.
Root cause verified:
omniauth_openid_connectv0.8.0redirect_urimethod (line 423-427) returnsclient_options.redirect_uriverbatim — whennil, the OIDC client omits the parameter from the authorization URL. Keycloak requires it and returns 400.Fix analysis:
config/initializers/omniauth.rb: Replacesnilwith explicit URL built fromAPP_URLenv var, defaulting to prod. Matches the workingpal-enterprisespattern exactly..env.example: DocumentsAPP_URLfor dev environments. The default value in the example is the dev URL, which is correct — prod doesn't need it (falls back to hardcoded default).APP_URLis a public URL, not a secret.Verified in dev: Login flow tested via Chrome DevTools — Keycloak login form renders,
lucas-super-adminlogged in successfully with full nav tabs visible.One consideration: The
redirect_uriis set at boot time, not per-request. This means a single Rails instance can only serve one hostname. This is correct for the current architecture (prod and dev are separate deployments), but worth noting.Verdict: Approve — ship it.