fix: support kubernetes client v35-v36 token keys#33
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Kubernetes authorization plugin’s temporary Kubernetes ApiClient construction so SelfSubjectAccessReview authentication works across Kubernetes Python client versions v35 and v36, which use different Configuration.api_key scheme names for bearer tokens.
Changes:
- Set both legacy (
api_key["authorization"]) and v36+ (api_key["BearerToken"]) token entries on the temporaryConfiguration. - Set
api_key_prefixfor both keys to ensure theBearerprefix is applied consistently across client versions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Set both legacy ('authorization') and v36+ ('BearerToken') keys. | ||
| # kubernetes-client/python still has a compatibility gap across v35-v36 | ||
| # for manually constructed Configuration objects; see issues #2592 and PR #2618. | ||
| configuration.api_key = {"BearerToken": token, "authorization": token} | ||
| configuration.api_key_prefix = {"BearerToken": "Bearer", "authorization": "Bearer"} |
Signed-off-by: kramaranya <kramaranya15@gmail.com>
3d77f5a to
ee9240f
Compare
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mprahl The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
The test failures are due to needing to rebase. I'll merge it though since this is a small change. |
What this PR does / why we need it:
The Kubernetes Python client changed bearer token handling between v35 and v36.
api_key["authorization"]api_key["BearerToken"]Configuration()objects still miss theBearerprefix when only the legacy key is setThis change sets both keys and both prefixes when constructing the temporary client used for
SelfSubjectAccessReview, so requests authenticate correctly across supported client versions.Related Issues/PRs (use
Fixes #<number>to auto-close, orRelates to #<number>):How is this PR tested?
Does this PR require documentation update?
Checklist:
pre-commit run --all-files)make python-test)