ADR-01
Store as few permission records as possible
- Context
- The data runs to millions of records, and each one has its own level of access.
- Decision
- Of the two or three models we considered, we chose the one that reduces the number of records stored.
Finance
Combined all permissions from different application into one source of truth
Authorization should be predictable, secure, auditable, and extensible: define clear precedence, separate scope, treat Deny explicitly, handle overrides, filter at the right level, centralize logic, and make decisions explainable.
Permission call time vs the previous implementations
Roughly 4× faster
Source: Informal timing: both endpoints called in a parallel loop in .NET and the timings compared. Not a formal benchmark.
Each service had their own implementation and the permissions are not judgeable and unable to track how the restricted data got exposed.
The client is a financial risk platform, described generically here. Five applications were involved, including a calculation engine and an operations application. A client’s access is granted at eight levels: Base Profile (the default permissions), Portfolio (a collection of funds), Fund, Client Fund, Stat (a specific calculation), Category (for example country or sector), User Group and User.
Permissions applied at several levels at once, from a default Base Profile up to individual users. Stat and Category permissions followed a waterfall across those levels. Report-date permissions for daily and monthly dates applied to both funds and portfolios. The data ran to millions of records.
I was the application architect on a team of three. Delivery ran in phases, and each phase added to or changed the requirements. That pushed the design toward one generic permission implementation, carried through to data-level security, in six months.
A request is checked from the most specific level down. 1: if a user-level permission is set, it is used and overrides every other level. 2: if a user group permission is set, it is used and overrides every level below it. 3: if the category is not permitted, access is denied. 4: if the stat is not permitted, access is denied. 5: the Client Fund and Fund levels are compared and the least permissive wins, so a No at either denies access. 6: if a Fund level exists it takes precedence over Portfolio, and the Portfolio level is ignored. 7: if a Portfolio permission is set and nothing further overrides it, all the portfolio’s data is returned. 8: otherwise the Base Profile default permissions apply. The data within the allowed scope is then returned.
ADR-01
ADR-02
Rejected options
ADR-03
Check permissions at eight points in a report’s life
GainedAccess stays correct even if a permission changes while the report is in progress
Gave upEight permission calls for every report
For a single report the permission API is called eight times:
Permissions can change at any time, so each stage checks again instead of trusting an earlier answer.
Compliance required that an endpoint call returns the necessary data, and only the data the client has access to. Checking again at the calculation engine and on the finished response keeps a change made mid-report from being missed.
To compare the new implementation with the previous ones, we called both endpoints in a parallel loop in .NET and compared the timings. The new one came out roughly four times faster. That was an informal timing comparison, not a formal benchmark.
The Permission UI was built with generics, so it is type-safe and needs no casting.
The waterfall logic is in SQL Server, so a change to a rule is one modification and does not require deploying each consuming service.
Designing the permission model highlighted that authorization is more than a simple Allow/Deny check. The key lessons were: