Skip to content

Commit c2bba6a

Browse files
committed
Add customSignedAssertion
1 parent 38dbb1d commit c2bba6a

File tree

8 files changed

+82
-3
lines changed

8 files changed

+82
-3
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
33
<!-- This should be passed from the VSTS build -->
4-
<MicrosoftIdentityAbstractionsVersion Condition="'$(MicrosoftIdentityAbstractionsVersion)' == ''">7.1.1</MicrosoftIdentityAbstractionsVersion>
4+
<MicrosoftIdentityAbstractionsVersion Condition="'$(MicrosoftIdentityAbstractionsVersion)' == ''">7.2.0</MicrosoftIdentityAbstractionsVersion>
55
<!-- This will generate AssemblyVersion, AssemblyFileVersion and AssemblyInformationVersion -->
66
<Version>$(MicrosoftIdentityAbstractionsVersion)</Version>
77
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)\build\35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>

src/Microsoft.Identity.Abstractions/ApplicationOptions/CredentialDescription.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4+
using System.Collections.Generic;
5+
using System.ComponentModel;
46
using System.Security.Cryptography.X509Certificates;
57

68
namespace Microsoft.Identity.Abstractions
@@ -67,6 +69,7 @@ public string? Container
6769
CredentialSource.StoreWithThumbprint or CredentialSource.StoreWithDistinguishedName => CertificateStorePath,
6870
CredentialSource.SignedAssertionFilePath => SignedAssertionFileDiskPath,
6971
CredentialSource.SignedAssertionFromVault => KeyVaultUrl,
72+
CredentialSource.CustomSignedAssertion => null,
7073
_ => null
7174
};
7275
}
@@ -96,6 +99,8 @@ public string? Container
9699
case CredentialSource.SignedAssertionFilePath:
97100
SignedAssertionFileDiskPath = value;
98101
break;
102+
case CredentialSource.CustomSignedAssertion:
103+
break;
99104
default:
100105
break;
101106
}
@@ -348,6 +353,7 @@ public string? ReferenceOrValue
348353
CredentialSource.Certificate or CredentialSource.Base64Encoded => Base64EncodedValue,
349354
CredentialSource.SignedAssertionFromManagedIdentity => ManagedIdentityClientId,
350355
CredentialSource.ClientSecret => ClientSecret,
356+
CredentialSource.CustomSignedAssertion => null,
351357
_ => null,
352358
};
353359
}
@@ -381,6 +387,8 @@ public string? ReferenceOrValue
381387
case CredentialSource.SignedAssertionFromManagedIdentity:
382388
ManagedIdentityClientId = value;
383389
break;
390+
case CredentialSource.CustomSignedAssertion:
391+
break;
384392
default:
385393
break;
386394
}
@@ -452,7 +460,8 @@ or CredentialSource.Certificate
452460

453461
CredentialSource.SignedAssertionFromManagedIdentity
454462
or CredentialSource.SignedAssertionFilePath
455-
or CredentialSource.SignedAssertionFromVault => CredentialType.SignedAssertion,
463+
or CredentialSource.SignedAssertionFromVault
464+
or CredentialSource.CustomSignedAssertion => CredentialType.SignedAssertion,
456465

457466
CredentialSource.AutoDecryptKeys => CredentialType.DecryptKeys,
458467

@@ -478,5 +487,19 @@ or CredentialSource.SignedAssertionFilePath
478487
/// </example>
479488
/// <remarks>If you want to use the default token exchange resource "api://AzureADTokenExchange", don't provide a token exchange url.</remarks>
480489
public string? TokenExchangeUrl { get; set; }
490+
491+
/// <summary>
492+
/// Extensibility. When used with <see cref="SourceType"/> = <see cref="CredentialSource.CustomSignedAssertion"/>, this property specifies the fully qualified
493+
/// named of the extension that will be used to retrieve the signed assertion used as a client credentials.
494+
/// </summary>
495+
public string? CustomSignedAssertionProviderName { get; set; }
496+
497+
/// <summary>
498+
/// Extensibility. When used with <see cref="SourceType"/> = <see cref="CredentialSource.CustomSignedAssertion"/>, this property specifies
499+
/// additional data that will be passed to the extension computing the signed assertion. This is meant for SDKs extending the credential
500+
/// description capabilities.
501+
/// </summary>
502+
[EditorBrowsable(EditorBrowsableState.Never)]
503+
public Dictionary<string, object>? CustomSignedAssertionProviderData { get; set; }
481504
}
482505
}

