Skip to content

Commit 60c6ef9

Browse files
authored
[BREAKING CHANGE] az role assignment list: Drop --include-classic-administrators argument (#29470)
1 parent cd00c8a commit 60c6ef9

File tree

7 files changed

+4
-102
lines changed

7 files changed

+4
-102
lines changed

linter_exclusions.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3113,11 +3113,6 @@ role assignment create:
31133113
assignee_principal_type:
31143114
rule_exclusions:
31153115
- option_length_too_long
3116-
role assignment list:
3117-
parameters:
3118-
include_classic_administrators:
3119-
rule_exclusions:
3120-
- option_length_too_long
31213116
security adaptive_network_hardenings show:
31223117
parameters:
31233118
adaptive_network_hardenings_resource_name:
@@ -4012,4 +4007,4 @@ webapp update:
40124007
- option_length_too_long
40134008
skip_dns_registration:
40144009
rule_exclusions:
4015-
- option_length_too_long
4010+
- option_length_too_long

src/azure-cli-core/azure/cli/core/profiles/_shared.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ def default_api_version(self):
191191
'managed_hsms': '2024-11-01'
192192
}),
193193
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2022-04-01', {
194-
'classic_administrators': '2015-06-01',
195194
'role_definitions': '2022-05-01-preview',
196195
'provider_operations_metadata': '2018-01-01-preview'
197196
}),
@@ -292,7 +291,6 @@ def default_api_version(self):
292291
ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01',
293292
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
294293
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
295-
'classic_administrators': '2015-06-01',
296294
'policy_assignments': '2016-12-01',
297295
'policy_definitions': '2016-12-01'
298296
}),
@@ -338,7 +336,6 @@ def default_api_version(self):
338336
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
339337
ResourceType.MGMT_KEYVAULT: '2016-10-01',
340338
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
341-
'classic_administrators': '2015-06-01',
342339
'policy_assignments': '2016-12-01',
343340
'policy_definitions': '2016-12-01'
344341
}),
@@ -377,9 +374,7 @@ def default_api_version(self):
377374
ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01',
378375
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
379376
ResourceType.MGMT_KEYVAULT: '2016-10-01',
380-
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
381-
'classic_administrators': '2015-06-01'
382-
}),
377+
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01'),
383378
# The order does make things different.
384379
# Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT
385380
ResourceType.DATA_KEYVAULT_CERTIFICATES: None,
@@ -407,9 +402,7 @@ def default_api_version(self):
407402
ResourceType.MGMT_RESOURCE_MANAGEDAPPLICATIONS: '2019-07-01',
408403
ResourceType.MGMT_NETWORK_DNS: '2016-04-01',
409404
ResourceType.MGMT_KEYVAULT: '2016-10-01',
410-
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01', {
411-
'classic_administrators': '2015-06-01'
412-
}),
405+
ResourceType.MGMT_AUTHORIZATION: SDKProfile('2015-07-01'),
413406
# The order does make things different.
414407
# Please keep ResourceType.DATA_KEYVAULT_KEYS before ResourceType.DATA_KEYVAULT
415408
ResourceType.DATA_KEYVAULT_CERTIFICATES: None,

src/azure-cli/azure/cli/command_modules/role/_breaking_change.py

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/azure-cli/azure/cli/command_modules/role/_help.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,6 @@
795795
long-summary: >-
796796
By default, only assignments scoped to subscription will be displayed.
797797
To view assignments scoped by resource or group, use `--all`.
798-
799-
800-
[WARNING] Azure classic subscription administrators will be retired on August 31, 2024.
801-
After August 31, 2024, all classic administrators risk losing access to the subscription.
802-
Delete classic administrators who no longer need access or assign an Azure RBAC role for fine-grained access
803-
control. Learn more: https://go.microsoft.com/fwlink/?linkid=2238474
804798
examples:
805799
- name: List role assignments at the subscription scope.
806800
text: az role assignment list --scope /subscriptions/00000000-0000-0000-0000-000000000000

src/azure-cli/azure/cli/command_modules/role/_params.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ def load_arguments(self, _):
340340
"the logged-in account has no permission or the machine has no network access to query "
341341
"Microsoft Graph.")
342342
c.argument('ids', nargs='+', help='space-separated role assignment ids')
343-
c.argument('include_classic_administrators', arg_type=get_three_state_flag(),
344-
help='list default role assignments for subscription classic administrators, aka co-admins')
345343
c.argument('description', is_preview=True, min_api='2020-04-01-preview', help='Description of role assignment.')
346344
c.argument('condition', is_preview=True, min_api='2020-04-01-preview', help='Condition under which the user can be granted permission.')
347345
c.argument('condition_version', is_preview=True, min_api='2020-04-01-preview', help='Version of the condition syntax. If --condition is specified without --condition-version, default to 2.0.')

src/azure-cli/azure/cli/command_modules/role/custom.py

Lines changed: 1 addition & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@
5252
"The output includes credentials that you must protect. Be sure that you do not include these credentials in "
5353
"your code or check the credentials into your source control. For more information, see https://aka.ms/azadsp-cli")
5454

