2026-02-06 19:58:01 +01:00
|
|
|
using System.Text.Json.Serialization;
|
|
|
|
|
|
|
|
|
|
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-14 14:54:48 +01:00
|
|
|
public required string Modulus { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
|
|
|
|
|
[JsonPropertyName("e")]
|
2026-02-14 14:54:48 +01:00
|
|
|
public required string Exponent { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
|
|
|
|
|
// Optional fields
|
|
|
|
|
[JsonPropertyName("x5c")]
|
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
2026-02-15 19:06:09 +01:00
|
|
|
public List<string>? X509CertificateChain { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
|
|
|
|
|
[JsonPropertyName("x5t")]
|
|
|
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
2026-02-15 19:06:09 +01:00
|
|
|
public string? X509CertificateThumbprint { get; set; }
|
2026-02-06 19:58:01 +01:00
|
|
|
}
|