Skip to content

Commit

Permalink
Merge pull request #34 from onahirniak/cache_key_prefix
Browse files Browse the repository at this point in the history
CacheKeyPrefix is added
  • Loading branch information
leastprivilege authored Jul 31, 2018
2 parents 2f01ba8 + 36d0626 commit a13f272
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()

if (Options.EnableCaching)
{
var claims = await _cache.GetClaimsAsync(token).ConfigureAwait(false);
var key = $"{Options.CacheKeyPrefix}{token}";
var claims = await _cache.GetClaimsAsync(key).ConfigureAwait(false);
if (claims != null)
{
var ticket = await CreateTicket(claims);
Expand Down Expand Up @@ -124,7 +125,8 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()

if (Options.EnableCaching)
{
await _cache.SetClaimsAsync(token, response.Claims, Options.CacheDuration, _logger).ConfigureAwait(false);
var key = $"{Options.CacheKeyPrefix}{token}";
await _cache.SetClaimsAsync(key, response.Claims, Options.CacheDuration, _logger).ConfigureAwait(false);
}

return AuthenticateResult.Success(ticket);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public OAuth2IntrospectionOptions()
/// </summary>
public TimeSpan CacheDuration { get; set; } = TimeSpan.FromMinutes(5);

/// <summary>
/// Specifies the prefix of the cache key (token).
/// </summary>
public string CacheKeyPrefix { get; set; } = string.Empty;

/// <summary>
/// Specifies the method how to retrieve the token from the HTTP request
/// </summary>
Expand Down

0 comments on commit a13f272

Please sign in to comment.