-
Notifications
You must be signed in to change notification settings - Fork 413
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
Refactor: Add Serialization for JsonWebToken in OpenIdConnectConfiguration #2627
Conversation
@nguyencuong2596 can you please add a description for what you are trying to do? |
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.
Please add a description of what this PR is for.
8f42e4a
to
cc1bc52
Compare
cc1bc52
to
6aacac0
Compare
@@ -156,6 +158,14 @@ public static OpenIdConnectConfiguration Read(ref Utf8JsonReader reader, OpenIdC | |||
else if (reader.ValueTextEquals(Utf8Bytes.EndSessionEndpoint)) | |||
config.EndSessionEndpoint = JsonPrimitives.ReadString(ref reader, MetadataName.EndSessionEndpoint, ClassName, true); | |||
|
|||
else if (reader.ValueTextEquals(Encoding.UTF8.GetBytes(JsonWebKeySetParameterNames.Keys))) |
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.
OpenIdConnectRetriever will reset the JsonWebKeySet here:
Line 81 in d0131d5
openIdConnectConfiguration.JsonWebKeySet = new JsonWebKeySet(keys); |
Is that accounted for?
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.
Good point. However, this shouldn't disrupt the flow that retrieves the configuration from an L2 cache. It might be best to fetch keys only if they are not already set.
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.
Is the JsonWebKeySet set by the OpenIdConnectRetriever accounted for?
# Conflicts: # src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Configuration/OpenIdConnectConfiguration.cs # src/Microsoft.IdentityModel.Protocols.OpenIdConnect/Json/OpenIdConnectConfigurationSerializer.cs
test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectSerializationTests.cs
Outdated
Show resolved
Hide resolved
# Conflicts: # test/Microsoft.IdentityModel.Protocols.OpenIdConnect.Tests/OpenIdConnectConfigurationTests.cs
50ee6d6
to
39c3ac2
Compare
src/Microsoft.IdentityModel.Tokens/Json/JsonWebKeySetSerializer.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.
Why do we need the boolean in WriteObject.
A method that writes: WriteObject and passes a boolean to Not write an object doesn't make sense to me.
@@ -220,6 +223,16 @@ public static OpenIdConnectConfiguration Read(ref Utf8JsonReader reader, OpenIdC | |||
else if (reader.ValueTextEquals(Utf8Bytes.EndSessionEndpoint)) | |||
config.EndSessionEndpoint = JsonPrimitives.ReadString(ref reader, MetadataName.EndSessionEndpoint, ClassName, true); | |||
|
|||
else if (reader.ValueTextEquals(Encoding.UTF8.GetBytes(JsonWebKeySetParameterNames.Keys))) | |||
{ | |||
config.ShouldSerializeJsonWebKeys = true; |
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 is this set to true?
@@ -575,6 +587,14 @@ public static OpenIdConnectConfiguration Read(ref Utf8JsonReader reader, OpenIdC | |||
|
|||
else if (propertyName.Equals(MetadataName.UserInfoSigningAlgValuesSupported, StringComparison.OrdinalIgnoreCase)) | |||
JsonPrimitives.ReadStrings(ref reader, config.UserInfoEndpointSigningAlgValuesSupported, propertyName, ClassName); | |||
|
|||
else if (propertyName.Equals(JsonWebKeySetParameterNames.Keys, StringComparison.OrdinalIgnoreCase)) |
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 is a breaking behavior for users.
Previously, users would have found an object in AdditionalData.
if (config.JsonWebKeySet == null) | ||
config.JsonWebKeySet = new JsonWebKeySet(); | ||
// Skip key "Keys" | ||
reader.Read(); |
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 is different than the case-insensitive below, reader.Read() is not called.
|
||
internal static void Append(ref Utf8JsonWriter writer, JsonWebKeySet jsonWebKeySet) |
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.
WriteKeys would be a better name than Append.
@@ -634,7 +634,7 @@ public static TheoryData<ConfigurationManagerTheoryData<OpenIdConnectConfigurati | |||
ConfigurationValidator = openIdConnectConfigurationValidator2, | |||
DocumentRetriever = new FileDocumentRetriever(), | |||
ExpectedException = new ExpectedException(typeof(InvalidOperationException), "IDX21817:", typeof(InvalidConfigurationException)), | |||
MetadataAddress = "JsonWebKeySetUnrecognizedKty.json", | |||
MetadataAddress = "EmptyJsonWebKeySet.json", |
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 were these tests removed?
JsonWebKeySetUnrecognizedKty
Moving to a different project. |
Refactor: Add Serialization for JsonWebToken in OpenIdConnectConfiguration
Summary of the changes (Less than 80 chars)
Description