Who goes there? Authn & Authz | Suki

Who goes there? Authn & Authz

Introduction

Every day, we live a significant portion of our lives online. We shop, bank, work, and connect with others, all through digital applications. But how do these apps know it’s really you accessing your bank account? And once you’re in, how do they ensure you can’t see someone else’s private messages or financial data?

The goal of this post is to pull back the curtain on digital identity and access. We hope this article provides a deeper understanding of the key technologies that make modern, secure access possible.

Authentication and Authorisation

Before we dive deep, it’s crucial to understand the two foundational pillars of access control. They sound similar, but they do very different jobs.

Think about going to the airport to catch a flight. Your journey through security involves both authentication and authorization.

  1. Authentication: “Are you who you claim to be?”
    When you get to the security checkpoint, you hand over your boarding pass and your passport. The agent checks that the name on your ticket matches your ID and that your face matches the photo. You have just been authenticated. The system has verified your identity.

  2. Authorization: “What are you allowed to do?”
    Now that they know who you are, what does your boarding pass permit you to do? It authorizes you to go through security, proceed to a specific gate, and board a specific plane. It does not authorize you to walk into the cockpit or access the air traffic control tower. Your permissions are clearly defined.

In the digital world, it’s the exact same principle. Authentication confirms your identity; authorization determines your permissions.

Understanding the technology

Instead of just talking about theory, let’s walk through the process of developing a simple application from the ground up. As we consider the growth and evolution of applications, we’ll introduce core security concepts. We’ll also consider some real-world analogies to break everything down, demystifying ideas like SSO, OAuth 2.0, and JWTs along the way.

A simple Web Application

Analogy: The One-Story Corporate Office

Imagine a small, single-story corporate office where everyone enters through the front desk. When you arrive, you show your ID to the receptionist. Once verified, the receptionist makes an entry for you in the ledger, and you’re handed a visitor badge. For the rest of the day, you can move around the office freely by just flashing your badge to any security personnel. Everything — identity verification, badge issuance, and access checks — happens right at that front desk. It’s centralized, efficient, and works smoothly for a small office.

Application: A Monolith

Similar to the one-story office, our web application is a self-contained unit where the user-facing front end and the back-end logic all live together. We need to let users create an account and log in, and the most traditional way to do this is with a username and password.

How it works: Classic Username, Password, and Cookie

A user enters their username and password (think: showing your ID) into a login form. The server checks these credentials against a list of users stored in its database. If the credentials are correct, the server needs a way to remember that this user is logged in for future requests. It does this by creating a session (think: adding an entry in the ledger). Think of a session as a temporary file with a unique SessionID on the server that stores information about the logged-in user.

The server then gives the user’s browser a small piece of data called a cookie (think: visitor badge), which contains the unique SessionID.

From then on, for every request the user makes (like clicking on a new page), the browser automatically sends this cookie back to the server. The server uses the Session ID from the cookie to look up the user’s session data and confirm they are authenticated.

Username/Password Authentication Flow

For many projects, this is a great way to start. Its main benefit is simplicity. All the logic is in one place, making it straightforward to build, deploy, and maintain.

The Application Grows

Analogy: The Skyscraper Upgrade

The company grows into a massive skyscraper, with different departments spread across multiple floors. Suddenly, the single receptionist on the ground floor can’t manage access for everyone. Each floor has its own security desk.

Our system of a visitor badge issued by a receptionist at the ground floor gets overwhelmed and starts to fall through. Let’s dive a bit deep and try to understand our problems:

To fix the chaos of our uncoordinated office, we need to completely rethink our access system. Simple visitor badges issued at random desks won’t cut it anymore.

The Photo ID Badge and Keycard

We introduce a proper credentialing system, managed by a central security office. Here’s how it works:

Application: Microservice Architecture

Now let’s apply this analogy to our application. Our simple application is a hit. To handle the massive increase in traffic, we’ve broken our all-in-one monolith into smaller, independent parts. This is a microservices architecture (think: multiple floors). Instead of one giant server doing everything, we have separate services for user profiles, billing, comments, and so on.

The old username/password and session cookie method starts to break down in this new, distributed world:

It’s clear that to truly support our application’s growth, we need a better approach — one that is stateless, scalable, and designed for a distributed environment.

How it works: Token-Based Auth

Instead of relying on server-side session state, the user’s identity and permissions are securely encoded in tokens. So, when a user logs in, an IdP+Auth server (think: central security office) issues the application two types of tokens, often in the JSON Web Token (JWT) format.

These tokens are then included in subsequent requests, allowing services to independently validate the tokens and authorize actions.

This model is powered by two key standards:

OAuth 2.0 supports several authorization flows, each suited to different application types and trust levels. Common flows include:

The following diagram illustrates the Authorization Code Flow, which is the most commonly used and secure flow for user-facing applications.

Oauth 2.0 — Authorization Code Flow

How it works: JWT

Let’s take a deeper look into the internals of the token standard, i.e. JWT, that enables this entire mechanism. JSON Web Tokens, or JWTs, are a compact and verifiable way of transferring information between two parties.

