Skip to content
Mathi Sudhanan

Finance

Permission API

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.

Role
Application Architect
Team
3 people
Duration
6 months
  • .NET Core
  • Web API
  • SQL Server
  • React
  • TypeScript

Measured outcomes

  • 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.

Problem

Each service had their own implementation and the permissions are not judgeable and unable to track how the restricted data got exposed.

Context

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.

Constraints

  • Five existing applications, including the calculation engine, had to adopt it
  • Six months to deliver, together with the Permission UI
  • Compliance: an endpoint call returns the necessary data, and only the data the client has access to
  • Permissions came from several microservices, each handling them in its own way
  • Every phase added to or changed the requirements

Leadership

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.

Architecture

Flowchart of the permission evaluation order. A user-level permission, if set, is used and overrides every other level. Then a user group permission overrides the levels below it. Category and stat must each be allowed. Client Fund and Fund take the least permissive answer, Fund takes precedence over Portfolio, and a Portfolio permission returns all its data, with the Base Profile as the default.
Permission API permission flow
Text description of the diagram

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.

Technology decisions

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.

ADR-02

Keep the waterfall permission logic in SQL Server

Context
Requirements kept changing as the work moved through the different applications, and the team’s strongest skills were in SQL Server.
Decision
The waterfall logic lives in SQL Server. A modification is made in one place, and the services that use it need no deployment for each change.

Rejected options

  • A rule engine — Development was fast-paced, the developers were more skilled in SQL Server, and the requirements kept changing.

ADR-03

Build the Permission UI with generics

Context
The UI loads Portfolio, Fund, Stat and Category selections, each from the permission API.
Decision
Generic components keep the UI type-safe and avoid casting.

Trade-offs

  • 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

Data flow

For a single report the permission API is called eight times:

  1. When the Portfolio dropdown loads in the UI.
  2. When the Fund dropdown loads.
  3. When the Stat dropdown loads.
  4. When the Category dropdown loads.
  5. When the selection is saved.
  6. When the request enters the calculation engine.
  7. After the calculation finishes.
  8. After the response is formed.

Permissions can change at any time, so each stage checks again instead of trusting an earlier answer.

Security

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.

Performance

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.

Deployment

The waterfall logic is in SQL Server, so a change to a rule is one modification and does not require deploying each consuming service.

Lessons learned

Designing the permission model highlighted that authorization is more than a simple Allow/Deny check. The key lessons were:

  • Define clear precedence — more specific permissions take precedence, with User-level permissions overriding all.
  • Separate scope from permission — Portfolio, Hedge Fund, Fund, Stat, and Category permissions must be evaluated independently.
  • Treat Deny as explicit — conflicting permissions should resolve safely to prevent unintended data exposure.
  • Handle exceptions deliberately — User-level overrides should be explicit and auditable.
  • Filter data at the right level — Category restrictions should remove unauthorized data rather than unnecessarily blocking the entire request.
  • Centralize authorization logic — a single policy evaluation layer improves consistency, testing, security, and maintainability.
  • Make decisions explainable — every authorization decision should be traceable to the permission and precedence rule that produced it.