QuizzesJWT Authentication — Concept Check
intermediate
spring-boot

JWT Authentication — Concept Check

Questions on JWT Authentication. JWT is a stateless authentication token — the server signs it, clients store and send it. A OncePerRequestFilter validates the token on every request and populates the SecurityContext without any database lookup.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on JWT Authentication — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A developer notices that their JWT-based service is not requiring database lookups for authentication. What is the reason for this behavior?

    • AJWT is stateless and does not require database lookups.
    • BJWT requires a database to validate tokens.
    • CJWT stores user data in the database.
    • DJWT uses sessions to authenticate users.
  2. 2.A service using JWT authentication suddenly starts rejecting all tokens. The secret key was recently changed. What is the likely cause?

    • ATokens are using RSA instead of HMAC.
    • BTokens were signed with the old secret key.
    • CTokens are missing the 'iat' claim.
    • DTokens have an invalid 'sub' claim.
  3. 3.A developer stores the JWT secret key directly in the codebase. Why is this practice discouraged?

    • AIt requires database lookups.
    • BIt exposes the key to unauthorized access.
    • CIt prevents token expiration.
    • DIt makes token parsing impossible.
  4. 4.A JWT token is rejected during validation. The developer suspects the token is expired. Which claim should they check?

    • Aalg
    • Bsub
    • Ciat
    • Dexp
  5. 5.A developer is using the JJWT library to generate tokens. They notice an error when using a secret key of 128 bits. What should they do?

    • AUse a secret key of at least 256 bits.
    • BStore the key in code.
    • CRemove the 'sub' claim.
    • DSwitch to RSA for signing.
  6. 6.Why might a JWT token be considered invalid even if the signature is correct?

    • AThe token is using RSA instead of HMAC.
    • BThe token is missing the 'alg' claim.
    • CThe token has expired.
    • DThe token is stored in a database.
  7. 7.A JWT token is passed in the HTTP request but the service is not authenticating the user. What could be the issue?

    • AThe Authorization header is missing 'Bearer '.
    • BThe token has a valid 'sub' claim.
    • CThe token uses HMAC-SHA256.
    • DThe token is stored in the database.
  8. 8.A developer believes JWT tokens require a session to authenticate users. Why is this incorrect?

    • AJWT tokens are only used for signing.
    • BJWT tokens are stored in cookies.
    • CJWT is stateless and does not use sessions.
    • DJWT requires database lookups instead.