refactor(RSATokenDescriptor): Standard-Id mit Issuer und Audience hinzugefügt.
- Issuer und Audience erforderlich gemacht.
This commit is contained in:
parent
66e3c771dd
commit
211064d44e
@ -47,6 +47,13 @@ namespace DigitalData.Core.Security.Config
|
|||||||
|
|
||||||
public CryptoFactoryParams()
|
public CryptoFactoryParams()
|
||||||
{
|
{
|
||||||
|
// set defaults
|
||||||
|
if (VaultDecryptor is not null)
|
||||||
|
VaultDecryptor.Id = "vault";
|
||||||
|
|
||||||
|
foreach (var descriptor in TokenDescriptors)
|
||||||
|
descriptor.IdSeparator = FileNameSeparator;
|
||||||
|
|
||||||
// init decryptors
|
// init decryptors
|
||||||
AfterCreate += () =>
|
AfterCreate += () =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,22 +1,16 @@
|
|||||||
using DigitalData.Core.Abstractions.Security;
|
using DigitalData.Core.Abstractions.Security;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace DigitalData.Core.Security.RSAKey
|
namespace DigitalData.Core.Security.RSAKey
|
||||||
{
|
{
|
||||||
public class RSAKeyBase : IAsymmetricKey
|
public class RSAKeyBase : IAsymmetricKey
|
||||||
{
|
{
|
||||||
|
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||||
public virtual string Content { get; init; }
|
public virtual string Content { get; init; }
|
||||||
|
|
||||||
protected virtual RSA RSA { get; } = RSA.Create();
|
public virtual string Id { get; internal set; }
|
||||||
|
|
||||||
public string Id { get; init; }
|
|
||||||
|
|
||||||
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
|
||||||
internal RSAKeyBase()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
|
||||||
|
|
||||||
|
protected virtual RSA RSA { get; } = RSA.Create();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8,13 +8,19 @@ namespace DigitalData.Core.Security.RSAKey
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class RSATokenDescriptor : RSAPrivateKey, IAsymmetricTokenDescriptor
|
public class RSATokenDescriptor : RSAPrivateKey, IAsymmetricTokenDescriptor
|
||||||
{
|
{
|
||||||
|
internal string IdSeparator { get; set; } = "_-_";
|
||||||
|
|
||||||
|
private string? _id;
|
||||||
|
|
||||||
|
public override string Id { get => _id ?? $"{Issuer}{IdSeparator}{Audience}"; internal set => _id = value; }
|
||||||
|
|
||||||
public string? ApiRoute { get; init; }
|
public string? ApiRoute { get; init; }
|
||||||
|
|
||||||
#region SecurityTokenDescriptor Map
|
#region SecurityTokenDescriptor Map
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the value of the 'audience' claim.
|
/// Gets or sets the value of the 'audience' claim.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Audience { get; set; }
|
public required string Audience { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the compression algorithm that will be used to compress the JWT token payload.
|
/// Defines the compression algorithm that will be used to compress the JWT token payload.
|
||||||
@ -34,7 +40,7 @@ namespace DigitalData.Core.Security.RSAKey
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the issuer of this <see cref="SecurityTokenDescriptor"/>.
|
/// Gets or sets the issuer of this <see cref="SecurityTokenDescriptor"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Issuer { get; set; }
|
public required string Issuer { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the time the security token was issued. This value should be in UTC.
|
/// Gets or sets the time the security token was issued. This value should be in UTC.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user