# Least privilege

Least privilege is the security principle that people, and the processes acting for them, get only the access they need for their task and no more. In a business app it applies to roles, to api keys, to connections with other systems and to assistants, and Meadowstack 2.1 starts every setting page, key and connection from the smallest right.

Checked 2 December 2026. By Bohuslav Poláček. https://meadowstack.com/glossary/least-privilege/

*The starter's workspace rules: settings, invitations and roles are admin-only, and nobody changes their own role.*

From `templates/starter/src/workspace/permissions.ts` in the Meadowstack repository:

```ts
export function canWorkspace(person: Person, action: string, subject?: unknown): boolean {
  const admin = person.role === "admin";
  switch (action) {
    // The admin pages of the settings (Team and roles, Connected apps, MCP and AI) and the workspace's details.
    case "settings.read":
    case "settings.edit":
      return admin;
    case "team.invite":
      return admin;
    case "team.role": {
      const member = subject as Pick<Person, "id"> | undefined;
      return admin && (!member || member.id !== person.id);
    }
    default:
      return false;
```

## Why it matters in a business app

Access grows by default: someone needs one export, gets the admin role, and keeps it for years. Each extra right is harmless until the account is phished or a key leaks, and then the damage is the sum of everything that account could do.

The principle is cheap to apply at the start and expensive later, because by then other things depend on the extra rights.

## How Meadowstack handles it

In 2.1:

- **Deny unless named.** `canWorkspace` ends in `default: return false`: an action nobody wrote a rule for is refused, and a module's action without its prefix is refused for everybody.
- **Admin pages are admin-only.** Team and roles, Connected apps, and MCP and AI are behind `settings.read`, and everyone else sees `NoAccess`.
- **Connections and keys.** The recipe `docs/recipes/integrations-and-mcp.md` makes reading the default and writing a separate choice, one token per connection, and a key that never has more rights than the person who made it.
- **Assistants.** An assistant runs as the person who asked and never gets more rights than they have.

What stays yours: the database role the api uses (bound by [row-level security](https://meadowstack.com/glossary/row-level-security/), never a superuser), the scopes of your provider tokens, and the people you make admins.

## Common mistakes

- **One token with every right for every connection.** One leak becomes every system.
- **A service account behind the assistant.** It then reads more than the person who asked.
- **Admin for convenience.** Give the action, not the role, or add a narrower role.
- **Rights that never expire.** Review admins and keys on a schedule; revoke what nobody used.

## Questions

### Is least privilege the same as zero trust?

No. Least privilege limits what each identity may do; zero trust is a wider approach that also stops trusting a request because of where it comes from. Least privilege is one of its parts.

### How does least privilege apply to AI assistants?

The assistant acts as the person who asked, with their rights or fewer: it reads only what they may read, and anything it would change waits for their yes. A key made for it can be read only.

### Why can admins in the starter not change their own role?

So the app always keeps an admin who can put a mistake right, and so nobody can raise or lower their own rights without a second person.

## Sources

- [NIST CSRC Glossary, least privilege](https://csrc.nist.gov/glossary/term/least_privilege), checked 2 December 2026

## Related

- [Team and roles, with the rules in code](https://meadowstack.com/screens/roles-and-permissions/) (Screens)
- [Permissions](https://meadowstack.com/patterns/permissions/) (Patterns)
- [The settings screen](https://meadowstack.com/patterns/settings/) (Patterns)
- [The approval flow](https://meadowstack.com/patterns/approval-flow/) (Patterns)
- [Google Workspace: only your company's domain](https://meadowstack.com/integrations/google-workspace/) (Integrations)
- [Microsoft Entra ID: the person from the token](https://meadowstack.com/integrations/microsoft-entra-id/) (Integrations)
