Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging in on sites with basic http auth impossible #597

Open
petarbasic opened this issue Aug 26, 2021 · 3 comments
Open

Logging in on sites with basic http auth impossible #597

petarbasic opened this issue Aug 26, 2021 · 3 comments

Comments

@petarbasic
Copy link

The issue appeared after upgrading from 3.4.1 to 4.1.
Function for logging in a user does a fast logout - which resets the session and removes all the headers set.
This practically makes this step (I am logged in as a user with the "example" role) unusable with sites that have basic auth setup.

Our workaround is not a change to drupal-extension itself, but an addition to the Mink Session where we adapted it to apply basic auth after each session starts & reset.
another way to go could be to somehow acquire credentials and set the basic auth after fast logout, or remember the Authorization header and re-add it after logout (but getting headers is not supported by session/drivers).

Suggestions, remarks & explanations are welcome!

@pfrenssen
Copy link
Collaborator

pfrenssen commented Aug 26, 2021

This is a very interesting case. Maybe a quick solution could be to set the basic auth credentials in the mink base URL? e.g. http://user:pass@my-environment.

You can also override the DrupalAuthenticationManager class and extend the ::login() method to adapt it to your use case. It is probably enough to simply remove this line that does a fast logout. We are resetting the session in Mink, I'm guessing this is what causes the credentials to be reset. You would have to handle relogging with one additional step though to ensure the previous user is logged out manually when logging in a new user.

But I think your suggestion to handle this in the Mink session is probably the best approach. Basic auth is not handled by Drupal but by the webserver (Apache or Nginx), so this is something that is ideally handled inside Mink.

@Berdir
Copy link
Contributor

Berdir commented Aug 26, 2021

The also causes problems for other things, like the big pipe cookie, currently we check that inside an @AfterStep and add it back if necessary.

@fago
Copy link

fago commented Oct 8, 2021

as discussed at minkphp/Mink#810 this is best fixed here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants