Skip to content
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

Using Fido2NetLib with Microsoft Identity ASP.NET Core 6.0 #280

Open
andreizammit opened this issue Dec 22, 2021 · 9 comments
Open

Using Fido2NetLib with Microsoft Identity ASP.NET Core 6.0 #280

andreizammit opened this issue Dec 22, 2021 · 9 comments
Labels
documentation Documentation, comments, guides, info etc.

Comments

@andreizammit
Copy link

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?

@dIeGoLi
Copy link
Contributor

dIeGoLi commented Jan 7, 2022

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");

@damienbod
Copy link
Contributor

I have an example of this working here:

https://github.com/damienbod/AspNetCoreIdentityFido2Mfa

maybe you can compare

Greetings Damien

@wmeints
Copy link

wmeints commented Jul 13, 2022

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?

@wmeints
Copy link

wmeints commented Jul 15, 2022

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.

@abergs
Copy link
Collaborator

abergs commented Jul 26, 2022

Yes, we are in need of some update docs. Does anyone want to do a PR?

@abergs abergs added the documentation Documentation, comments, guides, info etc. label Jul 26, 2022
@wmeints
Copy link

wmeints commented Aug 12, 2022

I'll take a look and create a PR. I'm in the process of writing a blogpost, so it's the right timing :-)

@damienbod
Copy link
Contributor

@wmeints I updated my identity samples and use System.Text.Json

@wmeints
Copy link

wmeints commented Aug 12, 2022

Do you still need the update for the docs?

@damienbod
Copy link
Contributor

I believe so, this is a great package and more docs would be great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation, comments, guides, info etc.
Projects
None yet
Development

No branches or pull requests

5 participants