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

Obfuscate refresh token and authorization code in logs #4942

Merged
merged 1 commit into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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