Skip to content

Step 5: membership inside the company row policy, as basejump's has_role_on_account #66

Open

Description

@leandrotcawork

Founder's word on step 5's native audit (item 2.9), 2026-10-17: "Passo 5: A". company_all keeps checking only the scope's company (decision 0039, security S7), and this issue records the alternative.

Today the COMPANY scope opens with the company from the address, before admission. The row policy checks company_id = conexus.company_id and not that the person is a member. Admission in code decides membership (identity/admission.ts, through the plugin's defaultRoles[role].authorize). The policy guards against a forgotten filter (criterion B3), not a forgotten admission.

basejump puts membership in the policy itself with a SECURITY DEFINER has_role_on_account() (supabase/migrations/20240414161947_basejump-accounts.sql:252-271).

Obstacle: the operator invites a company's first owner in the COMPANY scope of a company with no member (admission.ts). A membership policy would refuse that, so the operator's path needs its own scope or check first.

Trigger: the founder asks for membership in the database too, or a route opens a COMPANY scope where admission could be skipped.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions