Users, Auth, and Permissions

Keep who someone is separate from what they may do, and test the whole account life cycle, from signup to losing access.

Content date: October 15, 2026.

Plain English

Authentication shows who is making a request. Authorization decides what that person may do with a specific record. A session keeps a person signed in between requests. Signing in does not give someone the right to see every record, every tenant (customer organization), or every admin action.

Use this when

Do this before you add private user data or special actions. If the workflow can stay public and anonymous, skip accounts entirely.

If you are just starting

Use a maintained sign-in service, such as Supabase Auth, Clerk, Auth0, or your framework's own library. Never write your own password storage. Make a small permission table: who, which action, which record. Test with two made-up users from different tenants. On the server, take identity from the verified sign-in. A role label sent by the browser is not proof.

When your project grows

Cover signup, email verification, sign-in, sign-out, session expiry, recovery, disabling an account, and role changes. Prefer passkeys or another phishing-resistant method where your provider offers it. For passwords, NIST SP 800-63B-4 (2025) and OWASP say: at least 15 characters when the password is the only factor (8 with a second factor), allow long passphrases and paste, check against breached-password lists, and skip forced changes and character-mix rules. Ask for a fresh sign-in before sensitive actions such as changing an email. Check open sessions after access is revoked. Use one error for a wrong email or password. A hidden button or a working hosted login page does not prove the backend enforces a rule.

Worked example

Alice belongs to Chess Club and Bob to Garden Club. Both can sign in, but Bob cannot export Chess Club's documents. When Alice loses her admin role, her open tab still shows the admin button, but its next request must fail on the server.

Practice

Test identity and permission separately

  1. Write the permission table and name where the server gets its verified identity.
  2. In a test environment, create made-up accounts and records in two tenants.
  3. Send permitted, other-user, and other-tenant requests straight to the server, not through the screen.
  4. Try session expiry, sign-out, password recovery, disabling an account, and a role change, as your provider documents them.
  5. Record what happened, and list which checks used a local stand-in and which still need the real service.

Deliverable: A permission table and an account-and-session results table for one named test environment.

Common mistakes to watch for

  • The browser sends role=admin in a request, and the server believes it.
  • A parent reads another family's invoices by changing the ID in the URL, because the server only checked that someone was signed in.
  • A tutor is removed from the center, but their phone stays signed in and can open student records for days.
  • An invitation or reset link lets someone claim the wrong account.
  • The login page says "no account with that email," telling attackers who your customers are.

Prompting

A weak prompt

Add login to my app and make sure it's secure.

A better prompt

Define the account life cycle and a who, action, and record permission table for this workflow: [describe it, for example parents see only their own children's bookings]. Use a maintained auth service and enforce identity and record permissions on the server. In a test environment, try allowed, signed-out, expired, revoked, other-user, other-tenant, and admin cases. Say which checks used a stand-in and which used the real service.

"We have login" hides cases like a revoked user who stays signed in.

Check before you move on

  • The server takes identity from the verified sign-in.
  • Each permission names a specific record, not just a role.
  • You tested requests from another user and another tenant.
  • You checked sessions at expiry and after revocation.
  • You reviewed the recovery and invitation flows.
  • You noted which checks used a stand-in and which used the real service.

You are done when

  • Each test user can do only what your permission table allows.
  • Expiry, sign-out, and role changes behave as your provider documents.

Questions to think about

Two parents are signed in. One edits a booking ID in the address bar to someone else's booking. What should happen?

The server denies it unless its rules allow that booking. Signing in proves who she is, not what she may open.

Your practice code accepts a user ID from the request. Does that prove your real sign-in works?

No. It tests permission logic with assumed identities. Real sign-in, sessions, and expiry need checks against the actual service.

An admin loses their role while a tab is still open. Where must the new limit be enforced?

On the server or data layer, for every later request. An open page cannot keep authority the server has taken away.

Official references