Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authorization Roles and Permissions

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?

like image 215
mickfold Avatar asked Jan 16 '13 10:01

mickfold


People also ask

What is difference between role and permission?

A permission grants users the ability to perform an action on a resource in the WorkMarket platform. A role is a set of one or more permissions and can be assigned to a user to grant a set of permissions.

What are the 3 types of access control?

Three main types of access control systems are: Discretionary Access Control (DAC), Role Based Access Control (RBAC), and Mandatory Access Control (MAC).

What is authorization permission?

Authorization means determining whether that user, server, or client as permission to do something. Permissions are settings on a file or other object that define who or what is allowed to use it and what they are allowed to do with it.

What is the role of user permission?

User Roles give Administrators the ability to control what users can do within the system, without giving full administrator access. A Role is a collection of Permissions which could be based on a job function. Permissions are assigned to Roles and Roles are assigned to Users.


1 Answers

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.

like image 100
mythz Avatar answered Oct 02 '22 18:10

mythz