-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add endpoints to read, create, update and delete entity permissions #54
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM in principle, just a question wrt. migrations and some suggestions about exception handling
...n/java/de/terrestris/shogun/lib/controller/security/permission/BasePermissionController.java
Outdated
Show resolved
Hide resolved
...n/java/de/terrestris/shogun/lib/controller/security/permission/BasePermissionController.java
Show resolved
Hide resolved
...n/java/de/terrestris/shogun/lib/controller/security/permission/BasePermissionController.java
Outdated
Show resolved
Hide resolved
...n/java/de/terrestris/shogun/lib/controller/security/permission/BasePermissionController.java
Show resolved
Hide resolved
...n/java/de/terrestris/shogun/lib/controller/security/permission/BasePermissionController.java
Outdated
Show resolved
Hide resolved
f941cca
to
1ba671a
Compare
1ba671a
to
dc237af
Compare
dc237af
to
0b32973
Compare
bbcf211
to
e81f37a
Compare
todo list:
|
* remove unused basePermissionService methods * add todos for permission checks * reorganize imports
Now all (Group/Class)PermissionServices are annotated with security checks. One issue remains: Right now, we can't test permissions for permission objects. This is needed for example for the following method: @Override
@PreAuthorize("hasRole('ROLE_ADMIN') or hasPermission(#group, 'READ')")
@PostFilter("hasRole('ROLE_ADMIN') or hasPermission(filterObject, 'READ')")
// todo: in postfilter permission check: how to get either targetDomainType or entity from permission.entityId?
public List<GroupClassPermission> findFor(Group group) {
return super.findFor(group);
} I added a All methods which work like this are unused until now. So it might be enough for now to restrict them to users with role |
7d779ee
to
7b72a28
Compare
New changes since last review: https://github.com/terrestris/shogun/compare/8c3d20a..7b72a28ff7c2a3e7b2e17013d497d0ff9f66e22e @terrestris/devs Please review |
shogun-lib/src/main/java/de/terrestris/shogun/lib/security/access/BasePermissionEvaluator.java
Outdated
Show resolved
Hide resolved
… they will override existing permissions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some spaces on the Doc-strings seem to be off. I would suggest changes on them all, but there are too many. Anyway, it is just a minor issue. Otherwise It looks good to me
This initializes the
BasePermissionController
which adds all relevant CRUD endpoints to manage all kind permissions (UserInstancePermission
,UserClassPermission
,GroupInstancePermission
,GroupClassPermission
) on entity level:READ
@GetMapping("/{id}/permissions/class/group/{groupId}")
GroupClassPermission
for the givenGroup
and entity.@GetMapping("/{id}/permissions/class/user/{userId}")
UserClassPermission
for the givenUser
and entity.@GetMapping("/{id}/permissions/instance/group/{groupId}")
GroupInstancePermission
for the givenGroup
and entity.@GetMapping("/{id}/permissions/instance/user/{userId}")
UserInstancePermission
for the givenUser
and entity.@GetMapping("/{id}/permissions/class/group")
GroupClassPermission
for the given entity.@GetMapping("/{id}/permissions/class/user")
UserClassPermission
for the given entity.@GetMapping("/{id}/permissions/instance/group")
GroupInstancePermission
for the given entity.@GetMapping("/{id}/permissions/instance/user")
UserInstancePermission
for the given entity.CREATE/UPDATE
@PostMapping("/{id}/permissions/class/group/{groupId}")
GroupClassPermission
for the givenGroup
and entity (via the providedPermissionType
in the request body).@PostMapping("/{id}/permissions/class/user/{userId}")
UserClassPermission
for the givenGroup
and entity (via the providedPermissionType
in the request body).@PostMapping("/{id}/permissions/instance/group/{groupId}")
GroupInstancePermission
for the givenGroup
and entity (via the providedPermissionType
in the request body).@PostMapping("/{id}/permissions/instance/user/{userId}")
UserInstancePermission
for the givenGroup
and entity (via the providedPermissionType
in the request body).DELETE
@DeleteMapping("/{id}/permissions/class/group/{groupId}")
GroupClassPermission
for the givenGroup
and entity.@DeleteMapping("/{id}/permissions/class/user/{userId}")
UserClassPermission
for the givenUser
and entity.@DeleteMapping("/{id}/permissions/instance/group/{groupId}")
GroupInstancePermission
for the givenGroup
and entity.@DeleteMapping("/{id}/permissions/instance/user/{userId}")
UserInstancePermission
for the givenUser
and entity.@DeleteMapping("/{id}/permissions/class/group")
GroupClassPermission
for the given entity.@DeleteMapping("/{id}/permissions/class/user")
GroupClassPermission
for the given entity.@DeleteMapping("/{id}/permissions/instance/group")
GroupInstancePermission
for the given entity.@DeleteMapping("/{id}/permissions/instance/user")
UserInstancePermission
for the given entity.Breaking change:
The
permissions
field of theBasePermission
has been renamed topermission
.Please review @terrestris/devs.