Authentication & Authorization interview questions

25 questions from the Authentication & Authorization course, each with the correct answer and an explanation. Try to answer before you open the answer.

Identity Foundations

1. A logged-in user requests another tenant's record. Which check should stop them?

  1. TLS certificate validation
  2. Authentication
  3. Authorization
  4. Password hashing
Show answer

Answer: Authorization

The user is already authenticated; the question is whether they may access that object.

Lesson: Authentication Versus Authorization

2. Which combination is genuine multi-factor authentication?

  1. A password plus a code from an authenticator app
  2. A password plus a security question
  3. Two different passwords
  4. A username plus a password
Show answer

Answer: A password plus a code from an authenticator app

MFA needs factors from different categories: know plus have.

Lesson: Principals, Credentials and Factors

3. Which factor resists real-time phishing best?

  1. A longer password
  2. An SMS one-time code
  3. A TOTP code from an app
  4. A passkey (WebAuthn credential) bound to the site origin
Show answer

Answer: A passkey (WebAuthn credential) bound to the site origin

WebAuthn signatures are bound to the origin, so a look-alike domain cannot use them.

Lesson: Threat Model for Login

Passwords Done Right

4. Why is plain SHA-256 a poor choice for password storage?

  1. It is reversible with the right key
  2. It is designed to be fast, so offline guessing is cheap
  3. It produces outputs that are too long to store
  4. It cannot be used with a salt
Show answer

Answer: It is designed to be fast, so offline guessing is cheap

Password hashes must be deliberately slow and tunable.

Lesson: Storing Passwords

5. What is a downside of hard account lockout after a few failed attempts?

  1. It makes passwords easier to guess
  2. Attackers can deliberately lock out legitimate users
  3. It reveals the password hash
  4. It disables HTTPS for that user
Show answer

Answer: Attackers can deliberately lock out legitimate users

Lockout turns into a denial-of-service tool; progressive delays and step-up checks are gentler.

Lesson: Designing the Login Flow

6. Which property should a password reset token NOT have?

  1. Only its hash is stored server-side
  2. It is generated with a cryptographically secure random source
  3. It expires after a short time
  4. It stays valid after it has been used once
Show answer

Answer: It stays valid after it has been used once

Reset tokens must be single use and short-lived.

Lesson: Password Reset and Email Verification

Sessions and Cookies

7. What is a key advantage of server-side sessions over self-contained tokens?

  1. Sessions can be revoked immediately by deleting the server record
  2. They never need a cookie
  3. They work without any server storage
  4. They cannot be stolen
Show answer

Answer: Sessions can be revoked immediately by deleting the server record

State on the server means the server decides when a session ends.

Lesson: Server-Side Sessions

8. What does the HttpOnly attribute do?

  1. Blocks the cookie on all cross-site requests
  2. Forces the cookie to be sent only over HTTPS
  3. Prevents page JavaScript from reading the cookie
  4. Encrypts the cookie value
Show answer

Answer: Prevents page JavaScript from reading the cookie

HttpOnly limits cookie theft through XSS; Secure is the HTTPS-only flag.

Lesson: Secure Cookie Attributes and CSRF

9. Why regenerate the session ID immediately after login?

  1. To reset the user's password
  2. To make the cookie smaller
  3. To prevent session fixation using an ID set before login
  4. To disable CSRF tokens
Show answer

Answer: To prevent session fixation using an ID set before login

A pre-login ID could have been planted by an attacker.

Lesson: Session Lifecycle

Tokens and JWT

10. Why might several microservices prefer RS256 or ES256 over HS256?

  1. They can verify with a public key without being able to mint tokens
  2. Asymmetric signatures make the payload encrypted
  3. HS256 tokens cannot carry an exp claim
  4. RS256 tokens never expire
Show answer

Answer: They can verify with a public key without being able to mint tokens

With HS256 every verifier holds the signing secret.

Lesson: JWT Structure and Signing

11. What does pinning an algorithm allow-list during verification prevent?

  1. Key rotation through JWKS
  2. Clock skew between servers
  3. Tokens being read by the client
  4. Attacks that switch alg, such as alg none or RS256-to-HS256 confusion
Show answer

Answer: Attacks that switch alg, such as alg none or RS256-to-HS256 confusion

The verifier, not the token, decides which algorithms are acceptable.

Lesson: Verifying JWTs Correctly

12. Why is localStorage a poor place for a long-lived refresh token?

  1. It is cleared on every page load
  2. Any successful XSS can read it and send it to an attacker
  3. It cannot store strings longer than 64 characters
  4. Browsers send it automatically with every request
Show answer

Answer: Any successful XSS can read it and send it to an attacker

Unlike HttpOnly cookies, localStorage is fully readable by scripts on the page.

Lesson: Access Tokens, Refresh Tokens and Browser Storage

OAuth 2.0 and OpenID Connect

13. What does PKCE protect against?

  1. Weak user passwords
  2. An intercepted authorization code being redeemed by another party
  3. Expired access tokens
  4. Cross-site scripting in the API
Show answer

Answer: An intercepted authorization code being redeemed by another party

Only the client holding the code_verifier can redeem the code.

Lesson: Roles and the Authorization Code Flow With PKCE

14. Who is the intended audience of an OIDC ID token?

  1. Any service in the same company
  2. The resource server (API)
  3. The user's browser extensions
  4. The client application that requested the login
Show answer

Answer: The client application that requested the login

APIs should receive access tokens; ID tokens prove login to the client.

Lesson: OpenID Connect: ID Tokens, Userinfo and Access Tokens

15. Which grant fits a nightly batch job calling an internal API with no user present?

  1. Client credentials
  2. Implicit
  3. Resource owner password credentials
  4. Authorization code without PKCE
Show answer

Answer: Client credentials

No user is involved, so the service authenticates as itself.

Lesson: Client Credentials and Discouraged Grants

Strong and Modern Authentication

16. Why is SMS considered a weak second factor?

  1. SMS cannot be rate limited
  2. SMS codes are always longer than TOTP codes
  3. Codes can be stolen through SIM swapping or interception
  4. SMS requires the user to know a password
Show answer

Answer: Codes can be stolen through SIM swapping or interception

Phone numbers can be hijacked without touching the user's device.

Lesson: MFA Options

17. Why are passkeys resistant to phishing?

  1. The server stores the private key securely
  2. The user types a longer code
  3. Signatures are scoped to the relying party and origin, so a look-alike site cannot use them
  4. They are sent by SMS
Show answer

Answer: Signatures are scoped to the relying party and origin, so a look-alike site cannot use them

The private key stays on the authenticator and is bound to your domain.

Lesson: Passkeys and WebAuthn

18. What is the safest way to link a new social identity to an existing account with the same email?

  1. Require the user to sign in to the existing account first, then link
  2. Link automatically whenever emails match
  3. Create a duplicate account silently
  4. Ask the provider for the user's password
Show answer

Answer: Require the user to sign in to the existing account first, then link

Matching emails alone can be spoofed or unverified.

Lesson: Social Login and Account Linking

Authorization Models

19. Which model best fits Google Docs-style sharing through folders and groups?

  1. IP allow-listing
  2. Pure RBAC with global roles
  3. No authorization, only authentication
  4. ReBAC (relationship-based access control)
Show answer

Answer: ReBAC (relationship-based access control)

Access is derived from relationships between users, groups, folders and documents.

Lesson: RBAC, ABAC and ReBAC

20. An API returns any invoice by ID to any logged-in user. What is this flaw called?

  1. Session fixation
  2. Broken object level authorization (BOLA / IDOR)
  3. Credential stuffing
  4. Algorithm confusion
Show answer

Answer: Broken object level authorization (BOLA / IDOR)

The handler authenticates but never checks ownership of the object.

Lesson: Enforcing Authorization in APIs

21. Where should an API take the current tenant ID from?

  1. A tenant_id query parameter
  2. The authenticated session or verified token
  3. The Referer header
  4. A value in localStorage
Show answer

Answer: The authenticated session or verified token

Client-controlled values can be changed to another tenant's ID.

Lesson: Multi-Tenant Isolation

Production Identity

22. Which is a common trade-off of using a managed identity provider?

  1. It prevents all phishing automatically
  2. It removes the need for authorization in your app
  3. It makes HTTPS unnecessary
  4. Vendor lock-in and per-user costs in exchange for less security work
Show answer

Answer: Vendor lock-in and per-user costs in exchange for less security work

IdPs handle authentication; your app still owns authorization.

Lesson: Using Identity Providers

23. Which item should never appear in authentication logs?

  1. The full session ID or access token
  2. The event type and outcome
  3. The source IP address
  4. A request correlation ID
Show answer

Answer: The full session ID or access token

Logged tokens can be replayed by anyone with log access.

Lesson: Auditing and Monitoring Auth Events

24. How should a server store API keys it has issued?

  1. Encrypted in the client's browser storage
  2. In plain text so support can read them back
  3. As hashes, showing the plaintext key to the user only once
  4. Inside the JWT payload of every response
Show answer

Answer: As hashes, showing the plaintext key to the user only once

A database leak should not reveal working keys.

Lesson: API Keys and Service Accounts

25. Which item belongs on an identity review checklist?

  1. Password reset links never expire
  2. Refresh tokens are stored in localStorage for convenience
  3. Session IDs are regenerated at login and privilege changes
  4. Login errors reveal whether the email exists
Show answer

Answer: Session IDs are regenerated at login and privilege changes

The other options are classic identity weaknesses.

Lesson: An Identity Checklist

← Back to the course