Skip to content

Commit a8e6945

Browse files
authored
Merge pull request #194 from IdentityModel/ignore-exp
Allow tokens without an exp claim
2 parents a258d1b + 1e41dfb commit a8e6945

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/Infrastructure/CacheExtensions.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,10 @@ public static async Task<IEnumerable<Claim>> GetClaimsAsync(this IDistributedCac
4646
public static async Task SetClaimsAsync(this IDistributedCache cache, OAuth2IntrospectionOptions options, string token, IEnumerable<Claim> claims, TimeSpan duration, ILogger logger)
4747
{
4848
var expClaim = claims.FirstOrDefault(c => c.Type == JwtClaimTypes.Expiration);
49-
if (expClaim == null)
50-
{
51-
Log.NoExpClaimFound(logger, null);
52-
return;
53-
}
54-
5549
var now = DateTimeOffset.UtcNow;
56-
var expiration = DateTimeOffset.FromUnixTimeSeconds(long.Parse(expClaim.Value));
50+
var expiration = expClaim == null
51+
? now + duration
52+
: DateTimeOffset.FromUnixTimeSeconds(long.Parse(expClaim.Value));
5753
Log.TokenExpiresOn(logger, expiration, null);
5854

5955
if (expiration <= now)
@@ -79,4 +75,4 @@ public static async Task SetClaimsAsync(this IDistributedCache cache, OAuth2Intr
7975
await cache.SetAsync(cacheKey, bytes, new DistributedCacheEntryOptions { AbsoluteExpiration = absoluteLifetime }).ConfigureAwait(false);
8076
}
8177
}
82-
}
78+
}

0 commit comments

Comments
 (0)