DEV Community

tumberger for Kontext

Posted on • Originally published at kontext.security on

Authentication vs Authorization: What's the Difference?

Authentication verifies identity. Authorization decides access.

That is the shortest useful answer to authentication vs authorization. Authentication answers, "Who or what is making this request?" Authorization answers, "What is that verified identity allowed to do?"

The difference sounds small until something goes wrong. A user can be correctly authenticated and still be blocked from deleting a database. A service can present a valid certificate and still be denied access to a production secret. An AI agent can hold a valid token and still be prevented from exporting every customer record. Authentication proves identity. Authorization limits action.

Authentication vs authorization: quick comparison

Most systems need both. Authentication without authorization is a front door with no rooms inside. Authorization without authentication has no trustworthy subject to evaluate.

What is authentication?

Authentication is the process of proving that an identity is real enough to trust for the next step. The identity may belong to a person, device, workload, service account, API client, or AI agent runtime.

Human authentication usually uses one or more factors:

  • something you know, such as a password
  • something you have, such as a passkey, hardware security key, or authenticator app
  • something you are, such as a fingerprint or face scan

Non-human authentication uses different evidence. A workload might authenticate with a signed JWT, a short-lived cloud identity token, a certificate in a mutual TLS handshake, or a workload identity issued by an identity provider. An API client might use a client assertion. A device might use a certificate bound to hardware.

Once authentication succeeds, the system has a subject it can reason about: this user, this service, this device, this agent. That subject still should not receive blanket access. It has only cleared the identity check.

What is authorization?

Authorization is the process of deciding what a verified identity may access or do. It turns identity into a permission decision.

A simple authorization decision might ask whether a user has the admin role. A better decision asks more context:

  • Which resource is being accessed?
  • Is the action read, write, delete, export, invite, deploy, or approve?
  • Is the resource owned by the same tenant, user, project, or organization?
  • Is the request coming from an expected device, location, session, or workload?
  • Is the requested action consistent with the current task?
  • Does policy require approval, step-up authentication, or a narrower credential?

Authorization models vary. RBAC grants access by role. ABAC evaluates attributes such as department, sensitivity, device posture, environment, or request time. ReBAC evaluates relationships, such as whether a user owns a document, belongs to a project, or manages a team. Policy-as-code systems express these rules in versioned, testable policy.

For AI agents, authorization needs to be even more specific. A valid agent credential should not mean "do anything this token allows forever." It should mean "ask for permission at the moment of action."

Which comes first?

Authentication usually comes first. A system needs to know the subject before it can evaluate what that subject may do.

The sequence looks like this:

  1. The user, workload, or agent presents credentials.
  2. The identity provider or authentication layer verifies the credentials.
  3. The system establishes an identity, session, token, or workload principal.
  4. The authorization layer evaluates whether the requested action is allowed.
  5. The application, API, gateway, or tool enforces the decision.

That sequence is easy to understand for a web app login. It is harder for agents because there may be many authorization checks after the first login. An agent might authenticate once, then make dozens of tool calls across GitHub, Slack, Salesforce, cloud APIs, and internal systems. Each consequential action needs its own authorization decision.

OAuth vs OpenID Connect

OAuth 2.0 and OpenID Connect are often where authentication and authorization get confused.

OAuth 2.0 is primarily an authorization framework. It lets a client obtain an access token for a protected resource, often with delegated user consent. In plain terms: OAuth helps answer, "Can this client access this resource with these scopes?"

OpenID Connect adds an identity layer on top of OAuth 2.0. It introduces ID tokens and standardized identity claims so clients can authenticate users. In plain terms: OIDC helps answer, "Who signed in?"

This is why "Sign in with Google" can involve both:

  • OpenID Connect authenticates the user and tells the app who signed in.
  • OAuth 2.0 authorizes access to an API, such as a calendar, email, or profile resource.

The distinction matters in security reviews. An ID token is not a general API access token. An access token is not proof that every future action is appropriate. Token type, audience, scope, subject, issuer, expiry, and resource server validation all matter.

Common examples

Authentication examples:

  • A user unlocks a laptop with a passkey.
  • An employee signs in with MFA through an identity provider.
  • A service authenticates to another service with mTLS.
  • A workload receives a cloud identity token.
  • An API client signs a token request with a private key.