A JWT consists of three parts, each encoded in Base64Url and separated by dots (.):

  1. Header:
    Contains metadata about the token, including the signing algorithm (e.g., HS256, RS256) and token type (JWT).
  2. Payload:
    Contains the claims — statements about an entity (usually the user) and additional data. Common claims include:
    • sub (subject): the user identifier
    • iss (issuer): the token issuer
    • exp (expiration time): token expiry timestamp
    • aud (audience): intended recipients
    • Custom claims such as user roles or permissions
  3. Note that anyone can see these fields, so the payload should not contain sensitive information.
  4. Signature:
    Created by signing the encoded header and payload with a secret key or private key. The signature ensures the token’s integrity and authenticity.

The signature can be validated with the help of the public key of the identity provider accessible via the JWKS endpoint.

The following sequence diagram shows how JWT enables secure and independent validation at each resource server.

JWT Validation

So by leveraging an auth server to issue independently verifiable JWT tokens, we solve the problems with our microservice architecture as follows:

Thus, this token-based approach provides a scalable, secure, and flexible auth for our growing application needs.

One Login to Rule Them All: Single Sign-On (SSO)

Analogy: Access to a cafeteria building

Imagine now the company adds a separate cafeteria located alongside the main office building. Right now, accessing the cafeteria requires a different badge and key card — an extra step that feels inconvenient and unnecessary.

Now, picture a simpler system: your office badge and key card issued by the central security office work at both buildings. No need to verify your identity all over again. Just one badge, one key card, and seamless access across multiple locations.

Application: Family of apps

Similar to our office expansion analogy, our application (think: main office) too is now part of a bigger family of apps. Maybe we’ve built a separate “Admin Panel” (think: cafeteria). It would be annoying for our users to have to log in to each of these applications separately. We want them to log in once and have access to everything.

How it works: Single Sign-On

Think of it like logging into Gmail: once you’re signed in, you don’t need to log in separately to other Google apps like Drive or Calendar. The Identity Provider manages a single authenticated session, enabling seamless access across multiple applications without repeated logins. Here’s how it works:

Single Sign On

The result is a frictionless experience. The user authenticates once and gains access to a whole suite of applications without ever having to re-enter their credentials.

Trusting Others — Federated Identity

Analogy: The Trusted Contractor Agreement

Our company has a partnership with a major, trusted vendor — let’s say Microsoft. They’ve established a formal agreement to recognise each other’s credentials.

One day, a contractor from Microsoft arrives at your office. Instead of going through the usual ID verification process, they head to a special security desk and present their official Microsoft badge. Your company’s security team doesn’t personally know this contractor, but they trust Microsoft.

Thanks to the pre-arranged agreement, the badge is verified as legitimate, and the contractor is issued a temporary visitor keycard for access. Your company didn’t issue the original badge — it simply trusted the credentials from a known and trusted partner.

Application: Login without creating a username and password

Our app is a huge success, but we’ve noticed something: many potential users drop off at the sign-up page. They don’t want to create and remember another username and password. How can we make it easier for them by letting them use an account they already have and trust?

How it works: Federated Identity

Federated Identity is essentially SSO across organizations. It lets users authenticate with one trusted IdP (think: the vendor), like Azure AD, and use that authentication to access applications managed by another IdP (think: our office), like Okta, often referred to as a service provider. Instead of managing separate credentials for each system, users rely on their home organization’s credentials, while your application trusts the external IdP’s authentication.

Note: A trust must be established beforehand between your organization’s IdP and the third party’s IdP.

The following sequence diagram showcases how Federated SSO is used:

Federated SSO

One Token Doesn’t Fit All — Token Exchange

Analogy: The Temporary Access Code for Sensitive Areas

Inside the main office, there’s a high-security room managed by a separate internal team with stricter rules. An employee wants to enter the high security room, but their regular keycard isn’t authorized for direct access. So, they swipe their keycard at a secure terminal outside the room. The terminal contacts the Central Security Office and says, “This verified employee needs temporary access to the server room”. The terminal checks the employee’s credentials and issues a one-time , short-lived access code — a kind of special pass that works only for that server room and only for a limited time.

Application: Limited temporary access

One of our services, Service A (think: main office), often needs to call another, more specialised service, Service B (think: high security room) , on the user’s behalf to complete a task. For security, we don’t want the second service to accept the same general-purpose token (regular keycard) as the first. We need a way to trade a broad token for a very specific token (think: short-lived access code). This is the Token Exchange pattern.

How it works: Token Exchange

Token Exchange (https://datatracker.ietf.org/doc/html/rfc8693) is an OAuth 2.0 extension that enables a client or service to exchange an existing token called the subject token for a new token with different scopes, audiences, or privileges. This exchange happens securely at the authorization server’s token endpoint without requiring the user to re-authenticate.

In practice, Service A sends its current access token to the authorization server, requesting a new token scoped specifically for Service B. The authorization server validates the original token, applies security policies, and issues a new, limited-scope token tailored for Service B.

Token Exchange supports many complex scenarios:

Conclusion

From session cookies in simple applications to JWTs in distributed systems, identity and access are the invisible gates that shape every digital experience. What started as a username and password has evolved into a complex, resilient, and scalable dance of tokens, standards, and trust.

So the next time you’re magically signed into five apps with a single login, or wonder how third-party apps get just the right access — not too much, not too little — you’ll know: it’s not magic. It’s architecture.

Who Goes There? Now You Know!

Harish Thuwal