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

Refactor ImdsCredential to use ManagedIdentityClient #18120

Merged
merged 5 commits into from
Apr 23, 2021

Conversation

chlowell
Copy link
Member

Looks like a lot of new code because I moved ImdsCredential to a new module but it's actually a modest refactor (that enables throwing out some old code and, I hope, making this all a little easier to understand 🥳)

Closes #13674

Comment on lines -196 to -202
if len(scopes) != 1:
raise ValueError("This credential requires exactly one scope per token request.")

resource = scopes[0]
if resource.endswith("/.default"):
resource = resource[: -len("/.default")]
params = dict({"api-version": "2018-02-01", "resource": resource}, **self._identity_config)
Copy link
Member

Choose a reason for hiding this comment

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

Is this scopes restriction still being applied after the refactor?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, ManagedIdentityClient.request_token calls _scopes_to_resource, which is a copy of this.

@chlowell chlowell merged commit 896380d into Azure:master Apr 23, 2021
@chlowell chlowell deleted the imds-refactor branch April 23, 2021 18:27
iscai-msft added a commit to iscai-msft/azure-sdk-for-python that referenced this pull request Apr 23, 2021
…into azure_purview_catalog

* 'master' of https://github.com/Azure/azure-sdk-for-python:
  [Tables] hot fix for pipelines (Azure#18273)
  [Tables] Updates for apiview & sphinx docs (Azure#18134)
  override purview deps in shared reqs (Azure#18270)
  [Service Bus] fix deadletter sample + update README (Azure#18261)
  Update credential docstrings (Azure#18205)
  Refactor ImdsCredential to use ManagedIdentityClient (Azure#18120)
  [Key Vault] Target multiple API versions with tests (keys) (Azure#18149)
  Initial ModelsRepositoryClient (Azure#17180)
  [Communication]: Enabled Phone Number Search Test (Azure#18247)
  [Key Vault] Update default MHSM location for tests
  Update identity migration guide (Azure#18239)
  [AutoRelease] t2-managedservices-2021-04-22-08436(wave4) (Azure#18224)
  [AutoRelease] t2-hybridnetwork-2021-04-20-93742 (Azure#18169)
  Add Key Vault cert suppression (Azure#18245)
  update to aab1fb9 (Azure#18246)
  Enable retain runs. (Azure#18200)
  [formrecognizer] add testcases for labeled tables - fixed/variable rows (Azure#18214)
  Add caching support to verify-links (Azure#18231)
  add reading order for logging (Azure#18233)
  [purview] allow purview pylint failures (Azure#18237)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor ImdsCredential
2 participants