fido2-net-lib
fido2-net-lib copied to clipboard
Using Fido2NetLib with Microsoft Identity ASP.NET Core 6.0
I am using Fido2NetLib with Microsoft Identity ASP.NET Core 6.0 and implemented a sample project using the demo code and samples supplied from this GitHub. When trying to register a user I am getting the following error:
"Failed to read the 'attestation' property from 'PublicKeyCredentialCreationOptions': The provided value '0' is not a valid enum value of type AttestationConveyancePreference."
The values being passed are:
Attestation Type = "none"
Authenticator Attachment = ""
User Verification = "preferred"
Require Resident Key = "false"
Can someone give me any indicator what might be issue?
It works for me in .NET 6.0
I suspect there is a json serialisation issue.
The default of asp.net core is System.Text.Json which serializes enums as integers.
This library uses Newtonsoft (or it changes to system.text.json, dont remember exactly...). try to return data objects using the libraries ToJson method.
return Content(assertionOptions.ToJson(), "application/json");
I have an example of this working here:
https://github.com/damienbod/AspNetCoreIdentityFido2Mfa
maybe you can compare
Greetings Damien
I tried the same approach with ASP.NET Core 6 and ran into the same sort of serialization issues. I managed to get the default serializer to serialize to string, but the values don't match what is expected. I guess it's due to serialization settings. But after comparing your sources to mine @damienbod I can't find any custom serialization settings in your sample.
Are you using NewtonSoft or System.Text.Json?
Turns out, you need to call ToJson() on the created CredentialsCreateOptions. This is not matching any of the samples or the docs but works great.
Yes, we are in need of some update docs. Does anyone want to do a PR?
I'll take a look and create a PR. I'm in the process of writing a blogpost, so it's the right timing :-)
@wmeints I updated my identity samples and use System.Text.Json
Do you still need the update for the docs?
I believe so, this is a great package and more docs would be great