Authorization examples:

  • A user can read a support ticket but cannot issue a refund.
  • A developer can open a pull request but cannot merge to main.
  • A service can read one secret but cannot list every secret in the vault.
  • An agent can draft a Slack message but needs approval before sending it externally.
  • A runtime policy allows a read action but denies bulk export.

The simplest way to remember the difference: authentication gets you recognized; authorization decides what happens next.

Why the distinction matters for AI agents

AI agents make the old "login then trust" pattern brittle. They choose tools dynamically. They read untrusted context. They chain actions across systems. They may operate for minutes or hours after the human has stopped watching.

That creates a dangerous gap: the agent may be authenticated, and the downstream API may accept its token, but the current action may still be wrong.

Example:

  1. A user asks an agent to investigate one customer renewal.
  2. The agent authenticates through a connected CRM integration.
  3. A prompt injection hidden in a ticket tells the agent to export all accounts.
  4. The CRM sees a valid token with broad read access.
  5. Without runtime authorization, the export may proceed.

Nothing in that failure requires a fake identity. The credential can be valid. The user can be real. The agent can be non-malicious. The authorization failure is that the current action was outside the user's task and risk boundary.

This is why AI agent security needs more than authentication. It needs runtime authorization: a policy decision immediately before sensitive tool calls, credential requests, data access, sends, deletes, exports, merges, or workflow changes.

Authentication vs authorization for non-human identities

Non-human identities now include service accounts, CI/CD jobs, microservices, serverless functions, devices, bots, MCP clients, and AI agents. These identities often outnumber human users, and they often hold powerful credentials.

The same AuthN/AuthZ split applies:

  • Authentication proves which workload, service, agent, or device is calling.
  • Authorization decides whether that workload, service, agent, or device may perform this action.

The weak pattern is to issue a long-lived secret and treat possession of that secret as permission. That turns authentication material into an authorization shortcut. If the key leaks, or if an agent is manipulated into using it badly, the downstream system has little context to make a better decision.

A stronger pattern is:

  1. Authenticate the workload or agent.
  2. Bind the request to a user, tenant, task, session, and tool.
  3. Evaluate policy for the specific action and resource.
  4. Issue a short-lived, scoped credential only when policy allows it.
  5. Log the decision and credential scope for audit.

This reduces excessive agency because the agent receives only the access needed for the current operation.

Runtime authorization: where Kontext fits

Traditional IAM answers important questions: who signed in, which groups they belong to, which applications they can access, and which broad roles they hold. That remains necessary.

Kontext focuses on the next layer: what the agent is about to do right now.

A runtime authorization decision can include:

  • the authenticated human or workload identity
  • the agent or MCP client identity
  • the declared task
  • the tool being called
  • the action type, such as read, write, delete, export, send, approve, or deploy
  • the resource and tenant boundary
  • the requested credential scope
  • recent session behavior
  • policy requirements for approval, narrowing, denial, or audit

This is the practical difference between authentication and authorization in agent systems. Authentication tells you which agent or user is present. Runtime authorization decides whether the next action should run.

For a deeper implementation model, see AI agent runtime authorization, tool invocation privilege boundaries, and securing LLM tool use with runtime policies.

Common misconceptions

"If the user is authenticated, the action is safe"

No. Authentication only verifies identity. A real user can be compromised, over-permissioned, mistaken, or tricked by an agent workflow. Authorization must still decide whether the specific action is allowed.

"OAuth means authentication"

Not exactly. OAuth 2.0 is mainly for delegated authorization. OpenID Connect adds authentication on top of OAuth 2.0. Many products combine both in one login flow, which is why the distinction gets blurred.

"Authorization is just roles"

Roles are one input. Modern authorization also uses resource ownership, relationship graphs, attributes, scopes, sensitivity labels, session context, device posture, and risk signals. For agents, it should also include tool, task, action, and parameter context.

"Machine identities only need secrets"

Secrets authenticate callers. They do not define safe behavior. Machines, services, and AI agents need authorization policies that limit what each credential can do and when it can be used.

Short answer

Authentication verifies identity. Authorization determines access. Authentication asks who or what is making the request. Authorization asks whether that verified identity should be allowed to perform the requested action on the requested resource.

For normal applications, both controls protect users and systems. For AI agents, the authorization side needs to move closer to runtime because agents can make many sensitive decisions after the initial login. A valid credential is not the same thing as a valid action.

References

Top comments (0)