-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eeb9d7d
commit b4096af
Showing
8 changed files
with
196 additions
and
145 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
75 changes: 75 additions & 0 deletions
75
src/Microsoft.Identity.Web.Certificate/DefaultCredentialsLoader.CustomSignedAssertion.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,75 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Identity.Abstractions; | ||
|
||
|
||
namespace Microsoft.Identity.Web | ||
{ | ||
public partial class DefaultCredentialsLoader | ||
{ | ||
/// <summary> | ||
/// Constructor for DefaultCredentialsLoader when using custom signed assertion provider source loaders. | ||
/// </summary> | ||
/// <param name="logger"></param> | ||
/// <param name="customSignedAssertionProviders">Set of custom signed assertion providers.</param> | ||
public DefaultCredentialsLoader(ILogger<DefaultCredentialsLoader>? logger, IEnumerable<ICustomSignedAssertionProvider> customSignedAssertionProviders) : this(logger) | ||
{ | ||
var sourceLoaderDict = new Dictionary<string, ICredentialSourceLoader>(); | ||
|
||
foreach (var provider in customSignedAssertionProviders) | ||
{ | ||
sourceLoaderDict.Add(provider.Name ?? provider.GetType().FullName!, provider); | ||
} | ||
|
||
CustomSignedAssertionCredentialSourceLoaders = sourceLoaderDict; | ||
} | ||
|
||
/// <summary> | ||
/// Dictionary of custom signed assertion credential source loaders, by name (fully qualified type name). | ||
/// </summary> | ||
public IDictionary<string, ICredentialSourceLoader>? CustomSignedAssertionCredentialSourceLoaders { get; } | ||
|
||
|
||
private async Task ProcessCustomSignedAssertionAsync(CredentialDescription credentialDescription, CredentialSourceLoaderParameters? parameters) | ||
{ | ||
// No source loader(s) | ||
if (CustomSignedAssertionCredentialSourceLoaders == null || !CustomSignedAssertionCredentialSourceLoaders.Any()) | ||
{ | ||
_logger.LogError(CertificateErrorMessage.CustomProviderSourceLoaderNullOrEmpty); | ||
} | ||
|
||
// No provider name | ||
else if (string.IsNullOrEmpty(credentialDescription.CustomSignedAssertionProviderName)) | ||
{ | ||
_logger.LogError(CertificateErrorMessage.CustomProviderNameNullOrEmpty); | ||
} | ||
|
||
// No source loader for provider name | ||
else if (!CustomSignedAssertionCredentialSourceLoaders!.TryGetValue(credentialDescription.CustomSignedAssertionProviderName!, out ICredentialSourceLoader? sourceLoader)) | ||
{ | ||
_logger.LogError(CertificateErrorMessage.CustomProviderNotFound, credentialDescription.CustomSignedAssertionProviderName); | ||
} | ||
|
||
// Load the credentials, if there is an error, it is coming from the user's custom extension and should be logged and propagated. | ||
else | ||
{ | ||
try | ||
{ | ||
await sourceLoader.LoadIfNeededAsync(credentialDescription, parameters); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Logger.CustomSignedAssertionProviderLoadingFailure(_logger, credentialDescription, ex); | ||
throw; | ||
} | ||
return; | ||
} | ||
} | ||
} | ||
} |
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
110 changes: 0 additions & 110 deletions
110
src/Microsoft.Identity.Web.Certificate/DefaultCredentialsLoaderCustomSignedAssertion.cs
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/Microsoft.Identity.Web.Certificate/InternalAPI.Unshipped.txt
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
Oops, something went wrong.