Listing Users with AdminUsersFeature

Hi i’m trying the AdminUsersFeature :slight_smile: , i was looking to lists users with roles and permissions so i can show that in a admin user grid. Permissions and roles are returned correctly if i retrieve the user directly with AdminGetUser.

But on the AdminQueryUsers endpoint the Roles and Permissions are empty.

Maybe i din’t configure it correctly. this is my setup

           new AdminUsersFeature()
            {
                IncludeUserAuthProperties = {
                     nameof(UserAuth.Roles),
                     nameof(UserAuth.Permissions),
                },
                QueryUserAuthProperties = {
                     nameof(UserAuth.Roles),
                     nameof(UserAuth.Permissions),
                },
            }

AdminQueryUsers response:

{
  "results": [
    {
      "Id": 1,
      "Email": "admin@localhost.local",
      "DisplayName": "Admin User",
      "CreatedDate": "/Date(1600579951913-0000)/",
      "ModifiedDate": "/Date(1600579951913-0000)/",
      "Roles": [],
      "Permissions": []
    }
  ]
}

AdminGetUser response:

{
  "id": "1",
  "result": {
    "Id": 1,
    "Email": "admin@localhost.local",
    "DisplayName": "Admin User",
    "Roles": [
      "Admin"
    ],
    "Permissions": [],
    "CreatedDate": "/Date(1600579951913-0000)/",
    "ModifiedDate": "/Date(1600579951913-0000)/",
    "InvalidLoginAttempts": 0
  }
}

Roles/Permissions are not going to be returned when searching for users in AdminQueryUsers only when retrieving a single User, e.g. in AdminGetUser as some Auth Repositories can choose to store them differently by implementing IManageRoles APIs.

I’m currently using this feature to build out the new User Management module in Studio.

1 Like

Ok understood.

Do you think dtos could be moved to ServiceStack.Interfaces ? would be nice for example to reference it from Blazor for example.

I didn’t want to pollute the client DTOs for a likely rarely used feature, but if you think it’d be useful I just moved them to ServiceStack.Client with all the other AuthDtos.cs.

I’ll let you know when they land on MyGet, note: you can always just copy any DTOs you need.

Good thanks.

Yeah this is what i did for the time being :slight_smile:

1 Like

The DTOs are now in ServiceStack.Client from the latest v5.9.3+ on MyGet.

1 Like