-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #715 from skoruba/feature/533-add-support-for-azur…
…e-key-vault Add support for Azure Key Vault
- Loading branch information
Showing
17 changed files
with
331 additions
and
25 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
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
21 changes: 21 additions & 0 deletions
21
src/Skoruba.IdentityServer4.Shared/Configuration/Common/AzureKeyVaultConfiguration.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,21 @@ | ||
using System.Diagnostics; | ||
|
||
namespace Skoruba.IdentityServer4.Shared.Configuration.Common | ||
{ | ||
public class AzureKeyVaultConfiguration | ||
{ | ||
public string AzureKeyVaultEndpoint { get; set; } | ||
|
||
public string ClientId { get; set; } | ||
|
||
public string ClientSecret { get; set; } | ||
|
||
public bool UseClientCredentials { get; set; } | ||
|
||
public string IdentityServerCertificateName { get; set; } | ||
|
||
public string DataProtectionKeyIdentifier { get; set; } | ||
|
||
public bool ReadConfigurationFromKeyVault { get; set; } | ||
} | ||
} |
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
7 changes: 7 additions & 0 deletions
7
src/Skoruba.IdentityServer4.Shared/Configuration/Common/DataProtectionConfiguration.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,7 @@ | ||
namespace Skoruba.IdentityServer4.Shared.Configuration.Common | ||
{ | ||
public class DataProtectionConfiguration | ||
{ | ||
public bool ProtectKeysWithAzureKeyVault { get; set; } | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Skoruba.IdentityServer4.Shared/Helpers/AzureKeyVaultHelpers.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,27 @@ | ||
// Original file comes from: https://github.com/damienbod/IdentityServer4AspNetCoreIdentityTemplate | ||
// Modified by Jan Škoruba | ||
|
||
using System.Security.Cryptography.X509Certificates; | ||
using System.Threading.Tasks; | ||
using Skoruba.IdentityServer4.Shared.Configuration.Common; | ||
using Skoruba.IdentityServer4.Shared.Services; | ||
|
||
namespace Skoruba.IdentityServer4.Shared.Helpers | ||
{ | ||
public class AzureKeyVaultHelpers | ||
{ | ||
public static async Task<(X509Certificate2 ActiveCertificate, X509Certificate2 SecondaryCertificate)> GetCertificates(AzureKeyVaultConfiguration certificateConfiguration) | ||
{ | ||
(X509Certificate2 ActiveCertificate, X509Certificate2 SecondaryCertificate) certs = (null, null); | ||
|
||
if (!string.IsNullOrEmpty(certificateConfiguration.AzureKeyVaultEndpoint)) | ||
{ | ||
var keyVaultCertificateService = new AzureKeyVaultService(certificateConfiguration); | ||
|
||
certs = await keyVaultCertificateService.GetCertificatesFromKeyVault().ConfigureAwait(false); | ||
} | ||
|
||
return certs; | ||
} | ||
} | ||
} |
Oops, something went wrong.