You are tasked with implementing fine-grained security constraints on service methods in a Spring application. How would you leverage method security expressions to fulfill complex security requirements?
- Define custom security annotations
- Use method-level security annotations with SpEL expressions
- Rely solely on URL-based security configurations
- Implement a single global security rule
In Spring, method security expressions allow you to specify security constraints using SpEL (Spring Expression Language) within annotations like @PreAuthorize or @PostAuthorize. This enables fine-grained control over method-level security. Custom security annotations (Option 1) might be used in combination with method security expressions, but they are not a replacement. URL-based security (Option 3) and a single global security rule (Option 4) are not the preferred way to achieve fine-grained security.
Loading...
Related Quiz
- To customize the response body of a Spring Boot controller method, the @_____ annotation can be used.
- What is the significance of using the spring.profiles.active property in the application properties or YAML file in Spring Boot?
- In a microservices architecture using Spring Boot, how would you implement a shared cache to ensure that different services have access to the same cached data, maintaining consistency?
- In cases where a required dependency is not found, the @Autowired annotation will throw a _____.
- You need to inject a collection of beans in a certain order in your Spring Boot application. How would you ensure the correct order of beans in the injected collection?