...
Code Block | ||
---|---|---|
| ||
public class Permission { String guid; // synthetic key makes create/add/update APIs easier String appId; // this always has to be part of the query String userId; String role; // "admin", "developer" String objectType; // "study", "organization", "app", "system" String objectId; // "studyId", "orgId", "appId" boolean transitive; // e.g. true if permission comes from org membership // Suggested toString() descriptor (implicitly scoped to an app): // "2rkp3nU7p8fjUTDVIgjT6T ∈ {organization:sage-bionetworks admin}" } |
The service (which we’ll probably access through along with a method to integrate with Spring Security, see below):
Code Block | ||
---|---|---|
| ||
interface PermissionsService { Set<Permission> getPermissionsForUser(String userId, boolean includeTransitive); Permission addPermission(Permission permission); void updatePermission(Permission permission); void removePermission(Permission permissions); Set<Permission> getPermissionsForObject(ObjectType type, String id); /** Spring security will need a very focused method to check, for a given user * *given user and a given object, does the user have any of the required roles to perform * roles *to perform the request. This method can fudge things like * app-scoped permissions, too. */ boolean isAuthorized(AccountId accountId, ObjectType type, String objectId, Role... roles); } |
There will be top-level APIs to change permissions. Creating an object that is managed with permissions will always make the creator the administrator of that object:
Method | URL | Description |
---|---|---|
GET | /v1/permissions/{userId} | Get all permissions for a user. |
GET | /v1/permissions/{objectType}/{objectId} | Get all permissions for an object like organization, study, or app. |
POST | /v1/permissions | Create a permission for a specific object and user. Caller must be an admin for the object. Returns the object with a GUID. |
POST | /v1/permissions/{guid} | Update a permission (caller must be an admin for the object). |
DELETE | /v1/permissions/{guid} | Remove a permission for an object (caller must be an admin for the object). |
...