Scrivio Interview library

Authorization

18 questions in 6 subtopics.

Request authorization

ConceptFoundations6 min read
In Spring Security 6 and later, how does requestMatchers("/orders/**") decide which kind of matcher to use, and why did removing trailing-slash matching in Spring Framework 6 matter for security?
DebuggingFoundations6 min read
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?)
DesignIntermediate6 min read
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?
LeadershipPrincipal6 min read
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

CodingFoundations6 min read
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.
DebuggingIntermediate6 min read
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.
LeadershipAdvanced6 min read
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

ConceptFoundations5 min read
What is the difference between a role and an authority in Spring Security? Why does hasRole("ADMIN") fail for a user whose JWT gives the authority "admin"?
DesignIntermediate5 min read
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?
ScenarioAdvanced5 min read
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

CodingIntermediate6 min read
Write a custom AuthorizationManager 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?
DesignAdvanced6 min read
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.
LeadershipPrincipal6 min read
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

ConceptFoundations6 min read
What does Spring Security's ACL module provide, and when would a PermissionEvaluator with hasPermission() be simpler?
ScenarioIntermediate6 min read
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?
LeadershipPrincipal6 min read
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

CodingFoundations6 min read
In a Thymeleaf page in a Spring Boot application, show an Admin menu only to users with ROLE_ADMIN and display the user's name. What dependency do you need, and why is hiding the link not enough?
ScenarioIntermediate6 min read
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?