Skip to content
This repository has been archived by the owner on Mar 13, 2022. It is now read-only.

Fix azure refresh token apiserver id #170

Conversation

fooka03
Copy link
Contributor

@fooka03 fooka03 commented Oct 8, 2019

Fixes #135

Currently, the refresh token logic is hardcoded to use the general Microsoft Graph application id as the apiserver. This fails if there's a mismatch in the kubeconfig, specifically in the audience in the access token being refreshed. Instead, the new code will dynamically load this from the local kubeconfig as with the other request values and use that to submit the refresh call.

Additionally, this sets the ADAL API version to 1.0 to keep the behavior consistent with the kubernetes go client azure authentication flow. (Namely, the string spi: being included for the audience)

I also updated the tests to use the Microsoft Graph app id as that was the prior behavior the tests were relying on.

@k8s-ci-robot
Copy link
Contributor

Welcome @fooka03!

It looks like this is your first PR to kubernetes-client/python-base 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-client/python-base has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 8, 2019
@fooka03
Copy link
Contributor Author

fooka03 commented Oct 8, 2019

/assign @yliaog

)
refresh_token = config['refresh-token']
client_id = config['client-id']
apiserver_id = config['apiserver-id']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would break the kubeconfig that does not have the field 'apiserver-id'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The azure provider requires apiserver-id unless I'm missing something in the workflow. First thing I tried was removing apiserver-id from my kubeconfig to try and rely on the hardcoded ID. I got an error about apiserver-id being a required field when trying to run commands.

@fooka03 fooka03 force-pushed the bugfix/135_azure_refresh_token branch from 9da0652 to 78a0030 Compare October 9, 2019 15:30
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 9, 2019
@fooka03 fooka03 force-pushed the bugfix/135_azure_refresh_token branch from 78a0030 to 0b20833 Compare October 9, 2019 15:37
@codecov-io
Copy link

Codecov Report

Merging #170 into master will decrease coverage by 0.02%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #170      +/-   ##
==========================================
- Coverage   93.44%   93.41%   -0.03%     
==========================================
  Files          13       13              
  Lines        1389     1398       +9     
==========================================
+ Hits         1298     1306       +8     
- Misses         91       92       +1
Impacted Files Coverage Δ
config/kube_config.py 87.53% <0%> (-0.23%) ⬇️
config/kube_config_test.py 95.28% <100%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update afd1301...0b20833. Read the comment docs.

@yliaog
Copy link
Contributor

yliaog commented Oct 9, 2019

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 9, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fooka03, yliaog

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 9, 2019
@k8s-ci-robot k8s-ci-robot merged commit 6b65461 into kubernetes-client:master Oct 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure Refresh Token Unauthorised Error
4 participants