Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.

Commit 36d0626

Browse files
author
KYIV\Oleksandr_Nahirniak
committed
CacheKeyPrefix is added
1 parent 2f01ba8 commit 36d0626

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/IdentityModel.AspNetCore.OAuth2Introspection/OAuth2IntrospectionHandler.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
7676

7777
if (Options.EnableCaching)
7878
{
79-
var claims = await _cache.GetClaimsAsync(token).ConfigureAwait(false);
79+
var key = $"{Options.CacheKeyPrefix}{token}";
80+
var claims = await _cache.GetClaimsAsync(key).ConfigureAwait(false);
8081
if (claims != null)
8182
{
8283
var ticket = await CreateTicket(claims);
@@ -124,7 +125,8 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
124125

125126
if (Options.EnableCaching)
126127
{
127-
await _cache.SetClaimsAsync(token, response.Claims, Options.CacheDuration, _logger).ConfigureAwait(false);
128+
var key = $"{Options.CacheKeyPrefix}{token}";
129+
await _cache.SetClaimsAsync(key, response.Claims, Options.CacheDuration, _logger).ConfigureAwait(false);
128130
}
129131

130132
return AuthenticateResult.Success(ticket);

src/IdentityModel.AspNetCore.OAuth2Introspection/OAuth2IntrospectionOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ public OAuth2IntrospectionOptions()
115115
/// </summary>
116116
public TimeSpan CacheDuration { get; set; } = TimeSpan.FromMinutes(5);
117117

118+
/// <summary>
119+
/// Specifies the prefix of the cache key (token).
120+
/// </summary>
121+
public string CacheKeyPrefix { get; set; } = string.Empty;
122+
118123
/// <summary>
119124
/// Specifies the method how to retrieve the token from the HTTP request
120125
/// </summary>

0 commit comments

Comments
 (0)