Description
If an authorized object is sent to Spring Data, for example using CrudRepository#save
, the call fails since it tries to look up model metadata by the class name, a CGLIB name in this case.
Moreover, if an authorized object is sent to CrudRepository#save
(and the call succeeded), then the associated masks and other authorization handling would apply if its methods are called.
Consider the following sample controller method:
@PutMapping("/{id}")
public Message update(@PathVariable("id") Long id, @RequestBody String body) {
Message message = this.messageRepository.findById(id); // authorized, if using `@AuthorizeReturnObject`
// ...
// only authorized operations on the object
// ...
return this.messageRepository.save(message); // if still wrapped, then unwanted masking or other error handling could ensue when persisting
}
Because a proxied object could be used as a method parameter anywhere in the application, Security can't know on its own any circumstances where it should unwrap the object.
One way to address this could be for Spring Data to detect AuthorizationProxy
-implementing domain objects and unwrap them. The following sample illustrates the issue in its updateMessage
method.