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.

EasyTechnical
55 practiced

Explain the differences between input validation, schema/contract validation (OpenAPI/JSON Schema), and output encoding. Give concrete examples of how each prevents different attack classes such as SQL injection, XSS, and parameter pollution, and list common developer mistakes that lead to validation bypasses.

MediumTechnical
56 practiced

Walk through the API key management lifecycle you'd put in place: issuance workflow, key metadata (owner, scopes, creation time), secure storage (hashed keys vs plaintext), rotation policies (automatic/manual), revocation propagation, and tying rate limits/auditing to keys. Describe how to discover keys across services and how to handle emergency revocation.

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.

HardSystem Design
58 practiced

Architect a security model for a large-scale microservices platform (~1000 services) that uses a service mesh (e.g., Envoy/Istio) and an API gateway. Goals: enforce strong service-to-service authentication and authorization, minimize blast radius, centralize policy where sensible but avoid bottlenecks, ensure observability and incident response. Provide key components, identity model, policy enforcement points, rollout plan and scaling considerations.

HardSystem Design
68 practiced

Propose a policy-as-code solution (for example using Open Policy Agent - OPA) to enforce attribute-based access control across APIs. Describe where policies should evaluate (sidecar, gateway, service), policy distribution/versioning, performance strategies (caching/compile-time optimizations), CI testing of policies, and how to secure attribute sources and mitigate stale attributes.

Unlock Full Question Bank

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

Sign in to Continue

Join thousands of developers preparing for their dream job.