-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[ARM] Third party S2S Consent/Permission Enumeration #18433
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 all commits
2d83615
e72447f
f4e4740
2136995
0c5b73b
aa2315c
ca6b89b
64c33aa
714c674
8932b64
f000087
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 |
|---|---|---|
|
|
@@ -33,7 +33,8 @@ | |
|
|
||
| from azure.cli.command_modules.resource._client_factory import ( | ||
| _resource_client_factory, _resource_policy_client_factory, _resource_lock_client_factory, | ||
| _resource_links_client_factory, _resource_deploymentscripts_client_factory, _authorization_management_client, _resource_managedapps_client_factory, _resource_templatespecs_client_factory) | ||
| _resource_links_client_factory, _resource_deploymentscripts_client_factory, _authorization_management_client, _resource_managedapps_client_factory, _resource_templatespecs_client_factory, | ||
| cf_providers) | ||
| from azure.cli.command_modules.resource._validators import _parse_lock_id | ||
|
|
||
| from azure.core.pipeline.policies import SansIOHTTPPolicy | ||
|
|
@@ -1019,31 +1020,31 @@ def _get_auth_provider_latest_api_version(cli_ctx): | |
| return api_version | ||
|
|
||
|
|
||
| def _update_provider(cli_ctx, namespace, registering, wait, mg_id=None, accept_terms=None): | ||
| def _update_provider(cli_ctx, namespace, registering, wait, properties=None, mg_id=None, accept_terms=None): | ||
| import time | ||
| target_state = 'Registered' if registering else 'Unregistered' | ||
| rcf = _resource_client_factory(cli_ctx) | ||
| client = cf_providers(cli_ctx, None, api_version='2021-04-01') | ||
| is_rpaas = namespace.lower() in RPAAS_APIS | ||
| if mg_id is None and registering: | ||
| if is_rpaas: | ||
| if not accept_terms: | ||
| raise RequiredArgumentMissingError("--accept-terms must be specified when registering the {} RP from RPaaS.".format(namespace)) | ||
| wait = True | ||
| r = rcf.providers.register(namespace) | ||
| r = client.register(namespace, properties=properties) | ||
| elif mg_id and registering: | ||
| r = rcf.providers.register_at_management_group_scope(namespace, mg_id) | ||
| r = client.register_at_management_group_scope(namespace, mg_id) | ||
| if r is None: | ||
| return | ||
| else: | ||
| r = rcf.providers.unregister(namespace) | ||
| r = client.unregister(namespace) | ||
|
|
||
| if r.registration_state == target_state: | ||
| return | ||
|
|
||
| if wait: | ||
| while True: | ||
| time.sleep(10) | ||
| rp_info = rcf.providers.get(namespace) | ||
| rp_info = client.get(namespace) | ||
| if rp_info.registration_state == target_state: | ||
| break | ||
| if is_rpaas and registering and mg_id is None: | ||
|
|
@@ -2036,8 +2037,12 @@ def list_resources(cmd, resource_group_name=None, | |
| return list(resources) | ||
|
|
||
|
|
||
| def register_provider(cmd, resource_provider_namespace, mg=None, wait=False, accept_terms=None): | ||
| _update_provider(cmd.cli_ctx, resource_provider_namespace, registering=True, wait=wait, mg_id=mg, accept_terms=accept_terms) | ||
| def register_provider(cmd, resource_provider_namespace, consent_to_permissions=False, mg=None, wait=False, accept_terms=None): | ||
| properties = None | ||
| if consent_to_permissions: | ||
| from azure.mgmt.resource.resources.v2021_04_01.models import ProviderRegistrationRequest, ProviderConsentDefinition | ||
|
Contributor
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. It is not recommended to directly import the model from package under the specific version. If you plan to bump api-version, then you can use |
||
| properties = ProviderRegistrationRequest(third_party_provider_consent=ProviderConsentDefinition(consent_to_authorization=consent_to_permissions)) | ||
| _update_provider(cmd.cli_ctx, resource_provider_namespace, registering=True, wait=wait, properties=properties, mg_id=mg, accept_terms=accept_terms) | ||
|
|
||
|
|
||
| def unregister_provider(cmd, resource_provider_namespace, wait=False): | ||
|
|
@@ -2049,6 +2054,11 @@ def list_provider_operations(cmd): | |
| return auth_client.provider_operations_metadata.list() | ||
|
|
||
|
|
||
| def list_provider_permissions(cmd, resource_provider_namespace): | ||
| client = cf_providers(cmd.cli_ctx, None, api_version='2021-04-01') | ||
|
Contributor
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. Same as above |
||
| return client.provider_permissions(resource_provider_namespace) | ||
|
|
||
|
|
||
| def show_provider_operations(cmd, resource_provider_namespace): | ||
| version = getattr(get_api_version(cmd.cli_ctx, ResourceType.MGMT_AUTHORIZATION), 'provider_operations_metadata') | ||
| auth_client = _authorization_management_client(cmd.cli_ctx) | ||
|
|
||
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.
May I ask why you do not upgrade the api-version for
ResourceType.MGMT_RESOURCE_RESOURCES, but specify a fixed version2021-04-01here?Actually, If the current api-version does not support new features, we will generally bump the api-version