Skip to content

Quiz: Sign-In, Permissions and Access

Test your understanding of authentication, authorization, sessions, roles, object ownership checks and invite flows with these review questions.


1. What is the difference between authentication and authorization?

  1. Authentication proves who someone is; authorization decides what that identity may do
  2. Authentication decides what someone may do; authorization proves who they are
  3. Authentication runs on the server; authorization runs in the browser
  4. They are two names for the same check
Show Answer

The correct answer is A. In the hotel, the front desk checking your ID is authentication, and the lock deciding whether your card opens room 712 is authorization. Authentication produces an identity, such as user_381. Authorization runs on every request and asks whether that identity may do this thing to this record. Option B reverses them. Both checks must run on the server, so C is wrong.

Concept Tested: Authentication

See: Who Are You, and What May You Do?


2. What is least privilege?

  1. Giving new teammates admin access until they learn the app
  2. Letting each member choose which permissions they want
  3. Giving every person, program and key only the access it needs for its job, and no more
  4. Keeping the number of members in the app small
Show Answer

The correct answer is C. Least privilege means a teammate who answers support email gets a viewer role, not admin, and an API key that only needs to read gets a read-only key. If that account or key is ever stolen, the damage stops at what it could do. Option A does the opposite. Option B hands the decision to the person asking. Option D is about user count, not access.

Concept Tested: Least Privilege

See: Roles and Least Privilege


3. Maya is signed in and changes the address from /api/scans/1042 to /api/scans/1043, which belongs to another member. What gap would let her see it?

  1. A missing authentication check
  2. A cookie without the Secure setting
  3. A missing multi-factor prompt
  4. An insecure direct object reference, where the route returns the record without checking who owns it
Show Answer

The correct answer is D. Maya's sign-in is valid, so authentication passes (A). The route is one she may use. The gap is that the code looks up scan 1043 by its ID alone and returns it. An object ownership check adds "and it belongs to the person asking" to the lookup. The dating-safety app got this right. A wrong ID gets the same answer as a scan that doesn't exist.

Concept Tested: Insecure Direct Object Reference

See: Every Object, Not Just Every Route


4. Why does a 6-digit share code need a limit on wrong guesses?

  1. Members forget their codes after a few tries
  2. Without a limit, a script trying 100 codes a second could try all one million in under three hours
  3. The limit makes the code longer
  4. Browsers refuse to send more than five requests to one page
Show Answer

The correct answer is B. Six digits give one million codes, and a million divided by 100 a second is about 2.8 hours. Lock the report after 5 wrong guesses and the attacker's chance falls to 5 in a million, with the same code. That's why a share code also needs an expiry and the same 404 rule as scans. The limit doesn't change the code's length (C), and browsers have no such cap (D).

Concept Tested: Share Code Access

See: Sharing Without Signing In: The 6-Digit Code


  1. Scripts running in the page reading the cookie and copying the session ID
  2. The cookie being sent over a plain, unencrypted connection
  3. The cookie expiring too soon
  4. Other members guessing the session ID
Show Answer

The correct answer is A. HttpOnly means page scripts can't read the cookie, so if an attacker manages to run code in the page, they still can't copy the session ID. Sending only over HTTPS is the Secure setting (B). SameSite limits when the cookie goes along with requests started by other sites. Expiry is set by Max-Age (C). A long random session ID is what stops guessing (D).

Concept Tested: Cookie

See: Staying Signed In: Sessions, Cookies and Tokens


6. You asked the agent to "make sure viewers can't change settings," and it hid the Settings button for viewers. What should you tell it next?

  1. "Good, that covers it."
  2. "Also gray out the menu item, so viewers can't click it."
  3. "Add a server-side role check on the settings route, and a test that sends the change as a viewer and expects 403."
  4. "Remove the viewer role so the question goes away."
Show Answer

The correct answer is C. Hiding the button leaves a client-only check gap, because a viewer can send the settings change straight to the server. The lock belongs on the server, in middleware such as requireRole("admin"). A test keeps it from coming undone when an agent adds a route. Graying out the item (B) is still a browser-only change. The hidden button can stay, since it is good design, but it isn't the lock.

Concept Tested: Client-Only Check Gap

See: The Lock Belongs on the Server


7. Your app's invite flow creates an account with a password and puts the password in the invite email. What is the better design?

  1. Send the password in a second email, separate from the link
  2. Send a single-use, expiring invite token tied to the email and role, and let the teammate choose their own password
  3. Send the password by text message instead of email
  4. Make the password longer
Show Answer

The correct answer is B. An invite token is long, random, works once, expires in days, and is tied to one email and role. The server stores only its hash. The teammate chooses their own password, so no readable password ever travels. A plaintext password in email stays readable in mailboxes for years and can be forwarded by mistake. Splitting it across messages (A), texting it (C) or lengthening it (D) leaves that problem in place.

Concept Tested: Invite Token

See: The Fix: Invite Tokens


8. Someone requests a scan that exists but belongs to another member. Which response should the server send?

  1. 403 Forbidden, because it is the most accurate answer
  2. 200 with an empty body
  3. 401 Unauthorized, asking them to sign in again
  4. 404 Not Found, the same as for a scan that doesn't exist
Show Answer

The correct answer is D. A 403 says "this exists, and you may not have it." If scan 1043 returns 403 and scan 99999 returns 404, an outsider learns which IDs exist and roughly how fast the app is growing. Answering 404 leaks nothing. A 200 with an empty body (B) can be read as success. A 401 (C) is wrong because the person is already signed in.

Concept Tested: 404 Instead of 403

See: Why 404 Instead of 403


9. In the hotel, the housekeeper's card opens every room on the floor, but only during her shift. Which two ideas from the chapter does that card combine?

  1. A role that grants a set of doors, and a limit on how long the access lasts
  2. Authentication and multi-factor authentication
  3. An object ownership check and a share code
  4. An auth provider and a magic link
Show Answer

The correct answer is A. Her card carries a role, housekeeping, which opens a set of rooms no guest card does. The shift limit is the same idea as a session or token that expires. In an app, this is role-based access control plus sessions that end. Nothing about her card proves identity twice (B), checks who owns a room (C) or comes from an outside sign-in service (D).

Concept Tested: Role-Based Access Control

See: Roles and Least Privilege


10. An access review turns up three problems: a viewer can change settings, a shared report never expires, and one teammate has admin who only reads reports. Which should be fixed first?

  1. The extra admin, because admin accounts are the master card
  2. The never-expiring share, because it is the oldest problem
  3. The viewer who can change settings, because any viewer account can already do it through a direct request
  4. All three are equal, so fix them in alphabetical order
Show Answer

The correct answer is C. Rank by likelihood, impact and blast radius. The settings gap is open to every viewer account today, and settings can change how the whole app behaves, so it reaches every member. The extra admin (A) matters but depends on that one account being misused or stolen. A share with no expiry (B) still needs the code and a guess limit to be useful to an attacker. All three need fixing, just not as equals.

Concept Tested: Server-Side Check

See: Putting It Together: An Access Review