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

GetTwoFactorAuthenticationUserAsync(); #9

Closed
nicowitteman opened this issue Jan 8, 2021 · 12 comments
Closed

GetTwoFactorAuthenticationUserAsync(); #9

nicowitteman opened this issue Jan 8, 2021 · 12 comments

Comments

@nicowitteman
Copy link

await _signInManager.GetTwoFactorAuthenticationUserAsync() always returns null in release version, while it does function in development mode. I do see a cookie named Identity.TwoFactorUserId being set after the first step of logging in.

My environment is .NET 5.0

@damienbod
Copy link
Owner

Hi @nicowitteman

This should work, I'll have a look

Greetings Damien

@nicowitteman
Copy link
Author

nicowitteman commented Jan 9, 2021

Hello Damien, I forgot to mention that I made some changes in the code make the solution work in a subfolder (which was quite a trial and error effort). Could there be a relation?
The same check is done and fails as well in MakeAssertion.
My workaround is to save the username in a session cookie after successful login, and read it here.
Nico

@nicowitteman
Copy link
Author

nicowitteman commented Jan 10, 2021

I'm afraid my diagnosis was incorrect: it does work on localhost in both dev and release modes, but it fails when published. I publish in self-contained win-x64, running out-of-process. Any clue? Nico

@damienbod
Copy link
Owner

This should work as well, the app.setting for the domain needs to mathc with your deployment

Greetings Damien

@nicowitteman
Copy link
Author

It does match, Damien, or it would not work at all. I have serverDomain and origin matching the deployment. That is to say, both without the folder name I deployed into, which is the same as I do for localhost. I believe serverName can be anything, and I did not touch timestampDriftTolerance (the server time is correct) or MDSAccessKey.

@nicowitteman
Copy link
Author

It looks like something is going wrong in the AuthenticationHandler. Can't figure it out yet. It is just not stable - it works at times, and then suddenly it doesn't.

@nicowitteman
Copy link
Author

Hi Damien, let's close this issue - it is not in your code. At times I get an error from navigator.credentials.get, about the operation not being allowed. In Edge, a reference is shown to https://www.w3.org/TR/webauthn-2/#sctn-privacy-considerations-client.

@damienbod
Copy link
Owner

damienbod commented Jan 17, 2021

@nicowitteman Could you post a comment when you find a solution? Would be interesting

Greetings Damien

@nicowitteman
Copy link
Author

Hi Damien, I have new insights: in the cases SignInManager returns null and therefore the login fails, the preceding /mfassertionOptions POST had not included the Identity.TwoFactorUserId cookie, even though the browser shows it as being present. This happens mostly using the Firefox browser, but also Chrome and Edge fail occasionally. Safari on my iPhone on the other hand always works as expected. Does this behaviour ring a bell?

@nicowitteman nicowitteman reopened this Jan 19, 2021
@damienbod
Copy link
Owner

@nicowitteman Have not experienced this, thanks for the feedback.

@nicowitteman
Copy link
Author

I think I got it, finally: since I deployed my solution in a folder, and the Identity.TwoFactorUserId-cookie is stored with the path=folder, no cookie was found when the url wasn't all lowercase. This, and case-sensitivity of cookies! So it worked when I went to /fido2mfa/login, but it didn't when I went to /Fido2MFA/login. Now I force all url's to lowercase in web.config, the cookie is created with the lowercase pathname and no cookie confusion is possbile anymore.

@damienbod
Copy link
Owner

great you got it working, congrats. Thanks for the feedback as well.

Greetings Damien

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants