Authorization
18 questions in 6 subtopics.
Request authorization
In Spring Security 6 and later, how doesrequestMatchers("/orders/**") decide which kind of matcher to use, and why did removing trailing-slash matching in Spring Framework 6 matter for security?This configuration lets everyone access /admin/users: http.authorizeHttpRequests(a -> a.anyRequest().authenticated().requestMatchers("/admin/**").hasRole("ADMIN")) Explain the problem. (In recent versions this throws at startup; why?)Design authorization for a multi-tenant REST API where users can only access resources of their tenant and some endpoints need specific scopes from the access token. Where would you put which checks?Regulators and auditors expect least-privilege access and regular access certification for all systems. How would you build an authorization governance programme across hundreds of applications?Method security
Enable method security in a Spring Boot 3 or 4 service and write a method that only allows a user to read their own orders unless they have the role SUPPORT. Explain when the expression is evaluated.A@PreAuthorize("hasRole('ADMIN')") check on a service method is not enforced: any user can call it through a controller. List the causes you would check.Your teams mix URL-based rules, @PreAuthorize annotations and manual checks in code, and audits cannot tell which endpoints are protected by what. What authorization standards would you set?Roles vs authorities
What is the difference between a role and an authority in Spring Security? Why doeshasRole("ADMIN") fail for a user whose JWT gives the authority "admin"?Your application has roles ADMIN, MANAGER and USER where each higher role includes the lower ones' permissions, and teams keep writing hasAnyRole("ADMIN","MANAGER","USER"). How would you model this better?Your identity provider now has over 3,000 roles across applications, many unused or overlapping, and access reviews take weeks. How would you lead a clean-up and a better authorization model?Custom authorization managers
Write a customAuthorizationManager that allows access to /reports/** only during business hours and only for users with authority report:read. How do you plug it into request authorization?Several services need the same complex authorization rules (attribute-based, depending on user department, data classification and region). Compare embedding rules in each service with a central policy engine such as OPA or Cedar.Should your company build a central authorization service (for example relationship-based authorization in the style of Google Zanzibar) used by all products, or keep authorization inside each application? Lay out how you would decide.Domain object security
What does Spring Security's ACL module provide, and when would aPermissionEvaluator with hasPermission() be simpler?A penetration test shows that changing the id in GET /api/invoices/123 returns another customer's invoice (IDOR). How do you fix it in this service and prevent it in others?Broken access control remains the most common finding in your company's security reviews. What long-term programme would you run to reduce it?View-layer security tags
In a Thymeleaf page in a Spring Boot application, show an Admin menu only to users withROLE_ADMIN and display the user's name. What dependency do you need, and why is hiding the link not enough?A team moved from server-rendered Thymeleaf pages using sec:authorize to a React single-page application. How should the frontend decide which buttons to show, and what are the risks?No question matches these choices.