Revert PR #158: restore OmniAuth to fix broken prod auth #161
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "160-urgent-revert-pr-158-prod-auth-broken-ke"
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
Emergency revert of PR #158 which replaced OmniAuth with Keycloak Direct Access Grants (ROPC). The Keycloak terraform was never applied, so Keycloak does not accept
grant_type=password, breaking production auth for all users. This revert restores OmniAuth Authorization Code flow which Keycloak IS configured for.Changes
/auth/keycloak/callbackGET/POST routesTest Plan
git revertof commitaf9dc69-- no manual editsReview Checklist
Related Notes
None -- this is a straight revert to fix prod.
Related
PR #161 Review
DOMAIN REVIEW
Tech stack: Ruby on Rails 8.1, OmniAuth OpenID Connect, Keycloak SSO, RSpec request specs.
This is an emergency revert of PR #158 (which replaced OmniAuth Authorization Code + PKCE flow with ROPC Direct Access Grants). The revert restores the OmniAuth-based auth stack that Keycloak is actually configured for in production.
Revert completeness -- all critical components verified:
Gemfile/Gemfile.lock:
omniauth_openid_connect (~> 0.8)andomniauth-rails_csrf_protection (~> 1.0)restored with full dependency tree (faraday, json-jwt, rack-oauth2, openid_connect, etc.). Checksums present. Clean.config/initializers/omniauth.rb: Restored as a new file. Configures
OmniAuth::Builderwith:openid_connectstrategy, PKCE enabled (pkce: true), Authorization Code flow (response_type: :code), and proper guards for test vs production vs dev-without-Keycloak.allowed_request_methods = %i[post]enforces POST-only OmniAuth requests (CSRF protection). Clean.config/routes.rb: Restored OmniAuth callback routes (
GET /auth/keycloak/callback,POST /auth/keycloak/callback,GET /auth/failure). The ROPCPOST /loginroute is removed,GET /loginretained for the login page.DELETE /logoutretained. Clean.SessionsController: ROPC flow (Net::HTTP POST to Keycloak token endpoint, manual JWT decoding, credential validation) replaced with OmniAuth callback pattern (
request.env["omniauth.auth"]). Thedestroyaction restores Keycloak end-session redirect viakeycloak_configured?guard.failureaction restored for OmniAuth error callback. The unsafedecode_jwt_payloadmethod (Base64 decode without signature verification) is removed -- OmniAuth handles token validation properly. Clean.Login view (sessions/new.html.erb): Username/password form fields removed, replaced with
button_to "/auth/keycloak"redirect button.flash.now[:alert]simplified toflash[:alert](correct for redirect-based flow). Clean.Layout (application.html.erb): Login link changed from
link_to login_pathtobutton_to "/auth/keycloak", method: :postwithturbo: false. This ensures the OmniAuth POST requirement is met and CSRF protection works. Clean.CSS (application.css): ROPC login form styles (
.login-form,.login-field,.login-label,.login-input) removed. These are no longer needed since the login page uses a single redirect button instead of a form. Clean.Documentation:
docs/app-architecture.mdanddocs/keycloak-setup.mdreverted from ROPC descriptions back to Authorization Code + PKCE descriptions. The ROPC flow decision section is reverted to the "ROPC Flow Validation" analysis explaining why ROPC is wrong. Client table showsdirect_access_grants_enabled = false. Clean.Test support (spec/support/omniauth.rb):
stub_keycloak_token(which fabricated fake JWT tokens for Net::HTTP stubs) replaced withmock_keycloak_authusingOmniAuth::AuthHash.sign_in_ashelper now uses OmniAuth test mode flow (post "/auth/keycloak"+ follow redirects).RSpec.configureblock sets default mock auth before each test. This is the standard OmniAuth testing pattern. Clean.Test specs:
sessions_spec.rbreverted from ROPC-specific tests (invalid credentials, blank credentials, Keycloak unavailable) to OmniAuth callback tests. Keycloak logout redirect test preserved.auth/failuretest added.role_access_spec.rbandcrew_spec.rbredirect expectations updated from/loginto/auth/keycloakwhere appropriate.PR #146 (crew tab) preservation: Verified. The crew controller, crew views, crew routes, and crew index specs are untouched by this revert. The only crew_spec changes are in the auth redirect expectations for crew member show pages (changing
/loginto/auth/keycloak), which is the correct auth behavior change.Security observations (positive):
decode_jwt_payloadmethod did Base64 JWT decoding without signature verification -- the comment said "trusted server-to-server" but this is a bad practice. OmniAuth handles token validation properly through the openid_connect library.BLOCKERS
None.
NITS
The diff is +311/-254 lines across 14 files, which is large for a revert. However, reviewing the content confirms this is a clean reversal of PR #158's changes -- every addition restores pre-#158 code and every deletion removes #158's additions. No manual edits or additional changes detected beyond what
git revertwould produce.The
crew_spec.rbdiff shows changes to crew member show specs (lines 90+) that referenceactive_member.id. These lines exist in the PR branch but not onmaincurrently -- this suggests the branch was based on a commit that included crew member show changes. Sincemergeable: trueper Forgejo, there should be no conflict, but worth noting.SOP COMPLIANCE
160-urgent-revert-pr-158-prod-auth-broken-kereferences issue #160PROCESS OBSERVATIONS
direct_access_grants_enabled = true) was never applied. This is a deployment coordination gap -- the app change shipped without the infrastructure change it depended on.docs/keycloak-setup.mdrecommends against ROPC entirely, which this revert correctly restores.VERDICT: APPROVED