skoruba / Duende.IdentityServer.Admin

The administration for the Duende IdentityServer and Asp.Net Core Identity ⚡
Apache License 2.0
556 stars 194 forks source link

MFA and authenticator apps #119

Open albrookesplowman opened 1 year ago

albrookesplowman commented 1 year ago

Hi, I am trying to configure the multi factor authentication via the Microsoft authenticator app. When I scan the qr code with the app in my phone it all seems to work ok but I don't get the verification code to enter into the website.. is there any other configuration that I need to do for this to work.. the authenticator app is cycling through the codes ok but it doesn't work on the website..

skoruba commented 1 year ago

What version of admin ui do you use?

albrookesplowman commented 1 year ago

I am using version 1.1 which I downloaded a couple of weeks ago. do I need to configure sendgrid?

albrookesplowman commented 1 year ago

I am trying to configure it to run inside docker on my local machine but I get the same problem inside vs2022..

skoruba commented 1 year ago

No, sendgrid is not mandatory for mfa. I tested mfa and it seems that it works. Can you describe steps where it is failed?

albrookesplowman commented 1 year ago

It is when i call EnableAuthenticator(EnableAuthenticatorViewModel model) in the ManageController in the STS.identity project after clicking the Verify button. I have tried entering the 6 digit code from the authentication app. Is this the correct verification code that I should be using? The model.IsValid is false and the authenticationUri property is null but the code is the 6 digits that I have entered is getting passed in. When I hover the mouse over the qrcode image, the Uri seems to be OK at that point. Sorry but I am not sure what the work flow should be.

albrookesplowman commented 1 year ago

Having stepped through this function again, the model parameter doesn't have the uri or key set so the isvalid is flagged as false so it just ends up in an endless loop returning the uri and key which it seems to get from the encrypted data in the database.

albrookesplowman commented 1 year ago

@skoruba - I found the problem. It was down to the declarations of the variables in class EnableAuthenticatorViewModel. The SharedKey and AuthenticationUri are declared as strings but this fails the validation check if the frontend passes in null strings. However, if I declare them as string? or nullable then everything works absolutely great. I have a lot warnings in VS2022 related to this. Do you want me to go through, make some code changes and a PR to remove them. I have also increased my .net core version to 7.0.2 too if that would be interest to you.

skoruba commented 1 year ago

Sure, go for it please. PR is welcome. thanks!

albrookesplowman commented 1 year ago

@skoruba - sorry for the delay. Tied up with the day job but I will try and get on this over the weekend.

skoruba commented 1 year ago

Sure, take a time. I am glad that you help me with it.