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

Commit

Permalink
Merge pull request #4942 from IdentityServer/features/obfuscate-sensi…
Browse files Browse the repository at this point in the history
…tive-data-in-logs

Obfuscate refresh token and authorization code in logs
  • Loading branch information
brockallen authored Oct 5, 2020
2 parents 62d48b5 + 0b0f38f commit 2e27824
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/IdentityServer4/src/Extensions/StringsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,16 @@ public static string GetOrigin(this string url)

return null;
}

public static string Obfuscate(this string value)
{
var last4Chars = "****";
if (value.IsPresent() && value.Length > 4)
{
last4Chars = value.Substring(value.Length - 4);
}

return "****" + last4Chars;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public TokenRequestValidationLog(ValidatedTokenRequest request, IEnumerable<stri
}

GrantType = request.GrantType;
AuthorizationCode = request.AuthorizationCodeHandle;
RefreshToken = request.RefreshTokenHandle;
AuthorizationCode = request.AuthorizationCodeHandle.Obfuscate();
RefreshToken = request.RefreshTokenHandle.Obfuscate();
UserName = request.UserName;
}

Expand Down

0 comments on commit 2e27824

Please sign in to comment.