Repository navigation
can't use multiple login strategies to require an account inside a rodauth route #515
Replies: 2 comments 4 replies
|
Thank you for bringing this up. The error is expected from the changes, since you are using two different login types in the same route, so the potential for account confusion exists. If the http basic auth is for a different account as a logged in session, what should the behavior be? A possible fix is to add a configuration option so that if diff --git a/lib/rodauth/features/http_basic_auth.rb b/lib/rodauth/features/http_basic_auth.rb
index a4d03820..03cf8ab6 100644
--- a/lib/rodauth/features/http_basic_auth.rb
+++ b/lib/rodauth/features/http_basic_auth.rb
@@ -4,6 +4,7 @@ module Rodauth
Feature.define(:http_basic_auth, :HttpBasicAuth) do
auth_value_method :http_basic_auth_realm, "protected"
auth_value_method :require_http_basic_auth?, false
+ auth_value_method :http_basic_auth_set_account_session?, false
uses_instance_variables(:@checked_http_basic_auth)
@@ -33,6 +34,10 @@ module Rodauth
end
end
+ def require_account_session
+ super unless @checked_http_basic_auth && http_basic_auth_set_account_session?
+ end
+
def http_basic_auth
unless @checked_http_basic_auth.nil?
return (@checked_http_basic_auth ? true : nil)I don't think this should be the default behavior, because I think it allows for the potential for account confusion. What do you think about that approach? To quickly work around this issue, you can override |
|
I did more testing this evening and the While I don't think this results in account confusion, use of the http_basic_auth feature means that the account could be loaded from either the session or from the Authorization header. I think in many scenarios, that might be the desired behavior, but I'm not sure if that is a good default. Might be worth a configuration setting so that |
Uh oh!
There was an error while loading. Please reload this page.
I think this is a bug, but I'm not sure yet whether intended, so I'll post here first.
rodauth-oauth tests are broken with the latest version of rodauth, more specifically, this test which exercises login via http basic auth.
The roda application used for testing enables both login and http_basic_auth. These seem to be incompatible now since 2.47, which shipped a lot of security patches, one of them which broke
require_accountwhen used inside a rodauth route, which sets the@current_routeand triggers the condition.I prepared a reproduction:
this breaks with the following message:
lmk if you think this is a bug, or requires some different handling on my side.
All reactions