Copied to clipboard

Flag this post as spam?

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


  • mmaty 113 posts 286 karma points
    Nov 23, 2022 @ 04:59
    mmaty
    0

    Howto use my own data sources for roles and members?

    I got completely lost in the task of porting a pair of Custom Membership Provider / Role Provider from Umbraco 8 to Umbraco 10.

    All the examples I've found so far show how to use external OpenId Connect implementations so that the Umbraco members work with those authentication providers.

    However, this is not helpful for my current project.

    Let's start with the roles that are granted access to specific pages in Umbraco. In my old system, I have a Custom Role Provider that retrieves an array of roles, which Umbraco then displays in the dialog for securing a document. The implementation of where these roles come from is entirely up to me. In my case there is a service I can get the roles from. This is totally simple and works well.

    How can I achieve something like this in ASP.NET Core? All the examples covering this issue are extremely tightly tied to the Entity Framework. In my case, however, I want to retrieve the roles using a REST API. In previous versions I was able to do this with a Custom Role Provider. In Umbraco 10 I don't know at all where to start.

    All examples in the web show some startup configurations of .NET Core sites. But in Umbraco the startup code for ASP.NET Core is hidden in Umbraco's source code and I have no idea how to override the behavior in my own startup code.

    Let's continue with the login. In the old system there is a redirect to a login service showing the login dialog, which then makes a callback to the Umbraco system after a successful login. I think that's not too complicate to implement with Umbraco 10.

    In the callback of the old system I can now define the user name with FormsAuthentication.SetAuthCookie. Now the Custom Membership Provider comes into play. Umbraco uses the provider to retrieve information about the member. It was absolutely simple to call a REST API in my custom provider, to achieve this task. Umbraco was able to work with the member, as if it came from the own database.

    Again, I have the problem with Umbraco 10 that I don't know how to persuade the Umbraco system to use my own user data. This data does not come from the Umbraco database, but from the REST service.

    So my question here is: How can I get Umbraco to use my own role and user data in the simplest way possible?

  • Tim 45 posts 199 karma points
    Jul 05, 2023 @ 13:40
    Tim
    0

    Did you ever figure this one out? I've got a similar requirement coming up for a project and I'm also trying to figure out how to do this!

  • mmaty 113 posts 286 karma points
    Jul 06, 2023 @ 12:50
    mmaty
    101

    @Tim: Yes, I got a solution. I used my own implementations of IMemberService and IMemberGroupService. I used a composer, which registers this services with AddUnique (Umbraco 10, in Umbraco 11 you have to remove the Umbraco implementations before you add your own implementations). I remember having struggles with dependencies, so I added an additional service, the MemberGroupDataService. Both the MemberService and MemberGroupService instantiate the MemberGroupDataService in their constructor and use the MemberGroup data that way.

  • Tim 45 posts 199 karma points
    Jul 07, 2023 @ 10:50
    Tim
    0

    Awesome, thank you! That's given me a good idea of the approach to investigate for my project, much appreciated :)

Please Sign in or register to post replies

Write your reply to:

Draft