2026-02-06 19:58:01 +01:00
|
|
|
using System.Text.Json.Serialization;
|
2026-02-27 18:50:28 +01:00
|
|
|
using IdentityShroud.Core.Helpers;
|
2026-02-06 19:58:01 +01:00
|
|
|
|
|
|
|
|
namespace IdentityShroud.Core.Messages;
|
|
|
|
|
|
2026-02-14 14:54:48 +01:00
|
|
|
// https://www.rfc-editor.org/rfc/rfc7517.html
|
|
|
|
|
|
|
|
|
|
|
2026-02-06 19:58:01 +01:00
|
|
|
public class JsonWebKey
|
|
|
|
|
{
|
|
|
|
|
[JsonPropertyName("kty")]
|
|
|
|
|
public string KeyType { get; set; } = "RSA";
|
|
|
|
|
|
2026-02-14 14:54:48 +01:00
|
|
|
// Common values sig(nature) enc(ryption)
|
2026-02-06 19:58:01 +01:00
|
|
|
[JsonPropertyName("use")]
|
2026-02-14 14:54:48 +01:00
|
|
|
public string? Use { get; set; } = "sig"; // "sig" for signature, "enc" for encryption
|
2026-02-06 19:58:01 +01:00
|
|
|
|
2026-02-15 19:06:09 +01:00
|
|
|
// Per standard this field is optional, commented out for now as it seems not
|
|
|
|
|
// have any good use in an identity server. Anyone validating tokens should use
|
|
|
|
|
// the algorithm specified in the header of the token.
|
|
|
|
|
// [JsonPropertyName("alg")]
|
|
|
|
|
// public string? Algorithm { get; set; } = "RS256";
|
2026-02-06 19:58:01 +01:00
|
|
|
|
|
|
|
|
[JsonPropertyName("kid")]
|
2026-02-14 14:54:48 +01:00
|
|
|
public required string KeyId { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
|
|
|
|
|
// RSA Public Key Components
|
|
|
|
|
[JsonPropertyName("n")]
|
2026-02-20 17:35:38 +01:00
|
|
|
public string? Modulus { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
|
|
|
|
|
[JsonPropertyName("e")]
|
2026-02-20 17:35:38 +01:00
|
|
|
public string? Exponent { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
|
2026-02-20 17:35:38 +01:00
|
|
|
// ECdsa
|
|
|
|
|
public string? Curve { get; set; }
|
|
|
|
|
[JsonConverter(typeof(Base64UrlConverter))]
|
|
|
|
|
public byte[]? X { get; set; }
|
|
|
|
|
[JsonConverter(typeof(Base64UrlConverter))]
|
|
|
|
|
public byte[]? Y { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
|
2026-02-20 17:35:38 +01:00
|
|
|
// Optional fields
|
|
|
|
|
// [JsonPropertyName("x5c")]
|
|
|
|
|
// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
|
|
|
// public List<string>? X509CertificateChain { get; set; }
|
|
|
|
|
//
|
|
|
|
|
// [JsonPropertyName("x5t")]
|
|
|
|
|
// [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
|
|
|
// public string? X509CertificateThumbprint { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
}
|