-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update API for managed identity (#4107)
* Update API to specify managed identity in .Create() * Remove cache extensibility from managed identity * Fix integration tests * Address comments * Undo rename of res Id * Fix tests after merge from main * Update tests to disable shared cache * Address comments * Merge from main * Remove MIApplicationOptions and address comments * Rename ManagedIdentityConfiguration to ManagedIdentityId * Fix tests
- Loading branch information
1 parent
446a348
commit e7533b0
Showing
29 changed files
with
429 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
src/client/Microsoft.Identity.Client/AppConfig/ManagedIdentityApplicationOptions.cs
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
src/client/Microsoft.Identity.Client/AppConfig/ManagedIdentityId.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Identity.Client.AppConfig | ||
{ | ||
/// <summary> | ||
/// Class to store configuration for a managed identity enabled on a resource. | ||
/// For a system assigned managed identity use ManagedIdentityId.SystemAssigned. | ||
/// For user assigned managed identity use ManagedIdentityId.WithUserAssignedClientId("clientId") or | ||
/// ManagedIdentityId.WithUserAssignedResourceId("resourceId"). | ||
/// For more details see https://aka.ms/msal-net-managed-identity | ||
/// </summary> | ||
public class ManagedIdentityId | ||
{ | ||
internal string UserAssignedId { get; private set; } | ||
internal ManagedIdentityIdType IdType { get; private set; } | ||
internal readonly bool _isUserAssigned; | ||
|
||
private ManagedIdentityId(ManagedIdentityIdType idType) | ||
{ | ||
IdType = idType; | ||
|
||
switch (idType) | ||
{ | ||
case ManagedIdentityIdType.SystemAssigned: | ||
_isUserAssigned = false; | ||
break; | ||
case ManagedIdentityIdType.ClientId: | ||
case ManagedIdentityIdType.ResourceId: | ||
_isUserAssigned = true; | ||
break; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Create an instance of ManagedIdentityId for a system assigned managed identity. | ||
/// </summary> | ||
public static ManagedIdentityId SystemAssigned { get; } = | ||
new ManagedIdentityId(ManagedIdentityIdType.SystemAssigned); | ||
|
||
/// <summary> | ||
/// Create an instance of ManagedIdentityId for a user assigned managed identity from a client id. | ||
/// </summary> | ||
/// <param name="clientId">Client id of the user assigned managed identity assigned to azure resource.</param> | ||
/// <returns>Instance of ManagedIdentityId.</returns> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public static ManagedIdentityId WithUserAssignedClientId(string clientId) | ||
{ | ||
if (string.IsNullOrEmpty(clientId)) | ||
{ | ||
throw new ArgumentNullException(clientId); | ||
} | ||
|
||
return new ManagedIdentityId(ManagedIdentityIdType.ClientId) { UserAssignedId = clientId }; | ||
} | ||
|
||
/// <summary> | ||
/// Create an instance of ManagedIdentityId for a user assigned managed identity from a resource id. | ||
/// </summary> | ||
/// <param name="resourceId">Resource id of the user assigned managed identity assigned to azure resource.</param> | ||
/// <returns>Instance of ManagedIdentityId.</returns> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public static ManagedIdentityId WithUserAssignedResourceId(string resourceId) | ||
{ | ||
if (string.IsNullOrEmpty(resourceId)) | ||
{ | ||
throw new ArgumentNullException(resourceId); | ||
} | ||
|
||
return new ManagedIdentityId(ManagedIdentityIdType.ResourceId) { UserAssignedId = resourceId }; | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/client/Microsoft.Identity.Client/AppConfig/ManagedIdentityIdType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Identity.Client.AppConfig | ||
{ | ||
internal enum ManagedIdentityIdType | ||
{ | ||
SystemAssigned, | ||
ClientId, | ||
ResourceId | ||
} | ||
} |
Oops, something went wrong.