1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 23:52:50 -05:00

Fix WebAuthn not working after move to System.Text.Json (#1818)

This commit is contained in:
Oscar Hinton
2022-01-24 18:13:43 +01:00
committed by GitHub
parent ac8ca46f0f
commit a9a5417350
4 changed files with 14 additions and 7 deletions

View File

@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text.Json;
using Bit.Core.Enums;
using Bit.Core.Utilities;
using Fido2NetLib.Objects;
namespace Bit.Core.Models
@ -24,8 +24,13 @@ namespace Bit.Core.Models
}
catch
{
// Handle newtonsoft parsing
Descriptor = JsonHelpers.LegacyDeserialize<PublicKeyCredentialDescriptor>(o.Descriptor.ToString());
// Fallback for older newtonsoft serialized tokens.
if (o.Descriptor.Type == 0)
{
o.Descriptor.Type = "public-key";
}
Descriptor = JsonSerializer.Deserialize<PublicKeyCredentialDescriptor>(o.Descriptor.ToString(),
new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
}
PublicKey = o.PublicKey;
UserHandle = o.UserHandle;