Browse Source

Fix the Data Protection formatters to use the same properties format version as ASOS

pull/1197/head
Kévin Chalet 5 years ago
parent
commit
d123a83de6
  1. 3
      src/OpenIddict.Abstractions/OpenIddictResources.resx
  2. 9
      src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs
  3. 7
      src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs

3
src/OpenIddict.Abstractions/OpenIddictResources.resx

@ -1119,6 +1119,9 @@ To register the OpenIddict core services, reference the 'OpenIddict.Core' packag
<data name="ID0286" xml:space="preserve">
<value>The specified principal doesn't contain a valid claims-based identity.</value>
</data>
<data name="ID0287" xml:space="preserve">
<value>The payload of this authentication ticket was serialized using an unsupported formatter version.</value>
</data>
<data name="ID2000" xml:space="preserve">
<value>The security token is missing.</value>
</data>

9
src/OpenIddict.Server.DataProtection/OpenIddictServerDataProtectionFormatter.cs

@ -16,6 +16,7 @@ using System.Text.Json;
using OpenIddict.Abstractions;
using static OpenIddict.Abstractions.OpenIddictConstants;
using Properties = OpenIddict.Server.DataProtection.OpenIddictServerDataProtectionConstants.Properties;
using SR = OpenIddict.Abstractions.OpenIddictResources;
namespace OpenIddict.Server.DataProtection
{
@ -66,7 +67,7 @@ namespace OpenIddict.Server.DataProtection
var version = reader.ReadInt32();
if (version != 5)
{
return (null, ImmutableDictionary.Create<string, string>());
throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
}
// Read the authentication scheme associated to the ticket.
@ -150,9 +151,9 @@ namespace OpenIddict.Server.DataProtection
{
// Read the version of the format used to serialize the properties.
var version = reader.ReadInt32();
if (version != 5)
if (version != 1)
{
return ImmutableDictionary.Create<string, string>();
throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
}
var count = reader.ReadInt32();
@ -363,7 +364,7 @@ namespace OpenIddict.Server.DataProtection
static void WriteProperties(BinaryWriter writer, IReadOnlyDictionary<string, string> properties)
{
// Write the version of the format used to serialize the properties.
writer.Write(/* version: */ 5);
writer.Write(/* version: */ 1);
writer.Write(properties.Count);
foreach (var property in properties)

7
src/OpenIddict.Validation.DataProtection/OpenIddictValidationDataProtectionFormatter.cs

@ -13,6 +13,7 @@ using System.Text.Json;
using OpenIddict.Abstractions;
using static OpenIddict.Abstractions.OpenIddictConstants;
using Properties = OpenIddict.Validation.DataProtection.OpenIddictValidationDataProtectionConstants.Properties;
using SR = OpenIddict.Abstractions.OpenIddictResources;
namespace OpenIddict.Validation.DataProtection
{
@ -63,7 +64,7 @@ namespace OpenIddict.Validation.DataProtection
var version = reader.ReadInt32();
if (version != 5)
{
return (null, ImmutableDictionary.Create<string, string>());
throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
}
// Read the authentication scheme associated to the ticket.
@ -147,9 +148,9 @@ namespace OpenIddict.Validation.DataProtection
{
// Read the version of the format used to serialize the properties.
var version = reader.ReadInt32();
if (version != 5)
if (version != 1)
{
return ImmutableDictionary.Create<string, string>();
throw new InvalidOperationException(SR.GetResourceString(SR.ID0287));
}
var count = reader.ReadInt32();

Loading…
Cancel
Save