Repository navigation
feat(teams): preview a member's or role's vault permissions - #151
Merged
Merged
Conversation
…ject unknown request keys; dedupe preview code and tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
POST /v1/teams/:team_id/permissions/preview. It returns what a team member, or a role, can see and do in the team vault, and optionally what that would become under an unsaved draft. The client uses it for a read-only "View as" mode and for "Preview as role". Nothing is written. Saving still goes through the existing member and role endpoints.Request
subject:{ "type": "member", "user_id" }or{ "type": "role", "role_id" }draft(optional):{ "role_ids", "allow", "deny" }{ "permissions" }ALL_PERMISSIONS.scope:"full"(default) or"vault_key_gate"Gates
Gates run in this order, before the subject is looked up:
MANAGE_MEMBERS. A role subject needsMANAGE_ROLES.vault_key_gateis never plan-gated, so the Teams-plan "this removes their vault key" warning keeps working.Response
{ locked, current, draft, affected }, where each preview is{ team_bits, objects: { id: { mask, rule_set_id } }, rule_sets: { id: layers }, holds_vault_key_gate }.objectsonly lists objects the caller can view.rule_setsonly lists sets where the caller has object-levelMANAGE_ROLES, so a folder locked against managers stays locked.affectedlists the holders whose visible masks change and the holders who would lose the vault key.vault_key_gatescope returns emptyobjects/rule_sets.Status codes
fullscope below Businessrole_idsentry from another teamdeny_unknown_fields), so a typo such asscopis a 422, not a silent default.Other changes
recheck_scopeskips this endpoint. It is a read-only POST that the client refetches on every draft edit. Without the skip, each call re-checked every live terminal session in the team. Real permission writes still trigger the re-check.compose_member_row,preview_for,object_refsinobject_authz.rs), so the preview cannot drift from enforcement.Tests
cargo test --bin voltius-serveragainst a test database: 1070 passed.cargo clippy --all-targets -- -D warnings: clean.Capability
GET /v1/metaadvertisespermission_preview: true. A server without the route answers a bare 404, the same as a missing member, so clients read support from meta instead of guessing from a 404.