6
votes

I am using ServiceStack and have started to add role based authorization to my service. From the documentation I can see there are services to assign and remove roles from a user via the web service.

My question is are there any built-in services included in ServiceStack to query the roles and permissions the user currently has?

1

1 Answers

7
votes

There is no built-in Service in ServiceStack that returns Users Roles and Permissions, but it's easy enough to create your own custom Service to do this, e.g you can read it from the session with something like:

public class MyService : Service { 
    public object Get(UserRoles request) {
        var session = this.GetSession();
        return new UserRolesResponse {
            Roles = session.Roles,
            Permissions = session.Permissions,
        };
    }
}

For an example of an Admin service to return all users Auth details see the SocialBoostrap UserAuths Service.