55-
CLASSIC_ADMINISTRATOR_WARNING = (
56-
"Azure classic subscription administrators will be retired on August 31, 2024. "
57-
"After August 31, 2024, all classic administrators risk losing access to the subscription. "
58-
"Delete classic administrators who no longer need access or assign an Azure RBAC role for fine-grained access "
59-
"control. Learn more: https://go.microsoft.com/fwlink/?linkid=2238474")
60-
6155
logger = get_logger(__name__)
6256

6357
# pylint: disable=too-many-lines, protected-access
@@ -237,16 +231,10 @@ def list_role_assignments(cmd, # pylint: disable=too-many-locals, too-many-bran
237231
role=None,
238232
resource_group_name=None, scope=None,
239233
include_inherited=False,
240-
show_all=False, include_groups=False, include_classic_administrators=False,
234+
show_all=False, include_groups=False,
241235
fill_role_definition_name=True, fill_principal_name=True):
242236
if assignee and assignee_object_id:
243237
raise CLIError('Usage error: Provide only one of --assignee or --assignee-object-id.')
244-
if assignee_object_id and include_classic_administrators:
245-
raise CLIError('Usage error: --assignee-object-id cannot be used with --include-classic-administrators. '
246-
'Use --assignee instead.')
247-
248-
if include_classic_administrators:
249-
logger.warning(CLASSIC_ADMINISTRATOR_WARNING)
250238

251239
graph_client = _graph_client_factory(cmd.cli_ctx)
252240
authorization_client = _auth_client_factory(cmd.cli_ctx, scope)
@@ -268,8 +256,6 @@ def list_role_assignments(cmd, # pylint: disable=too-many-locals, too-many-bran
268256
include_inherited, include_groups)
269257

270258
results = todict(assignments) if assignments else []
271-
if include_classic_administrators:
272-
results += _backfill_assignments_for_co_admins(cmd.cli_ctx, authorization_client, assignee)
273259

274260
if not results:
275261
return []
@@ -471,53 +457,6 @@ def list_role_assignment_change_logs(cmd, start_time=None, end_time=None): # py
471457
return result
472458

473459

474-
def _backfill_assignments_for_co_admins(cli_ctx, auth_client, assignee=None):
475-
worker = MultiAPIAdaptor(cli_ctx)
476-
co_admins = auth_client.classic_administrators.list() # known swagger bug on api-version handling
477-
co_admins = [x for x in co_admins if x.email_address]
478-
graph_client = _graph_client_factory(cli_ctx)
479-
if assignee: # apply assignee filter if applicable
480-
if is_guid(assignee):
481-
try:
482-
result = _get_object_stubs(graph_client, [assignee])
483-
if not result:
484-
return []
485-
assignee = _get_displayable_name(result[0]).lower()
486-
except ValueError:
487-
pass
488-
co_admins = [x for x in co_admins if assignee == x.email_address.lower()]
489-
490-
if not co_admins:
491-
return []
492-
493-
result, users = [], []
494-
for i in range(0, len(co_admins), 10): # graph allows up to 10 query filters, so split into chunks here
495-
upn_queries = ["userPrincipalName eq '{}'".format(x.email_address)
496-
for x in co_admins[i:i + 10]]
497-
temp = list(list_users(graph_client, query_filter=' or '.join(upn_queries)))
498-
users += temp
499-
upns = {u['userPrincipalName']: u[ID] for u in users}
500-
for admin in co_admins:
501-
na_text = 'NA(classic admins)'
502-
email = admin.email_address
503-
result.append({
504-
'id': na_text,
505-
'name': na_text,
506-
})
507-
properties = {
508-
'principalId': upns.get(email),
509-
'principalName': email,
510-
'roleDefinitionName': admin.role,
511-
'roleDefinitionId': 'NA(classic admin role)',
512-
'scope': '/subscriptions/' + auth_client._config.subscription_id
513-
}
514-
if worker.old_api:
515-
result[-1]['properties'] = properties
516-
else:
517-
result[-1].update(properties)
518-
return result
519-
520-
521460
def _get_displayable_name(graph_object):
522461
# user
523462
if 'userPrincipalName' in graph_object:

src/azure-cli/azure/cli/command_modules/role/tests/latest/test_role.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -820,15 +820,6 @@ def test_role_assignment_list(self, resource_group):
820820
# There are role assignments inherited from subscription, so we can't tell the exact number.
821821
self.cmd('role assignment list -g {rg} --include-inherited', checks=[self.greater_than("length([])", 0)])
822822

823-
@ResourceGroupPreparer(name_prefix='cli_test_assignments_for_coadmins')
824-
def test_role_assignment_for_co_admins(self, resource_group):
825-
826-
result = self.cmd('role assignment list --include-classic-administrator').get_output_in_json()
827-
self.assertTrue([x for x in result if x['roleDefinitionName'] in ['CoAdministrator', 'AccountAdministrator']])
828-
829-
result = self.cmd('role assignment list -g {rg} --include-classic-administrator').get_output_in_json()
830-
self.assertTrue([x for x in result if x['roleDefinitionName'] in ['CoAdministrator', 'AccountAdministrator']])
831-
832823

833824
if __name__ == '__main__':
834825
unittest.main()

0 commit comments

Comments
 (0)