feat(supabase): V1-2.1 M4/M5 secure sheet access and review workflow
M4 20261028100000_sheet_access_hardening + M5 20261028110000_sheet_review_workflow (applied together; no unprotected window). Implements contract §5-§14. - Catalogue rights table + owner RPCs; has_mfa / has_aal2_session (live auth.sessions check); grant_active vs caller_has split; catalogue reader predicate; can_edit_sheet on the sheet_editor capability (F14). - AR-1 B: aal2 required on every platform role change, target verified factor, race-free last-owner guard (F18/F19); service_role loses table privileges on the catalogue + profiles/profile_roles and EXECUTE on the role RPCs (F12/F17). - Reviewed lifecycle: version provenance + review columns, content/freeze/ author triggers, rounds/comments/acknowledgments, save/submit/withdraw/ comment/acknowledge/decide, atomic publish_sheet_version(review_id) on the stored verdict, deprecate/archive/restore, species RPCs, equine working copy, uploads with the storage check (F7) + editor INSERT policy + 2 MiB bucket. F1-F3,F5,F6,F8,F9,F13,F15,F16 closed. Verdict is a fixture until M6 (V1-2.3). - O22: SQL business mirror removed, declared status check kept; pgTAP 011 and the Rust generator's SQL parts deleted, ledger retargeted. - Access layer sheets.ts (closed SheetFailure kinds); old client publish gate deleted; types regenerated; upload tool reads via get_sheet_asset_state. Tested on the throwaway sandbox only; DEV untouched. pgTAP 850 (real stack) / 122 (PGlite) green; real-GoTrue AR-1 B + F18 race green; fresh install and M3->M5 upgrade green; V1-1 regression green; rust:check, typecheck, lint, build, types drift clean. BDR-084, LRN-095.
This commit is contained in:
1 parent
9c13bae4bc
commit
77e5fa4cf5
33 files changed
+4613
-1617
No files matched your search
@@ -55,6 +55,19 @@ const expectedColumns = {
|
||||
'updated_at',
|
||||
'workspace_id',
|
||||
],
|
||||
anatomical_catalog_grants: [
|
||||
'expires_at',
|
||||
'grant_kind',
|
||||
'granted_at',
|
||||
'granted_by',
|
||||
'id',
|
||||
'reason',
|
||||
'revocation_reason',
|
||||
'revoked_at',
|
||||
'revoked_by',
|
||||
'user_id',
|
||||
'verification_note',
|
||||
],
|
||||
anatomical_sheet_assets: [
|
||||
'byte_size',
|
||||
'content_type',
|
||||
@@ -66,18 +79,58 @@ const expectedColumns = {
|
||||
'sheet_id',
|
||||
'uploaded_at',
|
||||
],
|
||||
anatomical_sheet_review_acknowledgments: [
|
||||
'created_at',
|
||||
'group_digest',
|
||||
'group_key',
|
||||
'id',
|
||||
'review_id',
|
||||
'reviewer',
|
||||
],
|
||||
anatomical_sheet_review_comments: ['author', 'body', 'created_at', 'group_key', 'id', 'review_id'],
|
||||
anatomical_sheet_reviews: [
|
||||
'attempts',
|
||||
'authors',
|
||||
'created_at',
|
||||
'decided_at',
|
||||
'decided_by',
|
||||
'decision_note',
|
||||
'failure_code',
|
||||
'failure_outcome',
|
||||
'id',
|
||||
'lease_token',
|
||||
'locked_at',
|
||||
'revision',
|
||||
'round',
|
||||
'status',
|
||||
'submission_note',
|
||||
'submitted_at',
|
||||
'submitted_by',
|
||||
'verdict',
|
||||
'verified_at',
|
||||
'verified_with',
|
||||
'version_id',
|
||||
'withdrawal_note',
|
||||
'withdrawn_at',
|
||||
'withdrawn_by',
|
||||
],
|
||||
anatomical_sheet_versions: [
|
||||
'authors',
|
||||
'change_note',
|
||||
'content',
|
||||
'created_at',
|
||||
'created_by',
|
||||
'deprecated_at',
|
||||
'deprecated_by',
|
||||
'document_fingerprint',
|
||||
'document_schema_version',
|
||||
'id',
|
||||
'published_at',
|
||||
'published_by',
|
||||
'published_review_id',
|
||||
'revision',
|
||||
'sheet_id',
|
||||
'source_version_id',
|
||||
'status',
|
||||
'updated_at',
|
||||
'version_number',
|
||||
@@ -100,6 +153,7 @@ const expectedColumns = {
|
||||
'status',
|
||||
'updated_at',
|
||||
'visibility',
|
||||
'working_copy_source_version_id',
|
||||
],
|
||||
assets: [
|
||||
'attempts',
|
||||
@@ -197,15 +251,26 @@ const expectedFunctionArgs = {
|
||||
complete_avatar_job: ['asset_id', 'byte_size', 'lock_token', 'sha256'],
|
||||
confirm_asset_upload: ['asset_id'],
|
||||
confirm_sheet_asset_upload: ['asset_id'],
|
||||
create_anatomical_sheet: [
|
||||
'description',
|
||||
'document',
|
||||
'name',
|
||||
'official',
|
||||
'slug',
|
||||
'species_id',
|
||||
'visibility',
|
||||
],
|
||||
acknowledge_sheet_review_group: ['group_digest', 'group_key', 'review_id'],
|
||||
activate_species: ['id'],
|
||||
comment_sheet_review: ['body', 'group_key', 'review_id'],
|
||||
create_official_sheet: ['document', 'slug'],
|
||||
create_species: ['id', 'name_en', 'name_fr', 'sort_order'],
|
||||
create_sheet_working_copy: ['slug', 'source_version_id'],
|
||||
decide_sheet_review: ['approve', 'note', 'review_id'],
|
||||
get_sheet_asset_state: ['asset_id'],
|
||||
get_sheet_version: ['version_id'],
|
||||
grant_catalog_right: ['expires_at', 'kind', 'reason', 'user_id', 'verification_note'],
|
||||
list_catalog_grants: [],
|
||||
list_catalog_species: [],
|
||||
list_official_catalog: [],
|
||||
lookup_catalog_account: ['email'],
|
||||
rename_species: ['id', 'name_en', 'name_fr'],
|
||||
revoke_catalog_right: ['grant_id', 'reason'],
|
||||
save_sheet_draft: ['change_note', 'document', 'expected_revision', 'version_id'],
|
||||
submit_sheet_review: ['expected_revision', 'note', 'version_id'],
|
||||
update_inactive_species: ['id', 'name_en', 'name_fr', 'sort_order'],
|
||||
withdraw_sheet_review: ['note', 'review_id'],
|
||||
create_animal: [
|
||||
'birth_date',
|
||||
'birth_year',
|
||||
@@ -247,11 +312,10 @@ const expectedFunctionArgs = {
|
||||
deprecate_sheet_version: ['reason', 'version_id'],
|
||||
end_animal_client_relation: ['ended_on', 'expected_revision', 'relation_id'],
|
||||
expire_pending_uploads: ['max_age_seconds'],
|
||||
fork_anatomical_sheet: ['name', 'slug', 'source_version_id', 'visibility'],
|
||||
grant_platform_role: ['role', 'target_user_id'],
|
||||
list_client_animals: ['after_id', 'after_sort', 'client_id', 'page_size'],
|
||||
mark_quarantine_purged: ['asset_id'],
|
||||
publish_sheet_version: ['version_id'],
|
||||
publish_sheet_version: ['review_id'],
|
||||
register_sheet_asset: ['byte_size', 'file_name', 'sha256', 'sheet_id'],
|
||||
reject_avatar_job: ['asset_id', 'lock_token', 'reason'],
|
||||
remove_avatar: [],
|
||||
@@ -276,7 +340,6 @@ const expectedFunctionArgs = {
|
||||
],
|
||||
set_animal_archived: ['animal_id', 'archived'],
|
||||
set_client_archived: ['archived', 'client_id'],
|
||||
set_sheet_visibility: ['sheet_id', 'visibility'],
|
||||
update_animal: [
|
||||
'animal_id',
|
||||
'birth_date',
|
||||
|
||||
@@ -26,6 +26,34 @@ create table auth.users (
|
||||
updated_at timestamptz default now()
|
||||
);
|
||||
|
||||
-- MFA state read by the V1-2 assurance checks (private.has_aal2_session,
|
||||
-- private.has_verified_totp). Types, names and NOT NULL columns as in GoTrue
|
||||
-- v2.197.0 (checked on the pinned image by tests/sandbox/mfa.sandbox.ts);
|
||||
-- the columns the migrations never read are left out.
|
||||
create type auth.aal_level as enum ('aal1', 'aal2', 'aal3');
|
||||
create type auth.factor_type as enum ('totp', 'webauthn', 'phone', 'recovery_code');
|
||||
create type auth.factor_status as enum ('unverified', 'verified');
|
||||
|
||||
create table auth.sessions (
|
||||
id uuid primary key,
|
||||
user_id uuid not null references auth.users (id) on delete cascade,
|
||||
created_at timestamptz,
|
||||
updated_at timestamptz,
|
||||
factor_id uuid,
|
||||
aal auth.aal_level,
|
||||
not_after timestamptz
|
||||
);
|
||||
|
||||
create table auth.mfa_factors (
|
||||
id uuid primary key,
|
||||
user_id uuid not null references auth.users (id) on delete cascade,
|
||||
friendly_name text,
|
||||
factor_type auth.factor_type not null,
|
||||
status auth.factor_status not null,
|
||||
created_at timestamptz not null,
|
||||
updated_at timestamptz not null
|
||||
);
|
||||
|
||||
create or replace function auth.uid()
|
||||
returns uuid
|
||||
language sql
|
||||
|
||||
Reference in new issue
Block a user