Skip to content

Commit 527d9cc

Browse files
committed
[Managed_Service_Identity] Added support for FlexibleFIC
1 parent 478da82 commit 527d9cc

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
- name: Create a federated identity credential under a specific user assigned identity.
4949
text: |
5050
az identity federated-credential create --name myFicName --identity-name myIdentityName --resource-group myResourceGroup --issuer myIssuer --subject mySubject --audiences myAudiences
51+
- name: Create a federated identity credential with claims matching expression
52+
text: |
53+
az identity federated-credential create --name myFicName --identity-name myIdentityName --resource-group myResourceGroup --issuer https://tokens.githubusercontent.com --audiences api://AzureADTokenExchange --claims-matching-expression-value "claims['sub'] startswith 'repo:contoso-org/contoso-repo:ref:refs/heads'" --claims-matching-expression-version 1
5154
"""
5255

5356
helps['identity federated-credential update'] = """
@@ -57,6 +60,9 @@
5760
- name: Update a federated identity credential under a specific user assigned identity.
5861
text: |
5962
az identity federated-credential update --name myFicName --identity-name myIdentityName --resource-group myResourceGroup --issuer myIssuer --subject mySubject --audiences myAudiences
63+
- name: Update a federated identity credential with claims matching expression
64+
text: |
65+
az identity federated-credential update --name myFicName --identity-name myIdentityName --resource-group myResourceGroup --issuer https://tokens.githubusercontent.com --audiences api://AzureADTokenExchange --claims-matching-expression-value "claims['sub'] startswith 'repo:contoso-org/contoso-repo:ref:refs/heads'" --claims-matching-expression-version 1
6066
"""
6167

6268
helps['identity federated-credential delete'] = """

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def load_arguments(self, _):
2222
c.argument('location', get_location_type(self.cli_ctx), required=False)
2323
c.argument('tags', tags_type)
2424

25-
with self.argument_context('identity federated-credential', min_api='2022-01-31-preview') as c:
25+
with self.argument_context('identity federated-credential', min_api='2025-01-31-PREVIEW') as c:
2626
c.argument('federated_credential_name', options_list=('--name', '-n'), help='The name of the federated identity credential resource.')
2727
c.argument('identity_name', help='The name of the identity resource.')
2828

@@ -31,3 +31,5 @@ def load_arguments(self, _):
3131
c.argument('issuer', help='The openId connect metadata URL of the issuer of the identity provider that Azure AD would use in the token exchange protocol for validating tokens before issuing a token as the user-assigned managed identity.')
3232
c.argument('subject', help='The sub value in the token sent to Azure AD for getting the user-assigned managed identity token. The value configured in the federated credential and the one in the incoming token must exactly match for Azure AD to issue the access token.')
3333
c.argument('audiences', nargs='+', help='The aud value in the token sent to Azure for getting the user-assigned managed identity token. The value configured in the federated credential and the one in the incoming token must exactly match for Azure to issue the access token.')
34+
c.argument('claims_matching_expression_value', options_list=['--claims-matching-expression-value'], help='The claims expression value that will be evaluated by Azure AD to issue a token. For example, claims[\'sub\'] startswith \'repo:contoso-org/contoso-repo:ref:refs/heads\'.')
35+
c.argument('claims_matching_expression_version', options_list=['--claims-matching-expression-version'], help='The version of claims expression language. For example, 1.')

src/azure-cli/azure/cli/command_modules/identity/commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def load_command_table(self, _):
3939

4040
with self.command_group('identity federated-credential', federated_identity_credentials_sdk,
4141
client_factory=_msi_federated_identity_credentials_operations,
42-
min_api='2022-01-31-preview') as g:
42+
min_api='2025-01-31-PREVIEW') as g:
4343
g.custom_command('create', 'create_or_update_federated_credential')
4444
g.custom_command('update', 'create_or_update_federated_credential')
4545
g.custom_show_command('show', 'show_federated_credential')

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,22 @@ def list_identity_resources(cmd, resource_group_name, resource_name):
3535

3636

3737
def create_or_update_federated_credential(cmd, client, resource_group_name, identity_name, federated_credential_name,
38-
issuer=None, subject=None, audiences=None):
38+
issuer=None, subject=None, audiences=None, claims_matching_expression_value=None,
39+
claims_matching_expression_version=None):
3940
_default_audiences = ['api://AzureADTokenExchange']
4041
audiences = _default_audiences if not audiences else audiences
4142
if not issuer or not subject:
4243
raise RequiredArgumentMissingError('usage error: please provide both --issuer and --subject parameters')
4344

4445
FederatedIdentityCredential = cmd.get_models('FederatedIdentityCredential', resource_type=ResourceType.MGMT_MSI,
4546
operation_group='federated_identity_credentials')
46-
parameters = FederatedIdentityCredential(issuer=issuer, subject=subject, audiences=audiences)
47+
parameters = FederatedIdentityCredential(
48+
issuer=issuer,
49+
subject=subject,
50+
audiences=audiences,
51+
claims_matching_expression_value=claims_matching_expression_value,
52+
claims_matching_expression_version=claims_matching_expression_version
53+
)
4754

4855
return client.create_or_update(resource_group_name=resource_group_name, resource_name=identity_name,
4956
federated_identity_credential_resource_name=federated_credential_name,

0 commit comments

Comments
 (0)