-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat: add support for custom authorization header names #2524
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
Open
Ndugu2
wants to merge
1
commit into
kubernetes-client:master
Choose a base branch
from
Ndugu2:fix-custom-auth-header-2510
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+33
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -161,15 +161,29 @@ def __init__(self, host="http://localhost", | |
| self.proxy = None | ||
| """Proxy URL | ||
| """ | ||
| self.no_proxy = None | ||
| # Load proxy from environment variables (if set) | ||
| self.authorization_header = "Authorization" | ||
| """Custom authorization header name (default: "Authorization")""" | ||
| self.no_proxy = [] | ||
| # Load proxy from environment variables (if set) | ||
| if os.getenv("HTTPS_PROXY"): self.proxy = os.getenv("HTTPS_PROXY") | ||
| if os.getenv("https_proxy"): self.proxy = os.getenv("https_proxy") | ||
| if os.getenv("HTTP_PROXY"): self.proxy = os.getenv("HTTP_PROXY") | ||
| if os.getenv("http_proxy"): self.proxy = os.getenv("http_proxy") | ||
| # Load no_proxy from environment variables (if set) | ||
| if os.getenv("NO_PROXY"): self.no_proxy = os.getenv("NO_PROXY") | ||
| if os.getenv("no_proxy"): self.no_proxy = os.getenv("no_proxy") | ||
| # Load and parse no_proxy from environment variables | ||
| # Check for uppercase NO_PROXY first (should take precedence) | ||
| no_proxy_env = None | ||
| # Check if NO_PROXY exists in environment (even if empty) | ||
| if "NO_PROXY" in os.environ: | ||
| no_proxy_env = os.getenv("NO_PROXY") | ||
| elif "no_proxy" in os.environ: | ||
| no_proxy_env = os.getenv("no_proxy") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're mixing this PR with another one for no_proxy? |
||
|
|
||
| if no_proxy_env is not None and no_proxy_env != "": | ||
| self.no_proxy = [ | ||
| domain.strip() | ||
| for domain in no_proxy_env.split(",") | ||
| if domain.strip() | ||
| ] | ||
| """bypass proxy for host in the no_proxy list. | ||
| """ | ||
| self.proxy_headers = None | ||
|
|
@@ -345,12 +359,22 @@ def auth_settings(self): | |
| :return: The Auth Settings information dict. | ||
| """ | ||
| auth = {} | ||
| if 'authorization' in self.api_key: | ||
| # Check for the configured authorization header name in api_key (case-insensitive) | ||
| header_name_lower = self.authorization_header.lower() | ||
|
|
||
| # Find the actual key in api_key that matches case-insensitively | ||
| actual_key = None | ||
| for key in self.api_key: | ||
| if key.lower() == header_name_lower: | ||
| actual_key = key | ||
| break | ||
|
|
||
| if actual_key is not None: | ||
| auth['BearerToken'] = { | ||
| 'type': 'api_key', | ||
| 'in': 'header', | ||
| 'key': 'authorization', | ||
| 'value': self.get_api_key_with_prefix('authorization') | ||
| 'key': self.authorization_header, # Use the configured case | ||
| 'value': self.get_api_key_with_prefix(actual_key) # Use the actual key from api_key | ||
| } | ||
| return auth | ||
|
|
||
|
|
@@ -411,4 +435,4 @@ def get_host_from_settings(self, index, variables=None): | |
|
|
||
| url = url.replace("{" + variable_name + "}", used_value) | ||
|
|
||
| return url | ||
| return url | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is generated by the openapi generator. Please make the change in upstream