Skip to content

Commit f144215

Browse files
author
Mark Macneil
committed
post in progress
1 parent 7997331 commit f144215

File tree

1 file changed

+11
-57
lines changed

1 file changed

+11
-57
lines changed

src/dotnetGigs/Models/JwtIssuerOptions.cs

Lines changed: 11 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,91 +7,45 @@ namespace DotNetGigs.Models
77
public class JwtIssuerOptions
88
{
99
/// <summary>
10-
/// "iss" (Issuer) Claim
10+
/// 4.1.1. "iss" (Issuer) Claim - The "iss" (issuer) claim identifies the principal that issued the JWT.
1111
/// </summary>
12-
/// <remarks>The "iss" (issuer) claim identifies the principal that issued the
13-
/// JWT. The processing of this claim is generally application specific.
14-
/// The "iss" value is a case-sensitive string containing a StringOrURI
15-
/// value. Use of this claim is OPTIONAL.</remarks>
1612
public string Issuer { get; set; }
1713

1814
/// <summary>
19-
/// "sub" (Subject) Claim
15+
/// 4.1.2. "sub" (Subject) Claim - The "sub" (subject) claim identifies the principal that is the subject of the JWT.
2016
/// </summary>
21-
/// <remarks> The "sub" (subject) claim identifies the principal that is the
22-
/// subject of the JWT. The claims in a JWT are normally statements
23-
/// about the subject. The subject value MUST either be scoped to be
24-
/// locally unique in the context of the issuer or be globally unique.
25-
/// The processing of this claim is generally application specific. The
26-
/// "sub" value is a case-sensitive string containing a StringOrURI
27-
/// value. Use of this claim is OPTIONAL.</remarks>
2817
public string Subject { get; set; }
2918

3019
/// <summary>
31-
/// "aud" (Audience) Claim
20+
/// 4.1.3. "aud" (Audience) Claim - The "aud" (audience) claim identifies the recipients that the JWT is intended for.
3221
/// </summary>
33-
/// <remarks>The "aud" (audience) claim identifies the recipients that the JWT is
34-
/// intended for. Each principal intended to process the JWT MUST
35-
/// identify itself with a value in the audience claim. If the principal
36-
/// processing the claim does not identify itself with a value in the
37-
/// "aud" claim when this claim is present, then the JWT MUST be
38-
/// rejected. In the general case, the "aud" value is an array of case-
39-
/// sensitive strings, each containing a StringOrURI value. In the
40-
/// special case when the JWT has one audience, the "aud" value MAY be a
41-
/// single case-sensitive string containing a StringOrURI value. The
42-
/// interpretation of audience values is generally application specific.
43-
/// Use of this claim is OPTIONAL.</remarks>
4422
public string Audience { get; set; }
4523

4624
/// <summary>
47-
/// "nbf" (Not Before) Claim (default is UTC NOW)
25+
/// 4.1.4. "exp" (Expiration Time) Claim - The "exp" (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing.
26+
/// </summary>
27+
public DateTime Expiration => IssuedAt.Add(ValidFor);
28+
29+
/// <summary>
30+
/// 4.1.5. "nbf" (Not Before) Claim - The "nbf" (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing.
4831
/// </summary>
49-
/// <remarks>The "nbf" (not before) claim identifies the time before which the JWT
50-
/// MUST NOT be accepted for processing. The processing of the "nbf"
51-
/// claim requires that the current date/time MUST be after or equal to
52-
/// the not-before date/time listed in the "nbf" claim. Implementers MAY
53-
/// provide for some small leeway, usually no more than a few minutes, to
54-
/// account for clock skew. Its value MUST be a number containing a
55-
/// NumericDate value. Use of this claim is OPTIONAL.</remarks>
5632
public DateTime NotBefore { get; set; } = DateTime.UtcNow;
5733

5834
/// <summary>
59-
/// "iat" (Issued At) Claim (default is UTC NOW)
35+
/// 4.1.6. "iat" (Issued At) Claim - The "iat" (issued at) claim identifies the time at which the JWT was issued.
6036
/// </summary>
61-
/// <remarks>The "iat" (issued at) claim identifies the time at which the JWT was
62-
/// issued. This claim can be used to determine the age of the JWT. Its
63-
/// value MUST be a number containing a NumericDate value. Use of this
64-
/// claim is OPTIONAL.</remarks>
6537
public DateTime IssuedAt { get; set; } = DateTime.UtcNow;
6638

6739
/// <summary>
6840
/// Set the timespan the token will be valid for (default is 5 min/300 seconds)
6941
/// </summary>
7042
public TimeSpan ValidFor { get; set; } = TimeSpan.FromMinutes(5);
7143

72-
/// <summary>
73-
/// "exp" (Expiration Time) Claim (returns IssuedAt + ValidFor)
74-
/// </summary>
75-
/// <remarks>The "exp" (expiration time) claim identifies the expiration time on
76-
/// or after which the JWT MUST NOT be accepted for processing. The
77-
/// processing of the "exp" claim requires that the current date/time
78-
/// MUST be before the expiration date/time listed in the "exp" claim.
79-
/// Implementers MAY provide for some small leeway, usually no more than
80-
/// a few minutes, to account for clock skew. Its value MUST be a number
81-
/// containing a NumericDate value. Use of this claim is OPTIONAL.</remarks>
82-
public DateTime Expiration => IssuedAt.Add(ValidFor);
44+
8345

8446
/// <summary>
8547
/// "jti" (JWT ID) Claim (default ID is a GUID)
8648
/// </summary>
87-
/// <remarks>The "jti" (JWT ID) claim provides a unique identifier for the JWT.
88-
/// The identifier value MUST be assigned in a manner that ensures that
89-
/// there is a negligible probability that the same value will be
90-
/// accidentally assigned to a different data object; if the application
91-
/// uses multiple issuers, collisions MUST be prevented among values
92-
/// produced by different issuers as well. The "jti" claim can be used
93-
/// to prevent the JWT from being replayed. The "jti" value is a case-
94-
/// sensitive string. Use of this claim is OPTIONAL.</remarks>
9549
public Func<Task<string>> JtiGenerator =>
9650
() => Task.FromResult(Guid.NewGuid().ToString());
9751

0 commit comments

Comments
 (0)