Skip to main content

Scoped Access

Scoped access lets admins assign specific forms to editors and viewers, restricting their dashboard to only the forms they need.

Overview

Users with global roles editor or viewer don’t automatically see all forms. Instead, an admin explicitly grants them access to individual forms through the Manage Access dialog on the admin settings page (/settings/admins).

How It Works

Two Access Systems

Terra has two independent systems for form-level access: Both systems are read at login time and merged — the higher role wins per form.

Role Resolution

When determining a user’s effective role for a form, the system:
  1. Queries user_form_access by user_profile_id (admin grants)
  2. Queries program_members by user_id and email (team invitations)
  3. Merges results — higher role wins (owner > editor > viewer)
  4. Applies global role overrides (global viewer caps to read-only)

Global Role Overrides

Global roles set a ceiling on form-level permissions:

Database Schema

user_form_access

The dedicated table for admin-managed grants, introduced in migration 093.
Design decisions:
  • References user_profiles(id) — a stable UUID PK — instead of auth.users, avoiding FK issues with WorkOS user IDs
  • Uses TEXT for role instead of an enum, avoiding program_role type compatibility issues across deployments
  • granted_by stores the admin’s user ID for audit purposes

Server Actions

getUserScopedAccess

Returns the list of available forms and the user’s current assignments.

updateUserScopedAccess

Replaces all form assignments for a user. Uses delete-then-insert for clean state:
Internally:
  1. Looks up user_profiles.id by user_id
  2. Deletes all existing user_form_access rows for that profile
  3. Inserts new rows for each selected form

UI

The Manage Access dialog is available on /settings/admins for users with editor or viewer roles. Admins can:
  • See all available forms grouped by workspace
  • Toggle individual forms on/off
  • Save assignments with a single click
Only super_admin and admin users can manage scoped access for others.

Authorization

Global role hierarchy

Multi-Tenancy

Workspaces and folders