Copied to clipboard

Flag this post as spam?

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


  • andrew shearer 506 posts 653 karma points
    Nov 04, 2022 @ 03:34
    andrew shearer
    0

    Umbraco 10 membership: external login and roles/claims

    Hello

    I am converting an Umbraco 7 site to Umbraco 10. It uses a CRM for membership login including providing the roles they belong to. In the CMS, the typical public access settings are used to lock down pages to those same CRM roles set up as equivalent member groups. In the umbraco 7 site, authentication was achieved with a Custom RoleProvider to obtain the roles from the CRM, and Umbraco did the rest.

    How do I achieve the same thing in Umbraco 10 / net core? Using the following seems to achieve the login part (where UserID is a unique id from the CRM already verified by a login workflow not included here):

    //https://our.umbraco.com/documentation/reference/querying/IMemberManager/
     var memberIdentityUser = new MemberIdentityUser() {
        UserName = authResult.UserID,                           
    };
     await _memberSignInManager.SignInAsync(memberIdentityUser, false);
    

    however, the missing piece of the puzzle is the roles. Do they need to be added as claims somehow? I tried the following but it doesn’t work:

    foreach (var crmRole in authResult.RoleGroups)
        memberIdentityUser.AddRole(crmRole.RoleGroupName);
    

    Is the only option to explore auto-linking? https://our.umbraco.com/documentation/reference/security/auto-linking/ That seems to still want a member record in Umbraco. Ideally that’s not what I want to do at all.

    Thanks for any insight

    Andrew

  • Ruder Partap Singh 28 posts 142 karma points
    Nov 05, 2022 @ 08:28
    Ruder Partap Singh
    0

    HI

    please go through the below link. a wonderfull article by Poornima Nayar that help me to set the custom claims in umbraco 9

    https://poornimanayar.co.uk/blog/member-login-with-umbraco-9/

    i hope this help

    Thanks

  • andrew shearer 506 posts 653 karma points
    Nov 14, 2022 @ 02:09
    andrew shearer
    0

    hi Ruder - thanks for the link. The User Identity object now has the claims i expected (and from what i understand they have the correct claim type, "http://schemas.microsoft.com/ws/2008/06/identity/claims/role").

    Now, memberManager.IsLoggedIn() returns true but IsMemberAuthorizedAsync() still returns false so I suspect there's still an issue comparing the claims to the member groups defined in the public access section of Umbraco.

    I'm finding hard to get a definitive answer if a member record needs to exist in Umbraco for this to all work. The idea is that i don't want to. Does anybody know?

    thanks

  • andrew shearer 506 posts 653 karma points
    Nov 14, 2022 @ 04:04
    andrew shearer
    0

    or in other words - in umbraco 10, how can i implement a UmbracoRoleProvider like you could in 7? thanks

  • Joel Mandell 6 posts 75 karma points c-trib
    Jul 23, 2023 @ 00:31
    Joel Mandell
    0

    This video might give you some hints on how to do it: https://youtu.be/aouFfym_7Zs

Please Sign in or register to post replies

Write your reply to:

Draft