Skip to content

Commit

Permalink
Prevent Authorization header to be overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellweg committed Jul 1, 2024
1 parent e858364 commit cbcf3c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/+auth_header.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A provided "Authorization" header will no longer be overruled by other authentication mechanisms.
6 changes: 5 additions & 1 deletion pulp-glue/pulp_glue/common/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,11 @@ def render_request(
"security", self.api_spec.get("security", {})
)
if security and self.auth_provider:
auth = self.auth_provider(security, self.api_spec["components"]["securitySchemes"])
if "Authorization" in self._session.headers:
# Bad idea, but you wanted it that way.
auth = None
else:
auth = self.auth_provider(security, self.api_spec["components"]["securitySchemes"])
else:
# No auth required? Don't provide it.
# No auth_provider available? Hope for the best (should do the trick for cert auth).
Expand Down

0 comments on commit cbcf3c8

Please sign in to comment.