SoftInstigate / restheart

Rapid API Development with MongoDB
https://restheart.org
GNU Affero General Public License v3.0
807 stars 171 forks source link

Need a way to surface user permissions for a db or collection to the client #156

Closed jbrownD3 closed 8 years ago

jbrownD3 commented 8 years ago

One thing I would like to do is to integrate my UI menus with the role permissions in RESTHeart. I was thinking that the API could expose an API allowing the client to query the permission set for a given DB or collection. Using this, I would hide/show different menu options in my UI. One part of that might be to store the role/predicate pairs in the db, though I think it could be done in a way that would work with SimpleAccessManager as well as any custom access manager. I guess the first question would be, what should the URL look like if we want to surface this query?

ujibang commented 8 years ago

the default configuration file binds an ApplicationHandler called GetRoleHandler

This allows the request GET /_logic/roles/<userid that returns (only if userid is the request authenticated user, otherwise you get 403 Forbidden):

{
    "_embedded": {},
    "_links": {
        "self": {
            "href": "/_logic/roles/user@si.com"
        }
    },
    "authenticated": true,
    "roles": [
        "USER"
    ]
}

Note the roles array. This gives back the roles of the authenticated user. You can use it to build your UI according to user's roles.

Documentation page reference is https://softinstigate.atlassian.net/wiki/x/JgDM

Does this fits your needs?

ujibang commented 8 years ago

closing now, if you need more support feel free to reopen