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

Add faq item: Basic auth (Authorization header) does not work after redirection #2921

Merged
merged 1 commit into from
Oct 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,33 @@ Control headers or other things about my HTTP requests
requests first and then ask on Stack Overflow for additional Locust
specific help if necessary.


Basic auth (Authorization header) does not work after redirection
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
`requests <https://requests.readthedocs.io/en/master/>`__ has a security mecanism that
drops the authorization header on domain change. It could occure when testing a SSO,
which is typically on a different domain and use mulitple redirections (30x).

Since ``allow_redirects=True`` is the default ``request`` behavior you'll have to turn it off,
handle manually the redirections and inject again the authorization header, ex::


.. code-block:: python

response = self.client.post(
allow_redirects=False,
url=...)

while "location" in response.headers:
response = self.client.get(
allow_redirects=False,
url=response.headers['location'],
headers={
'Authorization': 'XXX'
}
)


Create a Locust file based on a recorded browser session
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -98,4 +125,4 @@ If you have questions about Locust that are not answered here, please
check
`StackOverflow <https://stackoverflow.com/questions/tagged/locust>`__,
or post your question there. This wiki is not for asking questions but
for answering them :)
for answering them :)
Loading