Consolidate auth callbacks and fix Slack controller issues#71
Open
Consolidate auth callbacks and fix Slack controller issues#71
Conversation
Replaces #66, #67, #68, #70 with a single cohesive fix: - Merge check_session_expiry + check_user_token into one authenticate! callback, eliminating the double-render risk by design - SessionsController and Slack::ApplicationController now each skip a single authenticate! instead of managing multiple callbacks - Rename valid_slack_request? to verify_slack_request! and make it halt with head :unauthorized when signature verification fails - Replace head :unprocessable_entity in send_message with logging and Sentry.capture_exception so notification failures never affect the HTTP response back to Slack
This was referenced Mar 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supersedes #66, #67, #68, #70.
Context
A code review identified four related bugs across the auth and Slack controller layers. Rather than merging four separate fixes, this PR addresses all of them with a more robust design.
Problems
#66 — Double render in
ApplicationControllerTwo separate before_actions (
check_session_expiry,check_user_token) both calledrenderwithout returning. When a session expired, both fired and raisedAbstractController::DoubleRenderError.#67 — Slack auth filter never halted
valid_slack_request?returned a boolean but never calledrenderorhead, so invalid/unauthenticated Slack requests silently passed through to the action.#68 — Double render in
Slack::PuzzlesControllersend_messagecalledhead :unprocessable_entityon Slack API errors, but execution returned tocreatewhich then calledrender json:— another double render. It also incorrectly told Slack the request failed even when the puzzle had already been saved.#70 —
SessionsControllermissingskip_before_actioncheck_user_tokenwas skipped butcheck_session_expirywas not, so users with an expired session were shown the login page instead of completing the OAuth callback.Solution
ApplicationController— consolidate into oneauthenticate!callback:One callback means one render path — the double-render is impossible by design.
SessionsController— one skip covers everything:Slack::ApplicationController— three fixes:Tests
12 tests covering all fixed scenarios: