Quick revision
The short answer
I would start with data: analyse role assignments and usage logs to find roles that nobody uses, roles nobody holds and roles that grant the same access under different names. Then move applications to check permissions mapped from a much smaller set of business roles, with each application owning its role-to-permission mapping in one place. Roles are removed in stages with owner sign-off while we watch 403 errors, and periodic access reviews are automated so the model stays small.
What to remember
In this answer, we led a role clean-up with data first, finding unassigned, unused and duplicate roles from assignments and usage logs. We moved to a smaller model where code checks permissions and each application owns the mapping from a short list of business roles, removed roles in stages with owner sign-off, suspension and 403 monitoring, and kept the model small with ownership rules, automated reviews and trend reporting.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I would start with data: analyse role assignments and usage logs to find roles that nobody uses, roles nobody holds and roles that grant the same access under different names. Then move applications to check permissions mapped from a much smaller set of business roles, with each application owning its role-to-permission mapping in one place. Roles are removed in stages with owner sign-off while we watch 403 errors, and periodic access reviews are automated so the model stays small.
Why this question is asked
Role explosion is what happens when every access request is answered by creating a new role. After a few years, nobody knows what Finance_Approver_EU_2 grants, reviewers approve access they cannot understand, and audits take weeks. Interviewers ask this scenario question at senior levels to see whether we can lead a clean-up that removes real risk without breaking people's work. In this answer, we will see how roles multiply, find the waste with data, design a smaller model, remove roles safely in stages and keep the model small afterwards.
1How 3,000 Roles Happen
Roles multiply for understandable reasons. A team needs slightly different access, and creating a new role is faster than understanding the old one. Roles are copied per region or per project. Applications are retired but their roles remain. Each role was a reasonable decision at the time; together they make access impossible to reason about.
The cost is concrete. If a reviewer must certify 40 roles per person, each with a cryptic name, the review either takes weeks or becomes a rubber stamp. Both outcomes fail the auditor's real question, which is whether access matches need.
2Step One: Measure Before Changing Anything
We export three data sets: role definitions with their owning application, assignments of roles to people and groups, and usage evidence, such as authorization logs or the authorities that appeared in successful requests over the last 180 days. A few queries then sort the 3,000 roles into buckets.
The numbers in the comments are typical of what such an analysis finds: a large share of roles is unassigned, unused or duplicated. Notice that unused does not mean useless: some roles exist for rare events such as year-end close or disaster recovery. So the analysis produces candidates, not decisions, and owners decide.
3Step Two: A Smaller Model Built on Permissions
Cleaning up without changing the model just grows the list again. The model we move to separates two ideas. Applications check permissions, fine-grained names for actions, such as invoice:approve or report:read. People receive business roles that match jobs, such as Accounts Payable Clerk, and each application maps business roles to its own permissions in one place it owns.
- Personjoins, moves, leaves through HR
- Business role in the identity providerabout 150, named after jobs
- Application mapping, owned per appbusiness role -> permissions
- Permission check in code
hasAuthority('invoice:approve')
4 layers, from the top down. Step through them one at a time.
Code changes only when actions change; job changes touch only the mapping.
The identity provider then holds a short list of business roles, perhaps 100 to 200 for a large company, instead of 3,000 technical ones. In a Spring application, the mapping is applied when the token is converted to an Authentication, so controllers and services see permissions and never need to know role names.
4Step Three: Remove in Stages, Watching 403s
Removing access is where clean-ups hurt people, so we stage it. First, we remove roles with no assignments, which carries almost no risk. Second, for unused assigned roles, we notify holders and owners and give two weeks to object. Third, we disable rather than delete: the role stays defined but its assignments are suspended, so restoring it takes seconds. Fourth, after a quiet period of 30 to 60 days, we delete it.
During each stage we watch the rate of 403 responses per application and the volume of access requests. A spike tells us we removed something people needed, and we can restore it before it becomes an outage. Merged duplicates follow the same path: assign the surviving role, confirm in logs that it is used, then suspend the duplicate.
- Any assignments?YesNotify holders and ownerNoDelete now
- Owner signs off?two week windowYesSuspend assignmentsNoKeep, record reason
- 403 spike or requests?watch 30 to 60 daysYesRestore and reviewNoDelete the role
3 steps in order. Play them, or step through them one at a time.
5Step Four: Keeping It Small
Without guard rails, roles grow back within two years. So we change the process as well. New roles require an owner, a description of the job they serve and a check that no existing role grants the same permissions. Every role has an expiry review date. Access reviews are automated: managers receive their reports' business roles quarterly, with usage shown next to each line and removal as the default when unconfirmed, and a monthly job flags roles with no use in 180 days.
Finally, we report the trend: role count, roles without owners, average roles per person and review completion time. A dashboard that shows 3,000 dropping to 400 and review time dropping from weeks to days is what keeps leadership funding the work, and it is evidence the auditors value.
6Follow-up questions
How do you convince application teams to switch to permission checks?
Show them the cost they already pay: access tickets, review effort and code changes for every role tweak. Then make it cheap with a shared library that maps roles to permissions in Spring, and migrate one willing team first so others see a working example.
What if usage logs are not available for some applications?
Start logging the authorities used in authorization decisions now, and use assignment data and owner interviews in the meantime. For applications that cannot log, treat their roles conservatively: suspend rather than delete, with a longer quiet period.
Should business roles come from the HR job code automatically?
As a baseline, yes, for birthright access that everyone in a job needs. Exceptions are granted through requests with approval and expiry, so they show up in reviews instead of becoming new permanent roles.
7Conclusion
In this answer, we led a role clean-up with data first, finding unassigned, unused and duplicate roles from assignments and usage logs. We moved to a smaller model where code checks permissions and each application owns the mapping from a short list of business roles, removed roles in stages with owner sign-off, suspension and 403 monitoring, and kept the model small with ownership rules, automated reviews and trend reporting.
Open with
I would start with data rather than opinions. Export role definitions, assignments and usage from authorization logs over the last 180 days, and sort roles into unassigned, assigned but unused, and duplicates that grant the same permissions.
Then, if they want more
In most organisations that already covers more than half of them. In parallel I would fix the model, because otherwise it grows back: applications check permissions like invoice:approve in code, people get a small set of business roles that match jobs, and each application owns one mapping from business roles to its permissions, applied when the token becomes an Authentication.
Removal would be staged: delete unassigned roles first, then notify holders and owners of unused ones, suspend assignments instead of deleting so we can restore quickly, watch 403 rates and access requests per application for 30 to 60 days, and only then delete. Merges follow the same path.
To keep it small, new roles need an owner, a job description and a duplicate check, reviews are automated quarterly with usage data and removal by default, and unused roles are flagged monthly. I would report role count, ownerless roles and review time to leadership so the progress stays visible.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Security reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Your identity provider now has over 3,000 roles across applications, many unused or...": https://scrivio-interview-library.netlify.app/spring-boot/authorization/79a9e1d91f/