Remove http_digest - #2849
Open
ericproulx wants to merge 1 commit into
Open
Conversation
Nothing it could reach has existed since 2.0.0. #2361 removed Rack::Auth::Digest and Grape's :http_digest strategy after Rack 3 dropped digest authentication, but Grape::Middleware::Auth::DSL#http_digest survived and kept recording its settings, so an API declaring it still booted -- and then raised Grape::Exceptions::UnknownAuthStrategy on the first request, from inside the middleware build, as an uncaught exception rather than a response. A misconfiguration only visible in production. The 4.0 UPGRADING notes still used `auth :http_digest, realm: 'API', opaque: 'secret'` as a worked example of a supported call, so the documentation pointed at it too. That section is rewritten, and the removal documented. Removing the sugar rather than validating the strategy when `auth` is called: #auth deliberately records whatever it is given and resolves the strategy when the middleware is built, which is what lets an application register its own. That contract is specified -- validating early breaks it, and would break registering a strategy after the API class is defined. `auth :http_digest` therefore still works for anyone who registered one; only the sugar is gone, along with the two defaults it supplied (realm 'API Authorization', opaque 'secret'), which UPGRADING spells out. The DSL specs used :http_digest as their example label for #auth itself. They now use a neutral :custom, which keeps the distinction the specs are actually about: #auth records a label, the strategy behind it is looked up later. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ericproulx
force-pushed
the
remove/http-digest-dsl
branch
from
August 1, 2026 12:53
de85b55 to
2e12a20
Compare
Danger ReportNo issues found. |
4 tasks
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.
Summary
Nothing
http_digestcould reach has existed since 2.0.0. #2361 removedRack::Auth::Digestand Grape's:http_digeststrategy after Rack 3 dropped digest authentication — butGrape::Middleware::Auth::DSL#http_digestsurvived, complete with itsopaque-defaulting logic, and kept recording its settings happily.So an API declaring it still booted, and then raised on the first request:
Raised from inside the middleware build, so it escaped as an uncaught exception rather than a response — a misconfiguration only visible in production.
The 4.0 UPGRADING notes pointed at it too, using
auth :http_digest, realm: 'API', opaque: 'secret', &procas a worked example of a supported call.http_digest(...)with no registered strategyNoMethodErrorwhile the class is definedauth :http_digest, ...with a registered strategyWhy remove the sugar rather than validate the strategy
I tried validating in
#authso an unregistered strategy raises at definition time. It breaks 6 in-tree specs:dsl_spec.rbhas a.http_digestblock asserting it "sets auth parameters", and the.authspecs use:http_digestas their example label throughout.That makes the contract deliberate and specified —
#authrecords whatever label it is given and resolves the strategy when the middleware is built, which is exactly what lets an application register its own. Validating early breaks that, and would also break registering a strategy after the API class is defined.So only the sugar goes.
auth :http_digeststill works for anyone who registered a strategy under that label; verified.Backward compatibility
UPGRADING entry added, and the existing keyword-arguments section rewritten to stop advertising
http_digest.The removed method supplied two defaults
authdoes not —realmdefaulted to'API Authorization'andopaqueto'secret'(nested insiderealmwhenrealmwas itself a Hash) — so UPGRADING spells those out for anyone migrating a custom strategy toauth.Test plan
.http_digestdescribe block and its deprecation example are removed; the.authspecs now use a neutral:customlabel, which keeps the distinction they are actually about (a label is recorded, the strategy is looked up later).http_digestnow raisesNoMethodErrorat definition, and thatauth :http_digestwith a registered strategy still authenticates (200).🤖 Generated with Claude Code