Skip to content
This repository has been archived by the owner on Jul 31, 2024. It is now read-only.

Commit

Permalink
Changed level from error to warn on refresh token (#2695)
Browse files Browse the repository at this point in the history
Expired tokens
Invalid tokens
  • Loading branch information
alnimin authored and brockallen committed Nov 4, 2018
1 parent 619760e commit 40288f7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/Validation/Default/TokenRequestValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ private async Task<TokenRequestValidationResult> ValidateRefreshTokenRequestAsyn

if (result.IsError)
{
LogError("Refresh token validation failed. aborting.");
LogWarning("Refresh token validation failed. aborting.");
return Invalid(OidcConstants.TokenErrors.InvalidGrant);
}

Expand Down Expand Up @@ -766,6 +766,26 @@ private void LogError(string message = null, params object[] values)
}
}

private void LogWarning(string message = null, params object[] values)
{
var details = new TokenRequestValidationLog(_validatedRequest);
if (message.IsPresent())
{
try
{
_logger.LogWarning(message + ", request details: {details}", values, details);
}
catch (Exception ex)
{
_logger.LogError("Error logging {exception}, request details: {details}", ex.Message, details);
}
}
else
{
_logger.LogWarning("{details}", details);
}
}

private void LogInfo(string message = null, params object[] values)
{
var details = new TokenRequestValidationLog(_validatedRequest);
Expand Down
4 changes: 2 additions & 2 deletions src/Validation/Default/TokenValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public async Task<TokenValidationResult> ValidateRefreshTokenAsync(string tokenH
var refreshToken = await _refreshTokenStore.GetRefreshTokenAsync(tokenHandle);
if (refreshToken == null)
{
_logger.LogError("Invalid refresh token");
_logger.LogWarning("Invalid refresh token");
return Invalid(OidcConstants.TokenErrors.InvalidGrant);
}

Expand All @@ -388,7 +388,7 @@ public async Task<TokenValidationResult> ValidateRefreshTokenAsync(string tokenH
/////////////////////////////////////////////
if (refreshToken.CreationTime.HasExceeded(refreshToken.Lifetime, _clock.UtcNow.DateTime))
{
_logger.LogError("Refresh token has expired. Removing from store.");
_logger.LogWarning("Refresh token has expired. Removing from store.");

await _refreshTokenStore.RemoveRefreshTokenAsync(tokenHandle);
return Invalid(OidcConstants.TokenErrors.InvalidGrant);
Expand Down

0 comments on commit 40288f7

Please sign in to comment.