-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Fix #8840: Tenant domain name is not accepted by Key Vault #10418
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # -------------------------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for license information. | ||
| # -------------------------------------------------------------------------------------------- | ||
|
|
||
| import uuid | ||
|
|
||
| from azure.cli.core.util import should_disable_connection_verify | ||
| from knack.log import get_logger | ||
|
|
||
| logger = get_logger(__name__) | ||
|
|
||
|
|
||
| def _is_guid(guid): | ||
| try: | ||
| uuid.UUID(guid) | ||
| return True | ||
| except ValueError: | ||
| pass | ||
| return False | ||
|
|
||
|
|
||
| def validate_tenant(cmd, namespace): | ||
| """ | ||
| Make sure tenant is a GUID. If domain name is provided, resolve to GUID. | ||
| https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc#fetch-the-openid-connect-metadata-document | ||
| """ | ||
| if not _is_guid(namespace.tenant): | ||
| import requests | ||
| active_directory_endpoint = cmd.cli_ctx.cloud.endpoints.active_directory | ||
| url = '{}/{}/.well-known/openid-configuration'.format(active_directory_endpoint, namespace.tenant) | ||
|
Member
Author
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.
https://login.microsoftonline.com/azuresdkteam.onmicrosoft.com/.well-known/openid-configuration -> Official documentation on |
||
| metadata = requests.get(url, verify=not should_disable_connection_verify()).json() | ||
|
|
||
| # Example issuer: https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/ | ||
| tenant_id = metadata['issuer'].split("/")[3] | ||
|
|
||
| logger.warning('Resolve tenant domain name %s to GUID %s', namespace.tenant, tenant_id) | ||
| namespace.tenant = tenant_id | ||
Uh oh!
There was an error while loading. Please reload this page.
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.
nit: you can
return FalsehereUh oh!
There was an error while loading. Please reload this page.
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.
Good point! All
_is_guids are fixed.