I am leveraging Spring Roo to create a web application where users access and create information accessible only by their 'Company', defined through implementing UserDetails.
@RooJavaBean
@RooToString
@RooJpaActiveRecord(sequenceName = "PORTALUSER_SEQ", finders = {"findPortalUsersByUseame", "findPortalUsersByCompany" })
public class PortalUser implements UserDetails {
@ManyToOne
@JoinColumn(nullable = false)
private Company company;
}
With the default aj, any authenticated user with read/write access can perform all CRUD operations. The issue occurs when an authenticated user performs an operation outside of their Company by using an id they should not have access to.
Company Foo could very easily delete, view, etc a ticket from Bar, buy directly accessing the Ticket id.
@RequestMapping(value = "/{id}", produces = "text/html")
public String TicketController.show(@PathVariable("id") Long id, Model uiModel) {
...
}
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String TicketController.delete(@PathVariable("id") Long id, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel){
...
}
@RequestMapping(method = RequestMethod.GET, produces = "text/html")
public String TicketController.listDatatables(Model uiModel, HttpServletRequest request) {
...
}
Without modifying each method in every controller, is there a way to ensure that users caot access data that is outside of the intended scope?
It seems that a custom Filter, could be of use, and I am able to filter out Companies on GET's by cloning and modifying the parameter map, but I haven't found a way solution would work for all methods.
