Skip to content

feat(hasura): add role-based select_permissions for escrows and apart…#213

Open
Bosun-Josh121 wants to merge 1 commit into
safetrustcr:mainfrom
Bosun-Josh121:feat/hasura-role-based-select-permissions
Open

feat(hasura): add role-based select_permissions for escrows and apart…#213
Bosun-Josh121 wants to merge 1 commit into
safetrustcr:mainfrom
Bosun-Josh121:feat/hasura-role-based-select-permissions

Conversation

@Bosun-Josh121

@Bosun-Josh121 Bosun-Josh121 commented Jun 20, 2026

Copy link
Copy Markdown

Summary

Closes #199

Adds select_permissions for tenant and landlord roles on public.escrows and public.apartments, following the patterns established in public_users.yaml and public_user_wallets.yaml.

Decisions on open product questions

Question Decision
Can a tenant see all available apartments, or only those with an active bid/escrow? All available listings, is_available = true AND deleted_at IS NULL
Does a landlord see escrows via apartment.owner_id or receiver_address? Via apartment.owner_id relationship , works with existing X-Hasura-User-Id session variable, no new JWT claim needed
How are soft-deleted apartments exposed per role? Tenants: completely hidden (filter + deleted_at excluded from column list). Landlords: visible in their own history (deleted_at included in columns, no filter on it)

Permission summary

public.apartments

Role Filter deleted_at visible?
tenant is_available = true AND deleted_at IS NULL No
landlord owner_id = X-Hasura-User-Id Yes (history)

public.escrows

Role Filter unsigned_xdr visible?
tenant sender_address = X-Hasura-User-Wallet Yes (needed to sign the transaction)
landlord apartment.owner_id = X-Hasura-User-Id No (tenant's signing artifact only)

Summary by CodeRabbit

  • Chores
    • Refined access controls for escrow records to adjust data field visibility based on user role permissions.

…ments

Closes safetrustcr#199

Answers the three open product questions from the issue:
- Tenants browse all active (is_available=true, deleted_at IS NULL) apartments;
  landlords see only their own apartments including soft-deleted history.
- Landlords see escrows via apartment.owner_id relationship (X-Hasura-User-Id);
  no new JWT claim needed on the landlord path.
- Tenant escrow filter uses X-Hasura-User-Wallet (sender_address match);
  this claim is deferred to Batch N alongside the JWT migration that replaces
  x-hasura-admin-secret.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3673f086-d3b3-4f0d-9d3d-402e99709236

📥 Commits

Reviewing files that changed from the base of the PR and between be8852b and c046f1c.

📒 Files selected for processing (1)
  • infra/hasura/metadata/tenants/safetrust/databases/tables/public_escrows.yaml

📝 Walkthrough

Walkthrough

Removes unsigned_xdr from the landlord role's select_permissions column allowlist in the Hasura metadata for public.escrows. The tenant role's permissions, which include unsigned_xdr, are unchanged.

Changes

Landlord column allowlist update for escrows

Layer / File(s) Summary
Drop unsigned_xdr from landlord escrow select_permissions
infra/hasura/metadata/tenants/safetrust/databases/tables/public_escrows.yaml
Removes unsigned_xdr from the landlord role's column allowlist so created_at now directly follows status; tenant access to unsigned_xdr is unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related issues

Possibly related PRs

  • safetrustcr/dApp-SafeTrust#206: Directly related — this PR removes unsigned_xdr from the landlord allowlist, building on the initial tenant/landlord select_permissions introduced for public.escrows in that PR.

Suggested reviewers

  • sotoJ24

Poem

🐇 A column snipped, a secret kept,
The landlord's list has lost a step.
unsigned_xdr? Not for thee!
That field belongs to tenants, see.
One line removed, the rules are clear —
The rabbit hops with metadata cheer! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is partially related to the changeset - it mentions implementing role-based permissions for escrows and apartments, which is the main objective, but the visible change only removes unsigned_xdr from landlord permissions rather than adding comprehensive permissions.
Linked Issues check ✅ Passed The PR addresses the requirements from issue #199 by implementing role-based select_permissions for escrows and apartments tables with appropriate column visibility per role, resolving the three open product questions.
Out of Scope Changes check ✅ Passed The change to remove unsigned_xdr from landlord permissions is directly in scope with PR objectives to prevent landlords from accessing tenant signing artifacts while maintaining tenant access for transaction signing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sotoJ24 sotoJ24 self-requested a review June 23, 2026 00:46

@sotoJ24 sotoJ24 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done

@sotoJ24 sotoJ24 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @Bosun-Josh121, please update you're current branch to merge it

@Bosun-Josh121

Copy link
Copy Markdown
Author

@sotoJ24 you merged a PR addressing the same issue

@Bosun-Josh121 Bosun-Josh121 force-pushed the feat/hasura-role-based-select-permissions branch 2 times, most recently from c046f1c to be8852b Compare June 23, 2026 12:27
@sotoJ24

sotoJ24 commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@sotoJ24 you merged a PR addressing the same issue

The issue still open #199

@sotoJ24 sotoJ24 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear @Bosun-Josh121, I made some merge, sorry, could you update you're branch again please, everything else it's amazing, well done, good job

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(hasura): design role-based select_permissions for escrows and apartments tables

2 participants