From ce716d2bab34ba186850858fecc34f148e9d5e06 Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Fri, 20 Dec 2024 00:08:31 +0100 Subject: [PATCH] =?UTF-8?q?feat(TokenDescription):=20Erstellt=20als=20eing?= =?UTF-8?q?eschr=C3=A4nkte=20Version=20von=20SecurityTokenDescriptor=20als?= =?UTF-8?q?=20Wurzelbeschreibungen=20ohne=20Anspr=C3=BCche?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/AsymCryptParams.cs | 2 + .../Config/TokenDescription.cs | 73 +++++++++++++++++++ .../DigitalData.Core.Security.csproj | 1 + 3 files changed, 76 insertions(+) create mode 100644 DigitalData.Core.Security/Config/TokenDescription.cs diff --git a/DigitalData.Core.Security/Config/AsymCryptParams.cs b/DigitalData.Core.Security/Config/AsymCryptParams.cs index 7547f50..598ee96 100644 --- a/DigitalData.Core.Security/Config/AsymCryptParams.cs +++ b/DigitalData.Core.Security/Config/AsymCryptParams.cs @@ -55,6 +55,8 @@ namespace DigitalData.Core.Security.Config public IEnumerable Decryptors { get; init; } = new List(); + public IEnumerable TokenDescriptions { get; init; } = new List(); + public RSADecryptor? Vault { get; init; } public AsymCryptParams() => AfterCreate += () => diff --git a/DigitalData.Core.Security/Config/TokenDescription.cs b/DigitalData.Core.Security/Config/TokenDescription.cs new file mode 100644 index 0000000..a039eba --- /dev/null +++ b/DigitalData.Core.Security/Config/TokenDescription.cs @@ -0,0 +1,73 @@ +using Microsoft.IdentityModel.Tokens; + +namespace DigitalData.Core.Security.Config +{ + /// + /// Contains some information which used to create a security token. Designed to abstract + /// + public class TokenDescription + { + /// + /// Gets or sets the value of the 'audience' claim. + /// + public string Audience { get; set; } + + /// + /// Defines the compression algorithm that will be used to compress the JWT token payload. + /// + public string CompressionAlgorithm { get; set; } + + /// + /// Gets or sets the used to create a encrypted security token. + /// + public EncryptingCredentials EncryptingCredentials { get; set; } + + /// + /// Gets or sets the value of the 'expiration' claim. This value should be in UTC. + /// + public DateTime? Expires { get; set; } + + /// + /// Gets or sets the issuer of this . + /// + public string Issuer { get; set; } + + /// + /// Gets or sets the time the security token was issued. This value should be in UTC. + /// + public DateTime? IssuedAt { get; set; } + + /// + /// Gets or sets the notbefore time for the security token. This value should be in UTC. + /// + public DateTime? NotBefore { get; set; } + + /// + /// Gets or sets the token type. + /// If provided, this will be added as the value for the 'typ' header parameter. In the case of a JWE, this will be added to both the inner (JWS) and the outer token (JWE) header. By default, the value used is 'JWT'. + /// If also contains 'typ' header claim value, it will override the TokenType provided here. + /// This value is used only for JWT tokens and not for SAML/SAML2 tokens + /// + public string TokenType { get; set; } + + /// + /// Gets or sets the which contains any custom header claims that need to be added to the JWT token header. + /// The 'alg', 'kid', 'x5t', 'enc', and 'zip' claims are added by default based on the , + /// , and/or provided and SHOULD NOT be included in this dictionary as this + /// will result in an exception being thrown. + /// These claims are only added to the outer header (in case of a JWE). + /// + public IDictionary AdditionalHeaderClaims { get; set; } + + /// + /// Gets or sets the which contains any custom header claims that need to be added to the inner JWT token header. + /// The 'alg', 'kid', 'x5t', 'enc', and 'zip' claims are added by default based on the , + /// , and/or provided and SHOULD NOT be included in this dictionary as this + /// will result in an exception being thrown. + /// + /// For JsonWebTokenHandler, these claims are merged with while adding to the inner JWT header. + /// + /// + public IDictionary AdditionalInnerHeaderClaims { get; set; } + } +} \ No newline at end of file diff --git a/DigitalData.Core.Security/DigitalData.Core.Security.csproj b/DigitalData.Core.Security/DigitalData.Core.Security.csproj index cdc5043..b2e980c 100644 --- a/DigitalData.Core.Security/DigitalData.Core.Security.csproj +++ b/DigitalData.Core.Security/DigitalData.Core.Security.csproj @@ -7,6 +7,7 @@ +