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.

MediumSystem Design
65 practiced

Build an authentication and authorization scheme for a multi-tenant API that supports bearer tokens for user auth and API keys for service-to-service calls. Include per-tenant rate limits, key rotation, revocation, secure key storage, and how to represent tenant scoping in tokens or claims.

HardTechnical
67 practiced

Build automated tests to detect field level authorization bypass in a GraphQL service where some schema fields should only be visible to certain roles. Provide a practical test script example (for instance in Python or JavaScript) that: 1) enumerates accessible fields for an admin user, 2) repeats the same queries for a low privilege user, and 3) asserts unauthorized fields are absent or redacted. Explain how to handle schema introspection differences between environments.

HardTechnical
67 practiced

Given a GraphQL mutation that accepts deeply nested input to create users and related resources, perform a threat model that focuses on injection, excessive data exposure, denial-of-service via complex nested queries, and authorization bypass. Propose precise mitigations such as sanitization, field-level authorization hooks, depth/complexity limiting, persisted queries and cost estimation.

MediumTechnical
103 practiced

Write a Python function verify_jwt(token: str, expected_aud: str, expected_iss: str, jwks_url: str) -> dict that validates a JWT. Requirements: verify signature using JWKS, reject tokens with alg 'none', validate aud/iss/exp/nbf fields, support key rotation by using kid header and caching JWKS with TTL. Pseudocode is acceptable: show the key validation and caching logic.

EasyTechnical
59 practiced

Write a small Express middleware in Node.js that checks for a bearer token in the Authorization header, rejects requests with a 401 JSON response when missing or invalid, and logs request id and path. Provide the middleware signature and briefly describe how you'd integrate it into the request pipeline and unit-test it.

Unlock Full Question Bank

Get access to all 20 API Security, Authentication and Authorization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.