| | 1 | | namespace Kestrun.Jwt; |
| | 2 | |
|
| | 3 | | /// <summary> |
| | 4 | | /// Represents all parameters extracted from a JWT, including header fields, standard properties, and claims. |
| | 5 | | /// </summary> |
| | 6 | | public class JwtParameters |
| | 7 | | { |
| | 8 | | // Header fields |
| | 9 | | /// <summary> |
| | 10 | | /// Gets the JWT header fields as a dictionary. |
| | 11 | | /// </summary> |
| 49 | 12 | | public IDictionary<string, object> Header { get; init; } = new Dictionary<string, object>(); |
| | 13 | |
|
| | 14 | | // Standard properties |
| | 15 | | /// <summary> |
| | 16 | | /// Gets the issuer ("iss") claim from the JWT. |
| | 17 | | /// </summary> |
| 17 | 18 | | public string? Issuer { get; init; } |
| | 19 | | /// <summary> |
| | 20 | | /// Gets the audiences ("aud") claim from the JWT. |
| | 21 | | /// </summary> |
| 27 | 22 | | public IEnumerable<string> Audiences { get; init; } = []; |
| | 23 | | /// <summary> |
| | 24 | | /// Gets the subject ("sub") claim from the JWT. |
| | 25 | | /// </summary> |
| 17 | 26 | | public string? Subject { get; init; } |
| | 27 | | /// <summary> |
| | 28 | | /// Gets the "nbf" (Not Before) claim from the JWT, indicating the time before which the token is not valid. |
| | 29 | | /// </summary> |
| 14 | 30 | | public DateTime? NotBefore { get; init; } |
| | 31 | | /// <summary> |
| | 32 | | /// Gets the "exp" (Expiration Time) claim from the JWT, indicating the time after which the token expires. |
| | 33 | | /// </summary> |
| 16 | 34 | | public DateTime? Expires { get; init; } |
| | 35 | | /// <summary> |
| | 36 | | /// Gets the "iat" (Issued At) claim from the JWT, indicating when the token was issued. |
| | 37 | | /// </summary> |
| 12 | 38 | | public DateTime? IssuedAt { get; init; } |
| | 39 | | /// <summary> |
| | 40 | | /// Gets the algorithm ("alg") used to sign the JWT. |
| | 41 | | /// </summary> |
| 15 | 42 | | public string? Algorithm { get; init; } |
| | 43 | | /// <summary> |
| | 44 | | /// Gets the key ID ("kid") from the JWT header. |
| | 45 | | /// </summary> |
| 14 | 46 | | public string? KeyId { get; init; } |
| | 47 | | /// <summary> |
| | 48 | | /// Gets the type ("typ") of the JWT, indicating the token type. |
| | 49 | | /// </summary> |
| 15 | 50 | | public string? Type { get; init; } |
| | 51 | |
|
| | 52 | | // All payload claims |
| | 53 | | /// <summary> |
| | 54 | | /// Gets all claims from the JWT payload, including custom claims, as a dictionary. |
| | 55 | | /// </summary> |
| 86 | 56 | | public IDictionary<string, object> Claims { get; init; } = new Dictionary<string, object>(); |
| | 57 | | } |