src/Microsoft.Identity.Abstractions/ApplicationOptions/CredentialSource.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ public enum CredentialSource
175175
/// :::code language="csharp" source="~/../abstractions-samples/test/Microsoft.Identity.Abstractions.Tests/CredentialDescriptionTest.cs" id="autodecryp_csharp":::
176176
/// ]]></format>
177177
/// </example>
178-
AutoDecryptKeys = 10
178+
AutoDecryptKeys = 10,
179+
180+
/// <summary>
181+
/// Use this value in order to utilize a credential provider that is not part of the Microsoft.Identity.Abstractions library.
182+
/// This is an extension point, which goes along with <see cref = "CredentialDescription.CustomSignedAssertionProviderName" />
183+
/// </summary>
184+
CustomSignedAssertion = 11
179185
}
180186
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
#nullable enable
2+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderData.get -> System.Collections.Generic.Dictionary<string!, object!>?
3+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderData.set -> void
4+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderName.get -> string?
5+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderName.set -> void
6+
Microsoft.Identity.Abstractions.CredentialSource.CustomSignedAssertion = 11 -> Microsoft.Identity.Abstractions.CredentialSource
27
Microsoft.Identity.Abstractions.MicrosoftIdentityApplicationOptions.AppHomeTenantId.get -> string?
38
Microsoft.Identity.Abstractions.MicrosoftIdentityApplicationOptions.AppHomeTenantId.set -> void
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
#nullable enable
2+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderData.get -> System.Collections.Generic.Dictionary<string!, object!>?
3+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderData.set -> void
4+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderName.get -> string?
5+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderName.set -> void
6+
Microsoft.Identity.Abstractions.CredentialSource.CustomSignedAssertion = 11 -> Microsoft.Identity.Abstractions.CredentialSource
27
Microsoft.Identity.Abstractions.MicrosoftIdentityApplicationOptions.AppHomeTenantId.get -> string?
38
Microsoft.Identity.Abstractions.MicrosoftIdentityApplicationOptions.AppHomeTenantId.set -> void
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
#nullable enable
2+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderData.get -> System.Collections.Generic.Dictionary<string!, object!>?
3+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderData.set -> void
4+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderName.get -> string?
5+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderName.set -> void
6+
Microsoft.Identity.Abstractions.CredentialSource.CustomSignedAssertion = 11 -> Microsoft.Identity.Abstractions.CredentialSource
27
Microsoft.Identity.Abstractions.MicrosoftIdentityApplicationOptions.AppHomeTenantId.get -> string?
38
Microsoft.Identity.Abstractions.MicrosoftIdentityApplicationOptions.AppHomeTenantId.set -> void
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
#nullable enable
2+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderData.get -> System.Collections.Generic.Dictionary<string!, object!>?
3+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderData.set -> void
4+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderName.get -> string?
5+
Microsoft.Identity.Abstractions.CredentialDescription.CustomSignedAssertionProviderName.set -> void
6+
Microsoft.Identity.Abstractions.CredentialSource.CustomSignedAssertion = 11 -> Microsoft.Identity.Abstractions.CredentialSource
27
Microsoft.Identity.Abstractions.MicrosoftIdentityApplicationOptions.AppHomeTenantId.get -> string?
38
Microsoft.Identity.Abstractions.MicrosoftIdentityApplicationOptions.AppHomeTenantId.set -> void

test/Microsoft.Identity.Abstractions.Tests/CredentialDescriptionTest.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using Xunit;
5+
using System.Collections.Generic;
56

67
namespace Microsoft.Identity.Abstractions.ApplicationOptions.Tests
78
{
@@ -342,6 +343,24 @@ public void AutomaticDecryptKeys()
342343
Assert.Null(credentialDescription.Container);
343344
}
344345

346+
[Fact]
347+
public void CustomSignedAssertion()
348+
{
349+
// Signed assertion from a custom provider
350+
// -------------------------------------------
351+
CredentialDescription credentialDescription = new CredentialDescription
352+
{
353+
SourceType = CredentialSource.CustomSignedAssertion,
354+
CustomSignedAssertionProviderName = "MyCustomProvider",
355+
CustomSignedAssertionProviderData = new Dictionary<string, object>(){ { "MyCustomProviderData_Key", "MyCustomProviderData_Data" } }
356+
357+
};
358+
359+
Assert.Equal(CredentialType.SignedAssertion, credentialDescription.CredentialType);
360+
Assert.Null(credentialDescription.Container);
361+
Assert.Null(credentialDescription.ReferenceOrValue);
362+
}
363+
345364
[Fact]
346365
public void TokenExchangeUrl()
347366
{
@@ -415,6 +434,17 @@ public void TestContainerAndValueOrReferenceForCertificate()
415434
Assert.Null(credentialDescription.ReferenceOrValue);
416435
}
417436

437+
// This is still in the process of being implemented so for now it will return null. This test will need to change once it is fully implemented.
438+
[Fact]
439+
public void TestContainerAndValueOrReferenceForCustomSignedAssertion()
440+
{
441+
CredentialDescription credentialDescription = new CredentialDescription { SourceType = CredentialSource.CustomSignedAssertion };
442+
credentialDescription.Container = "container";
443+
Assert.Null(credentialDescription.Container);
444+
credentialDescription.ReferenceOrValue = "referenceOrValue";
445+
Assert.Null(credentialDescription.ReferenceOrValue);
446+
}
447+
418448
// Container only
419449
[Theory]
420450
[InlineData(CredentialSource.SignedAssertionFilePath)]

0 commit comments

Comments
 (0)