-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xiao/DisarmSecurityArtifact #2064
Conversation
0c583ae
to
de6d050
Compare
@ciaozhang can you add more details to the description as well as a section which can be copied directly into the release notes? I'm happy to help construct if you need help. @jmprieur would also likely be able to help. In reply to: 1524185285 In reply to: 1524185285 In reply to: 1524185285 |
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectProtocolValidator.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectProtocolValidator.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectProtocolValidator.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the changes so far Xiao.
You mentioned to me you also had two questions for Brent/Team? Can you please add those as comments in the PR and we can resolve there?
@ciaozhang minor observation, the title of the PR is very descriptive but the commit message is not. Let's try to keep our commit messages readable and with enough context for anyone to understand a change. In reply to: 1526562219 In reply to: 1526562219 In reply to: 1526562219 |
test/Microsoft.IdentityModel.JsonWebTokens.Tests/JwtTokenUtilitiesTests.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ciaozhang
I've asked questions.
Not sure why this is so complicated?
why not just:
if (PII)
{
write token;
}
else
{
write token.SubString(0, token.LastIndexOf('.'));
}
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Logging/IdentityModelEventSource.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.JsonWebTokens/JsonWebTokenHandler.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.IdentityModel.Protocols.OpenIdConnect/OpenIdConnectProtocolValidator.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
rename the interface temp save temp save santize logic resolve comments address comments address comments
b669c1d
to
cedb975
Compare
@@ -429,6 +429,24 @@ private static long ParseTimeValue(JToken jToken, string claimName) | |||
throw LogHelper.LogExceptionMessage(new FormatException(LogHelper.FormatInvariant(LogMessages.IDX14300, LogHelper.MarkAsNonPII(claimName), jToken.ToString(), LogHelper.MarkAsNonPII(typeof(long))))); | |||
} | |||
|
|||
internal static string SafeLogJwtToken(object obj) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the callback func we used in SecurityArtifact struct. The reason we take obj as the type of parameter is LogHelper treat all arguments as object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, still regardless of the parameter type this is meant to be consumed by using string version of tokens correct?
how do you justify the code for non strings that you have here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will use the default ToString() method return the GetType().ToString()
int lastDot = token.LastIndexOf("."); | ||
|
||
// no dots, maybe not a JWT | ||
if (lastDot == -1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will throw in the ReadToken() method if the string token is not an encoded JWT token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be safe regardless of the caller, for non strings, non tokens we should return null.
src/Microsoft.IdentityModel.Logging/IdentityModelEventSource.cs
Outdated
Show resolved
Hide resolved
namespace Microsoft.IdentityModel.Logging | ||
{ | ||
/// <summary> | ||
/// Interface that provides an unsafe method to log a security artifact. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// <param name="arg">A log message argument to be marked as SecurityArtifact.</param> | ||
/// <param name="callback">A callback function to log the security artifact safely.</param> | ||
/// <returns>An argument marked as SecurityArtifact.</returns> | ||
public static object MarkAsSecurityArtifact(object arg, Func<object, string> callback) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we receive an object here, this should receive and return a string. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving based on Victor's approval and seeing that the new direction is more consistent. Thanks for the changes @ciaozhang!
Remove the signatures from JWS and authentication tag from JWE when PII is on.