Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ras 64 posts 328 karma points
    Sep 27, 2023 @ 08:16
    Ras
    0

    2FA documentation, confusing?

    Hi, I've started implementing 2FA for members on my Umbraco 10 site, but having some problems and the documentation (https://docs.umbraco.com/umbraco-cms/reference/security/two-factor-authentication) is a bit unclear to me. First of all I've added a Compose in my startup.cs as such:

        public void Compose(IUmbracoBuilder builder)
        {
          var identityBuilder = new MemberIdentityBuilder(builder.Services);
          identityBuilder.AddTwoFactorProvider<UmbracoAppAuthenticator>(UmbracoAppAuthenticator.Name);
        }
    

    Do I need to do anything further with this? Where do I call the Compose() from?

    At this point I've reached this part:

    At this point, the 2FA is active, but no members have set up 2FA yet. The setup of 2FA depends on the type. In the case of App Authenticator, we will add the following to our view showing the edit profile of the member.

    Then it shows a view with some code. What is this view? How is it used? Where is it supposed to be displayed? I tried creating a new document type containing this code and tried browsing to it but I'm presented with a blank page (except for my default layout), I've also tried restricting the view to members but same result when logged in. Unsure how to proceed.

    Edit: Seems the problem might be that no providers are added. But it's unclear exactly how I add a specific provider?

  • Huw Reddick 1929 posts 6697 karma points MVP 2x c-trib
    Sep 27, 2023 @ 10:02
    Huw Reddick
    100

    Hi Ras,

    The compose should be in it's own class that inherits IComposer

    public class UmbracoAppAuthenticatorComposer : IComposer
    {
        public void Compose(IUmbracoBuilder builder)
        {
            var identityBuilder = new MemberIdentityBuilder(builder.Services);
            identityBuilder.AddTwoFactorProvider<UmbracoAppAuthenticator>(UmbracoAppAuthenticator.Name);
        }
    }
    
  • Ras 64 posts 328 karma points
    Sep 27, 2023 @ 10:32
    Ras
    0

    Hello, just as I finished writing this post I made this change actually, but my list of providers still result in an empty list in the view. Not sure why it's not registering my provider? When I debug it it seems to appear as expected in the composer.

    Edit: I checked my composer again and corrected it, thank you. I still had a problem where my view was empty, but it seems like it was me who didn't change the default model that came from the documentation! Thank you again.

Please Sign in or register to post replies

Write your reply to:

Draft