API Security, Authentication and Authorization Questions
Controlling who can call an API, what they may do, and defending it against abuse. Covers the access-control mechanics: API keys, OAuth 2.0 flows, OpenID Connect, JWT issuance/validation, session vs. token auth, scopes/roles for fine-grained authorization, token lifetime and refresh, mutual TLS, and machine-to-machine vs. user-delegated access. Also covers the adversarial hardening view: input validation, injection and deserialization risks, broken object-level authorization (BOLA), mass assignment, secrets handling, and the OWASP API Security Top 10, plus securing data in transit, preventing enumeration/scraping, and testing APIs for vulnerabilities.
Design an audit logging and telemetry schema for APIs to support security investigations and compliance (e.g., GDPR, SOC2). Specify required log fields (principal, action, resource, timestamp, request/response metadata, trace-id), redaction rules, retention policies, storage backends, indexing strategies, sampling, and how to balance forensic needs with cost and privacy.
Sample Answer
Direct answer
An audit logging schema for API security investigations and compliance needs a small, consistent
set of required fields on every event (who did what, to what, and when, with enough correlation
context to reconstruct a request across services), a redaction policy that strips or masks
sensitive payload data before it is ever written to the log store, and a two-tier storage design:
a shorter-retention, fully indexed "hot" store for active investigation, and a cheaper, longer-
retention "cold" store for the multi-year retention many compliance regimes (SOC2, a common third-party audit standard for how a company handles customer data, and GDPR) actually
require.
Structured elaboration
Required log fields. At minimum, every audit event needs: principal (who or what made the
request: a user id, a service identity, or an API key id), action (what operation was
performed, ideally a stable, enumerable name rather than a raw HTTP method plus path), resource
(what was acted on, an object id or resource path), timestamp (in a single consistent timezone,
UTC, with enough precision to establish ordering), and trace_id (a correlation identifier that
ties this event to the same identifier used in distributed tracing, so a single user-visible
request can be reconstructed across every service it touched). Request/response metadata (source
IP, user agent, response status code, and which fields were affected on a write, not necessarily
their full before/after values) rounds this out without yet crossing into the redaction concerns
below.
Redaction rules. Decide, per field, whether it is safe to log at all, needs to log a masked
or hashed form (so investigators can still tell "these two events touched the same account
number" without the log storing the raw account number), or must never appear in the log under
any circumstance (a raw password, a full payment card number, an authentication token). This
decision has to be made at the schema level, before any log line is written, not left to
individual services to decide ad hoc, since an inconsistent policy across services is what turns
"we log for security investigations" into its own data-exposure incident.
Retention policies. Different investigation and compliance needs justify different retention
windows: an active-investigation window (commonly 30 to 90 days) needs to be fully indexed and
fast to query; a compliance-driven retention window (often measured in years, depending on the
framework and jurisdiction) can tolerate slower, cheaper retrieval, since it is accessed rarely,
typically only for an audit or a legal request.
Storage backends. A streaming ingestion layer (a message queue or log-streaming platform)
decouples "the API just emitted an audit event" from "the event is durably stored and queryable,"
which matters because audit logging must never become a synchronous dependency that can slow
down or fail the request it is auditing. From there, route to a hot, indexed store (built for the
security team's investigation queries) and a cold, cheap object-storage tier (built for
long-term, infrequent-access retention and legal hold).
Indexing strategies. Index the fields investigators actually query by: principal,
resource, trace_id, and timestamp range are the common ones; avoid indexing full free-text
payload fields by default, since that is expensive at volume and is exactly the kind of field
most likely to need redaction rather than indexing anyway.
Sampling. For extremely high-volume, low-sensitivity read traffic, full logging of every
single event may not be economically justified; a documented sampling policy (log 100% of
writes and authentication events, sample a smaller percentage of high-volume reads) is a
legitimate trade-off, as long as it is an explicit, reviewed decision rather than an
accidental byproduct of a storage cost optimization that nobody flagged as a compliance-relevant
change.
Balancing forensic needs with cost and privacy. More logged detail, retained longer, always
helps a future investigation; it also always costs more to store and increases the amount of
personal data the organization is responsible for protecting and eventually deleting under
frameworks like GDPR (General Data Protection Regulation, the EU's data-protection law), which
directly constrains how long personal data, including audit logs that contain it, can be
retained without a specific justified purpose. The schema's redaction rules and retention tiers
are the two levers that resolve this tension: log less of the truly sensitive data, and retain
the two tiers for different, explicitly justified lengths of time, rather than either
under-logging (a real investigation gap) or over-retaining raw sensitive data indefinitely (a
real compliance and breach-impact risk).
Worked example
graph LR
Req[API Request and Response] --> Cap[Capture: principal, action, resource, trace id]
Cap --> Red[Redaction Layer]
Red --> Buf[Streaming Buffer]
Buf --> Hot[Hot Store - indexed, 30 to 90 days]
Buf --> Cold[Cold Store - object storage, years]
Hot --> SIEM[SIEM and Investigation Queries]
Cold --> Compliance[Compliance and Legal Hold Export]
Sizing the hot tier with concrete numbers: an API sustaining roughly 10,000 requests/second, with
one structured audit log line per request averaging about 800 bytes (a realistic size for the
required fields above plus modest request metadata), produces:
raw throughput : 10,000 req/sec * 800 bytes = 8,000,000 bytes/sec = 8 MB/sec
raw daily volume : 8,000,000 bytes/sec * 86,400 sec/day ~= 691 GB/day
compressed daily : 691 GB / 5 (a typical ~5x text-log compression ratio) ~= 138 GB/day
90-day hot tier : 138 GB/day * 90 days ~= 12.4 TB
These are illustrative planning numbers, not a measured production figure, since they depend
entirely on the assumed request rate and per-line size; the point of walking through them is the
method (raw rate times record size, times the retention window, adjusted for compression), which
is exactly the calculation a real capacity-planning exercise would run against the actual
traffic and schema. At roughly 12.4 TB for a 90-day hot window, keeping the same three years of
data fully indexed would mean holding onto roughly 12x that volume in the expensive, indexed
tier, which is the concrete cost argument for a cheaper cold tier handling the years-long
compliance retention instead.
Trade-offs and pitfalls
- A synchronous, blocking audit-log write is a latency and availability risk on the request
path itself. The streaming-buffer design exists specifically so a slow or briefly unavailable
log backend degrades log durability (a small window of events might be delayed or, in a worst
case, lost) rather than degrading the API's own availability for the request being audited. - Redaction is a one-way decision once data has already been logged unredacted. If a field is
discovered to have been logged in raw form when it should have been redacted, remediation means
finding and scrubbing every copy across hot and cold storage, including backups, which is far
more expensive than getting the redaction rule right before the first log line was ever
written. - Common wrong turn: indexing everything "in case it's useful later." This inflates the hot
tier's cost roughly in proportion to how much gets indexed, without a matching increase in
investigative value, since most fields nobody ever actually queries by; index what
investigators demonstrably query, and keep the rest in the cheaper tier where it is still
retrievable, just not indexed. - Common wrong turn: one retention policy for all data. Treating a routine read event and an
authentication failure with the same retention and redaction rules ignores that they carry very
different forensic value and very different privacy sensitivity; tier both retention and
redaction by the event's actual investigative and privacy weight, not uniformly.
Walk me through how you'd build a scalable pipeline to detect API abuse (credential stuffing, scraping, fraud) across hundreds of services and millions of requests per minute. Include data collection and enrichment (geo, ASN, device fingerprint), real-time detection and scoring (streaming feature aggregation, ML models), alerting to SIEM/SOAR, automated blocking/lists and the feedback loop for model updates, while preserving low latency on request paths.
Sample Answer
Direct answer
At the scale described (hundreds of services, millions of requests per minute) the pipeline has
to split into a fast synchronous path that adds only a few milliseconds per request, and a
slower asynchronous path that does the expensive enrichment and model scoring off to the side
and feeds its verdicts back as a cache the fast path can check cheaply. You cannot run full
machine-learning scoring inline on every request at that volume without blowing the latency
budget, so the design's central decision is what stays synchronous (a cheap reputation lookup)
versus what happens asynchronously and only changes future requests (enrichment, scoring, model
updates).
Structured elaboration
Sizing the problem first. "Millions of requests per minute" is on the order of tens of
thousands of requests per second; for example 5,000,000 requests/minute is about 83,000
requests/second sustained. Any synchronous, per-request check has to fit inside a latency budget
of a few milliseconds at that rate, which rules out anything that calls out to a heavyweight
model or an external enrichment API inline.
Data collection and enrichment. Capture request metadata at the edge (source IP, user agent,
TLS fingerprint, authenticated identity if any) and enrich it: geolocation and ASN (autonomous
system number, which identifies the network/ISP a request came from) lookups from a local,
periodically-refreshed dataset rather than a live network call; device fingerprinting from
client-side signals where available. Do the enrichment lookups against an in-memory or
local-cache copy of the reference data, not a network round trip per request, since a network
call per request at 83,000 requests/second is its own outage risk.
Real-time detection and scoring. Split scoring into two tiers:
- A cheap, synchronous tier that checks a precomputed verdict (IP or identity already on a
blocklist or flagged as high-risk from a shared, low-latency cache) and applies simple rules
(velocity thresholds) that need no model inference. - An asynchronous tier that aggregates streaming features (request velocity per identity, ratio
of failed to successful auth attempts, geographic dispersion of a single credential's usage)
over sliding windows, and periodically runs those aggregated features through a scoring model.
The model's output updates the shared verdict cache that the synchronous tier reads, so the
request path never blocks on model inference; it only ever blocks on a cache read.
Alerting to SIEM/SOAR. Route confirmed and borderline detections to the security team's SIEM
(security information and event management system, which centralizes security logs for
investigation) and SOAR (security orchestration, automation and response, which can trigger
automated response playbooks) rather than only auto-blocking. High-confidence, high-severity
patterns can trigger automated blocking directly; medium-confidence patterns should raise an
alert for a human or a scripted playbook to act on, since automated blocking on a weak signal
risks blocking real users (a false positive that costs revenue and trust).
Automated blocking and the feedback loop. Blocking decisions (IP bans, credential lockouts,
CAPTCHA challenges) need to be revisable: log every automated action with the signal that caused
it, and feed confirmed false positives (a legitimate user who got blocked and later proved it,
for example by successfully completing account recovery) back into the model's training data or
into rule exceptions, so the system's precision improves rather than accumulating permanent
mistakes.
Preserving low latency on request paths. The single most important architectural rule is
that nothing on the synchronous request path may depend on the availability or latency of the
detection pipeline's slower components. If the verdict cache is unreachable, the request path
should fail open to "no additional friction" (log the miss, do not block), not fail closed to
"block everything," unless the product's risk tolerance explicitly demands the opposite for a
specific high-value action (initiating a payment, for example).
Worked example
graph LR
R[API Request] --> E[Enrichment: geo, ASN, device fingerprint]
E --> F[Streaming Feature Aggregation]
F --> ML[Real time ML Scoring]
ML -->|high risk| B[Auto Block or Challenge]
ML -->|medium risk| SIEM[Alert to SIEM and SOAR]
ML -->|low risk| P[Pass Through]
B --> FB[Feedback Loop]
SIEM --> FB
FB --> ML
Reading the diagram left to right: the synchronous request path is only the leftmost box, since
everything from "Streaming Feature Aggregation" onward runs asynchronously against buffered
data, not inline with the request. At 83,000 requests/second, if the synchronous enrichment plus
a verdict-cache read together cost 2ms, that is a fully absorbable addition to a typical API's
latency budget; if the same path instead waited on the "Real time ML Scoring" box per request,
the pipeline would need that box to sustain 83,000 scoring calls per second with sub-millisecond
latency each, which is why that box is drawn as feeding a cache asynchronously rather than
sitting inline.
Trade-offs and pitfalls
- Fail-open vs. fail-closed under detector outage. Failing open (letting requests through
when the detection pipeline is down) protects availability and revenue but temporarily loses
abuse protection; failing closed protects against abuse but can turn a detection-pipeline
outage into a full product outage. State this trade-off explicitly per endpoint rather than
picking one default for the whole system, since a login endpoint and a public read-only search
endpoint have very different risk profiles. - False positives have a real cost, not just a technical one. An overly aggressive
auto-block tier degrades the experience for legitimate users and generates support load; this
is why the design routes medium-confidence signals to an alert instead of an automatic block,
and why the feedback loop exists at all. - Common wrong turn: scoring every request synchronously "to be safe." This looks more
thorough on paper but does not scale to the stated volume and turns the fraud pipeline into
the system's latency bottleneck; the asynchronous, cache-backed design is not a shortcut, it is
the only version of this architecture that survives the request rate. - Common wrong turn: treating the feedback loop as optional. Without it, the model's
precision decays as attackers adapt and as the false-positive rate silently rises, since
nothing in the system is measuring or correcting for it.
Perform a threat model for an external-facing API. Identify threats such as injection attacks, broken authentication, excessive data exposure, rate-limiting bypass, and DDoS. As a Solutions Architect, propose mitigation strategies including validation, least-privilege, rate limits, WAF, and API-level quotas, and discuss trade-offs and monitoring approaches.
Sample Answer
Structure the threat model with a systematic method, the STRIDE categories (Spoofing, Tampering, Repudiation, Information disclosure, Denial of service, Elevation of privilege), applied to each trust boundary the API crosses: client to gateway, gateway to backend, backend to database. Then map every identified threat to a concrete mitigation and a way to monitor for it in production, since a threat model that stops at a list without controls and monitoring doesn't change what ships.
Scope and trust boundaries
External-facing REST API, untrusted public internet clients, an API gateway (trust boundary 1), backend services (trust boundary 2), and a database or storage layer (trust boundary 3).
Systematic identification, by category and boundary
| STRIDE category | Example threat at this API | Primary mitigation |
|---|---|---|
| Spoofing | attacker forges a client identity or replays a stolen token | strong authentication (OAuth 2.0 or mutual TLS), short token lifetimes |
| Tampering | request or response payload modified in transit or by a compromised intermediary | TLS everywhere, request signing for high-value operations |
| Repudiation | client denies having made a state-changing call | structured, tamper-evident audit logs tied to an authenticated identity |
| Information disclosure | the API returns more fields than the caller should see | schema-driven response filtering, per-scope field allowlists |
| Denial of service | one client or an expensive query exhausts shared capacity | per-client rate limits and quotas at the gateway, query cost limits |
| Elevation of privilege | a regular-user token reaches an admin-only endpoint | function-level authorization enforced server-side on every route, never inferred from the client's UI |
Mapped onto the threats the question specifically calls out: injection attacks (SQL, NoSQL, command) are a tampering-category failure, since they let an attacker change what a backend query or command actually does; broken authentication is a spoofing failure, letting an attacker pass as someone they're not; excessive data exposure is this API's information-disclosure failure, returning fields the caller shouldn't see; rate-limiting bypass and distributed denial-of-service (DDoS) are both denial-of-service failures, differing only in mechanism, one exploits a gap in how limits are enforced, the other simply throws enough volume at the API to matter regardless of any single limiter.
Mitigations, organized by where they run
Design time: enumerate every object identifier in a URL or body and write down, per identifier, how ownership is verified; use parameterized queries or an ORM to close injection paths. Gateway or edge: OAuth 2.0 or API key authentication, a web application firewall (WAF) with managed and custom rules, per-client rate limiting, TLS termination with modern cipher suites. Application layer: least-privilege service accounts, explicit authorization checks per action (not just per resource), input validation against a strict schema. Data layer: encryption at rest, database accounts scoped to only the tables and operations that service actually needs.
Worked example
Consider GET /v1/accounts/{accountId}/statements. The threat-model pass asks: can caller A read caller B's statements by changing accountId (information disclosure)? Can a client request a huge date range and force a full table scan (denial of service)? Does the handler check a verified role claim, or does it trust a client-suppliable header (elevation of privilege)?
The mitigation trace: add a server-side check statement.account.owner_id == token.sub before returning any data, closing the disclosure gap; cap the date range parameter server-side (for example, reject ranges over 366 days and force pagination), closing the expensive-query denial-of-service path; derive the caller's role only from the verified token's claims, never from a client-suppliable header, closing the privilege-escalation path. The monitoring trace: alert if a single token generates 403s on accountId values it doesn't own more than five times in a minute (an enumeration signature); alert on requests repeatedly hitting the date-range cap from one client (probing for the limit).
Trade-offs and pitfalls
A full STRIDE pass on every endpoint before every release doesn't scale, reserve the deep pass for new trust boundaries or high-value endpoints, and rely on automated contract tests to catch regressions on endpoints already modeled. WAF rules cut noise but generate false positives that erode trust in alerts if left untuned, budget time to tune them, not just deploy them. These same categories map closely onto the current OWASP (the Open Web Application Security Project, a nonprofit that publishes ranked lists of common vulnerability categories) API Security Top 10 (the 2023 edition): the information-disclosure and elevation-of-privilege threats above correspond to API3:2023 Broken Object Property Level Authorization and API5:2023 Broken Function Level Authorization respectively. Using STRIDE to find threats systematically and the OWASP list to sanity-check nothing common was missed is stronger than relying on either alone, but the two lists are not interchangeable: they are two separate documents with their own independent numbering, and the API-specific OWASP list (API1:2023-API10:2023) is a separate, narrower edition than the general OWASP Top 10 for web applications broadly (currently the 2025 edition), don't cite a category number from one list as if it belongs to the other.
Describe a secure key management and rotation architecture for API signing and encryption keys. Cover the roles of HSM/KMS vs Vault, envelope encryption, automated rotation schedules, key versioning, secure provisioning to services, access control policies, and rollback strategies if a key is compromised.
Sample Answer
Direct answer
A secure key management architecture separates who is allowed to use a key from who can see
the key's raw bytes: application services request cryptographic operations (sign, encrypt,
decrypt) through an API backed by a hardware security module (HSM, a dedicated physical or
cloud-managed device for storing keys and performing crypto operations without ever exposing the
raw key) or a cloud key management service (KMS), rather than ever pulling the raw key material
into application memory. Automated rotation on a defined schedule, envelope encryption for bulk
data, and a rehearsed rollback plan for a suspected compromise complete the picture.
Structured elaboration
HSM/KMS vs. Vault. An HSM (or a cloud KMS built on HSM-backed key storage, like AWS KMS or
Google Cloud KMS) is purpose-built for one thing: keys that never leave it in plaintext, with
every cryptographic operation performed inside the device or service and only the result
(a signature, a ciphertext) returned to the caller. HashiCorp Vault (a secrets-management
platform) is broader: it manages many kinds of secrets (database credentials, API tokens,
certificates, and also encryption keys via its own key-management backends), often layering on
top of or delegating hardware-backed storage to a KMS/HSM underneath for the highest-sensitivity
keys, while adding features like dynamic, short-lived credential issuance for things that are not
purely "an encryption key," like database passwords. In practice, a mature setup often uses both:
KMS/HSM for the small number of long-lived signing and master keys, Vault for the broader
population of API-facing secrets and dynamically issued credentials.
Envelope encryption. Rather than encrypting every piece of data directly with a single
master key (which would mean any bulk decryption needs an HSM call and makes rotating the master
key mean re-encrypting everything it ever touched), envelope encryption generates a unique data
encryption key (DEK) per data item or batch, encrypts the actual data with that DEK locally
(fast, no HSM round trip needed), and then encrypts (wraps) only the small DEK itself using the
HSM-held master key (KEK, key-encryption key). Rotating the master key then only means
re-wrapping the small DEKs, not re-encrypting the underlying bulk data.
Automated rotation schedules. Signing and encryption keys should rotate on a defined cadence
(commonly 90 days for many compliance frameworks, though the right interval depends on the key's
exposure and the standard you are held to) via automation, not a manual calendar reminder, since
manual rotation is exactly the kind of rarely-exercised process that breaks silently when it is
finally needed. Automation should generate the new key version, begin using it for new
operations, and keep prior versions available for verification/decryption of data signed or
encrypted before the rotation, until that older data ages out.
Key versioning. Keys are never destructively replaced in place; each rotation creates a new
version while prior versions remain available (for verifying old signatures or decrypting old
ciphertext) until nothing depends on them anymore. Every signature or ciphertext should carry, or
be resolvable to, which key version produced it, so verification always uses the matching
version rather than assuming "the current key" is always correct.
Secure provisioning to services. Services should authenticate to the KMS/HSM/Vault using
their own workload identity (a short-lived certificate or token tied to what the service is,
renewed automatically, the same pattern well-run service meshes use for service-to-service
authentication), not a static credential baked into configuration, and should request only the
specific operations and key scopes they need (a service that only ever verifies signatures should
not hold a grant to sign).
Access control policies. Scope every grant to the narrowest key, operation, and identity
combination that satisfies the actual need: "this specific service identity may call decrypt
using this specific key" rather than a broad grant across all keys or all operations, and log
every key-use request (which identity, which key, which operation, when) so unusual access
patterns are visible after the fact.
Rollback strategy if a key is compromised. Have a rehearsed, not just documented, procedure:
revoke or disable the compromised key version immediately (stopping new operations with it),
rotate to a fresh key version, re-encrypt or re-sign anything that specifically depended on the
compromised version's continued trust (this is where envelope encryption pays off, since only
the wrapped DEKs need re-wrapping with the new KEK, not the bulk data itself), and audit the
access log for the compromised key to scope what, if anything, was actually exposed during the
compromise window.
Worked example
A payments service signs outbound webhook payloads with a signing key held in a KMS. Rotation
cadence: 90 days, automated. On day 90, the automation generates key version v7, begins signing
new webhooks with v7, and keeps v6 available for verification only (a partner's system might
still be validating a webhook signed just before the rotation, using cached knowledge of v6).
After a defined overlap window (long enough that no in-flight signed payload from v6 is still
being verified anywhere), v6 is retired from active use but its public verification material
stays available for as long as audit or dispute resolution might need to verify historical
signatures. If v7's private key material were suspected compromised on day 95, the rollback
plan disables v7 immediately, generates v8 for new signing, and the access log for v7 gets
audited to determine the exact window and scope of exposure, since "we rotated the key" alone
does not answer "what did the attacker actually get to sign or decrypt before we noticed."
Trade-offs and pitfalls
- Frequent rotation adds real operational overhead (key-version bookkeeping, overlap-window
management) in exchange for a smaller blast radius per key. The right interval balances that
against how sensitive the key is and what compliance framework, if any, sets a floor; rotating
a low-sensitivity internal key on the same aggressive schedule as a payments-signing key adds
cost without a matching security benefit. - Envelope encryption adds a layer of indirection that is easy to get subtly wrong, most
commonly by caching a decrypted DEK longer than intended (defeating the point of only
decrypting it when actually needed) or by failing to re-wrap old DEKs during a KEK rotation,
silently leaving old data protected only by a retired key. - Common wrong turn: treating "we have a KMS" as equivalent to "keys are managed securely."
A KMS with overly broad access grants (every service can calldecrypton every key) gives
you hardware-backed storage without the access-control discipline that actually limits blast
radius; the KMS is necessary but not sufficient. - Common wrong turn: documenting a rollback plan but never rehearsing it. A compromise
response that has never been exercised tends to reveal missing pieces exactly when there is no
time to discover them, for example, a service that hard-codes a specific key version instead of
always resolving "the current version" and so does not pick up the rotation automatically.
What is an API gateway, and what security responsibilities does it typically take on for the services sitting behind it?
Sample Answer
Direct answer
An API gateway is a single entry point that sits in front of a set of backend services and handles cross-cutting concerns, routing, traffic management, and security, before a request ever reaches business logic. On the security side, its main value is enforcing cheap, universal checks exactly once, instead of every individual service having to duplicate that logic.
Structured elaboration
Typical security responsibilities a gateway takes on:
- Transport security: terminating TLS (Transport Layer Security) and enforcing HTTPS-only, including a minimum supported TLS version.
- Coarse authentication: validating a token's signature and expiry, or checking an API key, before forwarding the request at all.
- Coarse authorization: confirming this identity is allowed to call this route in general, not the fine-grained "does this caller own this specific record" check, which still belongs inside the service.
- Rate limiting and throttling: protecting the whole platform from abuse or an accidental traffic spike from any single caller.
- Request validation: rejecting malformed, oversized, or wrong-content-type requests early, before they cost any downstream service compute.
- IP allow/deny lists and basic filtering: blocking known-bad sources or request patterns before they reach anything meaningful.
- Centralized audit logging: one place to see every request that entered the system, useful for both security review and debugging.
- Identity propagation: injecting a verified identity (for example, a user-id header) into the forwarded request, so downstream services trust the gateway's verification rather than each re-parsing raw tokens themselves.
Worked example
A POST /orders request arrives with no authentication token. The gateway rejects it with a 401 response before the orders service, inventory service, or payment service ever see it, so none of them spend any compute on traffic that was never going to be allowed. A validly authenticated request for the same endpoint is forwarded along with an X-User-Id header the gateway added after verifying the token, so the orders service can trust that identity without re-validating the raw token itself.
Trade-offs & pitfalls
A gateway should take on responsibilities that are universal and cheap to check without business context, not fine-grained, per-resource authorization, which needs domain knowledge only the service actually has. The most common pitfall is treating the gateway as the only layer of defense: it is a first filter that removes obviously bad traffic early, not a substitute for a service independently checking that a specific caller is allowed to touch a specific resource.
Unlock Full Question Bank
Get access to all 28 API Security, Authentication and Authorization interview questions and detailed answers.
Sign in to ContinueJoin thousands of developers preparing for their dream job.