Securing Spring Data methods
Where to find this section’s code
The source code used for this portion of the chapter can be found at https://github.com/PacktPublishing/Learning-Spring-Boot-3.0/tree/main/ch4-method-security.
So far, we’ve seen tactics to apply various security provisions based on the URL of the request. But Spring Security also comes with method-level security.
While it’s possible to simply apply these techniques to controller methods, service methods, and in fact, any Spring bean’s method calls, this may appear to be trading one solution for another.
Method-level security specializes in providing a finer-grained ability to lock things down.
Updating our model
Before we can delve into this, we need an update to our domain model used earlier in this chapter. As a reminder, we created a VideoEntity
class in the previous section that has an id
, name
, and description
field.
To really take advantage of method-level security...