-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix routes with path format not working in front of http_basic_auth
If a request was made to /my_data.xml with `Accept: */*`, and there was http basic authentication in front in the Rodauth middleware, the requested format wouldn't get selected when it came to processing the controller action. This is because rodauth-rails would infer formats from the `Accept` header as soon as it instantiated the controller (which would happen when logging the user in from Authorization header), preventing Rails from inferring the format from the URL path. We fix that by only doing this before handling Rodauth endpoints, leaving requests to Rails endpoints untouched. Fixes #272
- Loading branch information
Showing
6 changed files
with
30 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,4 +100,19 @@ class RenderTest < IntegrationTest | |
|
||
assert_equal %(<turbo-stream action="append" target="login-form"><template><div id="turbo-stream">login failed</div></template></turbo-stream>), page.html | ||
end if defined?(::Turbo) | ||
|
||
test "path format is preserved with basic auth" do | ||
Account.create!(email: "[email protected]", password: "secret123", status: "verified") | ||
page.driver.browser.basic_authorize "[email protected]", "secret123" | ||
|
||
page.driver.browser.get "/basic_auth", {}, { "HTTP_ACCEPT" => "*/*" } | ||
assert_equal "Basic Auth", page.html | ||
assert_equal "text/plain; charset=utf-8", page.response_headers["Content-Type"] | ||
|
||
page.driver.browser.get "/basic_auth.json", {}, { "HTTP_ACCEPT" => "*/*" } | ||
assert_equal "{\"message\":\"Basic Auth\"}", page.html | ||
assert_equal "application/json; charset=utf-8", page.response_headers["Content-Type"] | ||
|
||
page.driver.browser.header "Authorization", nil | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
controller :test do | ||
get :auth1 | ||
get :auth2 | ||
get :basic_auth | ||
get :secondary | ||
get :auth_json | ||
get :sign_in | ||
|