What is authentication vs authorization?
Signing in is only half of security. Authentication answers "who are you?", authorization answers "are you allowed?", and most real data leaks come from skipping the second.

Key takeaways
- Authentication (authn) verifies identity: password, magic link, Google sign-in. Authorization (authz) checks permission for each action.
- Authorization must be enforced on the server or in the database, never only by hiding buttons in the frontend.
- A 401 error means "we do not know who you are"; a 403 means "we know, and the answer is no."
In one line: authentication proves who a user is, and authorization decides what that user is allowed to do. Logging in with a password is authentication; being able to edit your own posts but not someone else's is authorization. People shorten them to "authn" and "authz," and confusing the two is behind a large share of real-world data leaks.
An everyday example: checking into a hotel
At the front desk you show your passport. The clerk checks your face against it: that is authentication. Then you get a key card. It opens room 314, the gym and the lift to your floor, but not room 315 or the staff office: that is authorization. The card does not prove who you are each time; it carries what you are allowed into. And crucially, each door checks the card itself. A sign saying "guests only" would not stop anyone.
How the two look in a real app
Take a small team task tracker:
- Authentication: a user signs in with email and password, a magic link or Google. The app now knows this request comes from user `u_204`.
- Authorization, by ownership: `u_204` can edit tasks where `owner_id = u_204`.
- Authorization, by membership: `u_204` can see tasks in projects where they appear in `project_members`.
- Authorization, by role: only users with role `admin` can delete a project or invite people.
Authentication happens once per session. Authorization happens on every request: every read, every save, every delete. That is why it needs to live where users cannot tamper with it.
Where each check belongs
The frontend can hide a Delete button from non-admins, and it should, for a clean interface. But anyone can open developer tools and send the delete request anyway. Real authorization is enforced on the server (in an API or edge function) or in the database itself through row-level security policies. The Startbase security practices page puts it plainly: use frontend auth state only for rendering the interface, never for access control, and check roles and permissions server-side.
Why it matters when building with Startbase
Startbase Cloud handles both halves. For authentication, the Auth section offers email and magic link sign-in, Google, Apple, phone, anonymous users and an invite-only mode (auth docs). You can change a user's role between Member and Admin there; it is stored in the user's app metadata for your app to check. For authorization, the agent turns on row-level security for every table it creates, with policies that match how your app signs people in, and the check before every publish flags tables with it turned off. Your job is to describe the rules clearly.
Add sign-in with email and Google. Users belong to workspaces. Members can see and edit tasks in their own workspaces only; only workspace admins can delete tasks or invite people. Enforce these rules in the database with row-level security, not just in the interface, and show me the policies you created.
Go deeper with user authentication explained and row-level security explained.
Common confusions
- 401 versus 403. HTTP status 401 (named "Unauthorized," confusingly) really means unauthenticated. 403 Forbidden means authenticated but not permitted.
- OAuth is mostly about authorization. It was designed to grant an app access to your data elsewhere; sign-in on top of it is a layer called OpenID Connect.
- "Logged in" is not "allowed." Every signed-in user should still only reach their own rows.
Frequently asked questions
Which comes first, authentication or authorization?
Authentication. The app has to know who you are before it can decide what you may do. Public pages skip both; everything private needs both.
Is hiding a page enough to protect it?
No. Hiding a link only changes the interface. The data behind it must be protected by checks on the server or row-level security in the database.
What is role-based access control?
A form of authorization where permissions attach to roles like member, editor or admin, and users get roles. It is simpler to manage than per-user permissions once a team grows.

