Foundations

Authentication & Authorization

Foundational

Authentication asks "who are you?". Authorization asks "what are you allowed to do?". They are different questions, and mixing them up is where access-control bugs grow. Establish identity once, from a validated source. Then check permission on every action — server-side, default-deny, and scoped to the tenant.

Authentication must be strict (a fully validated token or session, strong credentials, MFA). Authorization must be everywhere (every protected operation re-checks that this identity may perform this action on this resource). The most common failures are not broken crypto. They are a route that forgot to check, a permission taken from client input, or an object reference that is not scoped to the caller.

In a multi-tenant AML platform, authorization also carries the tenant dimension: a valid user of tenant A must never reach tenant B's data, and a user must never raise their own privileges. The Finperiti findings — a fully unauthenticated controller and a shared HS256 secret — show both halves failing: missing authentication, and an identity mechanism that could not be trusted.

Authenticate rigorously

Authorize every action

Authenticated but not authorised [Authorize]
public Customer Get(Guid id) =>
db.QuerySingle("SELECT * FROM Customers WHERE Id=@id", new { id });

The caller is logged in, but any logged-in user can read any customer of any tenant by guessing or listing ids. This is authentication without object-level, tenant-scoped authorisation.

Authorise the specific resource [Authorize]
public Customer Get(Guid id) =>
db.QuerySingleOrDefault(
"SELECT * FROM Customers WHERE Id=@id AND TenantId=@t",
new { id, t = User.GetTenantId() }) ?? throw new NotFound();

The tenant comes from the validated token, the row can only belong to the caller's tenant, and a miss looks like 'not found' rather than revealing that the record exists.

Self-review checklist

Why it matters: Broken access control is consistently the most common serious web vulnerability. In a multi-tenant financial platform it means one customer reading or moving another's money and data. Strict authentication, plus authorization that is everywhere, tenant-scoped, and default-deny, is the core control everything else depends on.