Authentication vs Authorization

Security:FoundationConcept:AuthN vs AuthZ

Authentication and authorization solve two different problems.

Authentication answers: "Who is making this request?"

Authorization answers: "Is this authenticated user allowed to perform this operation?"

For example, a GraphQL request may contain an access token. The server validates the token and identifies the user as user-42. That is authentication.

The server then checks whether user-42 is allowed to update order order-100. That is authorization.

A useful request flow is:

Request
  ↓
Extract credentials
  ↓
Authenticate identity
  ↓
Create GraphQL context
  ↓
Execute operation
  ↓
Authorize requested action
  ↓
Business logic
  ↓
Data source

Do not confuse authentication with authorization. A successfully authenticated user does not automatically have permission to perform every operation.

For example, an application may have these users:

  • alice — regular customer
  • bob — support agent
  • carol — administrator

All three may authenticate successfully, but their permissions can be different.

GraphQL itself does not prescribe JWT, sessions, OAuth, cookies, or any particular authentication mechanism. Those are application and infrastructure decisions.

Two Security Questions
Authentication: Who are you?
Establishes the identity associated with a request.
Authorization: What are you allowed to do?
Determines whether the authenticated identity can access a resource or perform an operation.
Authentication and Authorization Flow
Key Takeaways
  • Authentication establishes identity.
  • Authorization determines permissions.
  • GraphQL does not prescribe a specific authentication mechanism.
  • Authentication success does not imply authorization success.
Knowledge Check

A user successfully presents a valid JWT but is not allowed to delete another user's account. Which security concern prevents the operation?