Replace OmniAuth redirect with Keycloak Direct Access Grants #157
Loading…
Add table
Add a link
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?
Type
Feature
Lineage
Corrects auth implementation from Phase 1 (#115). Original decision (2026-06-04) was Direct Access Grants with login form in the app. OmniAuth redirect flow was implemented instead by spike #132 / PR #134 without escalating the decision change. This restores the intended architecture.
Repo
ldraney/landscaping-assistantUser Story
As a landscaping app user (web or iOS)
I want to log in with a username and password on the app's own login page
So that I never see Keycloak's UI and the experience is consistent across web and turbo-ios
Context
The app currently uses OmniAuth OpenID Connect (Auth Code + PKCE) which redirects users to Keycloak's default grey login page. This breaks mobile UX expectations and doesn't match the turbo-ios App Store experience we're building toward. Direct Access Grants (ROPC) lets the app render its own login form and exchange credentials with Keycloak server-side. No redirect, no external UI.
Pre-requisite: Direct Access Grants must be enabled on the Keycloak client in pal-e-services Terraform (separate cross-repo task).
File Targets
Files to modify:
Gemfile— removeomniauth,omniauth_openid_connect,omniauth-rails_csrf_protection; addjwtif neededconfig/initializers/omniauth.rb— delete entirelyapp/controllers/sessions_controller.rb— rewritecreateto POST username/password to Keycloak token endpoint, decode JWT, store in sessionapp/controllers/application_controller.rb— remove OmniAuth-specific checks (keycloak_configured? may need updating)app/views/sessions/new.html.erb— replace Keycloak redirect button with username + password formconfig/routes.rb— replace/auth/keycloak/*routes withpost "/login"spec/requests/sessions_spec.rb— rewrite for direct grants flowspec/requests/role_access_spec.rb— update auth helpersdocs/app-architecture.md— update auth flow diagram and descriptiondocs/keycloak-setup.md— note decision reversal, update ROPC sectionFiles NOT to touch:
app/controllers/application_controller.rbrole-checking logic (require_role, current_user_roles) — these work off session data and don't care how the session was createdAcceptance Criteria
Test Expectations
bundle exec rspecConstraints
{KEYCLOAK_URL}/realms/{KEYCLOAK_REALM}/protocol/openid-connect/tokenpasswordwithclient_id,client_secret,username,password,scope=openidsession[:user] = {username:, email:, roles:}Checklist
Related
landscaping-assistantprojectldraney/landscaping-assistant #115— original Keycloak login implementationldraney/landscaping-assistant #132— spike that recommended Auth Code over ROPCldraney/landscaping-assistant #154— assume_ssl band-aid (superseded by this)Reading this issue to plan the Direct Access Grants rewrite. This is the proper auth architecture per the 2026-06-04 decision -- OmniAuth redirect flow was implemented by mistake and is currently broken in prod.