QuizzesAuthentication Patterns — Concept Check
intermediate
nextjs

Authentication Patterns — Concept Check

Questions on Authentication Patterns. Reading the session on the server changes the shape of auth: there is no loading state, no flash of the signed-out UI, and no token in JavaScript at all.

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 Authentication Patterns — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A user reports seeing a flash of the signed-out UI before being redirected to the dashboard. What might be causing this issue?

    • AThe redirect logic is missing in the server-side code.
    • BServer-side cookies are not set properly, leading to session errors.
    • CThe token is stored in localStorage instead of cookies.
    • DClient-side auth is used, causing a delay in session verification.
  2. 2.During a security review, you notice the session token is accessible via JavaScript. What should you do to correct this?

    • ASet the cookie with the httpOnly flag.
    • BEnsure the token is stored in a secure database.
    • CUse a different encryption algorithm for the token.
    • DMove the token to localStorage for better security.
  3. 3.A developer wants to implement a logout function that clears both server sessions and client-side caches. Which approach is correct?

    • ARevoke the session on the server and store a logout flag in localStorage.
    • BClear the browser cache and delete the session cookie.
    • CRevoke the session on the server and delete the session cookie.
    • DOnly delete the session cookie on the client side.
  4. 4.What is a potential drawback of using server-side authentication with cookies for session management?

    • AThe session token is vulnerable to XSS attacks.
    • BThe route becomes dynamic, affecting caching strategies.
    • CCookies cannot store complex user data.
    • DThe server cannot handle concurrent requests efficiently.
  5. 5.A team is deciding between Next owning the session or FastAPI. What is a benefit of FastAPI owning the session?

    • AEasier integration with third-party auth services.
    • BBetter isolation with more moving parts.
    • CAPI can identify the user on its own.
    • DSimple architecture with one source of truth.
  6. 6.Why is there no loading state in server-side authentication?

    • AServer-side rendering is inherently faster than client-side rendering.
    • BThe server pre-fetches all necessary data, including authentication details.
    • CCookies are faster to access than localStorage, reducing wait times.
    • DThe answer is available before the first render, eliminating the need for loading states.
  7. 7.A developer is using a separate backend for authentication. What is a key consideration when forwarding cookies from the browser to the API?

    • AStore the cookie in localStorage for easy access.
    • BEnsure the cookie is same-site to maintain security.
    • CUse a service token for better isolation.
    • DImplement a complex encryption algorithm for the cookie.
  8. 8.What is the purpose of using the cache function in the getSession method?

    • ATo ensure only one verification per request, optimizing performance.
    • BTo prevent unauthorized access by caching session tokens.
    • CTo store user credentials securely on the client side.
    • DTo enable client-side rendering of authenticated pages.