Skip to content

[M2.3c4c1] Manage scoped resource role bindings - #91

Merged
samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.3c4c1-resource-bindings
Nov 5, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
feat/m2.3c4c1-resource-bindings

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Task

M2.3c4c1, stacked on #90. Review in order; no automatic merge.

What changed and why

Add audited project/environment role assignment and removal with fresh password/MFA proof and ordered actor/subject locks. Assignment resolves only an exact existing organization member by email after scope authorization; it cannot add organization membership or grant ownership. New/changed bindings require an active verified member. Removal also works for disabled or subsequently promoted accounts.

Live scope checks honor explicit environment downgrades: a project administrator downgraded in an environment cannot remove that restriction themselves. Removing an override can restore inherited rights, so removal invalidates credentials just like assignment. Self-changes return a rotated session; unchanged/absent grants preserve credential versions and audit proof confirmation.

How it was tested

  • Seven real restricted-PostgreSQL acceptance tests pass: assignment/update/removal, idempotence, all administration scopes, self-demotion, explicit overrides, wrong ancestry/recipients/roles, duplicate concurrency, directory races and audit rollback.
  • Application coverage: 98% statements, 97% branches, 100% functions and lines.
  • API lint, typechecks, 103 unit tests and production build pass.
  • Parent PR [M2.3c4b] Manage memberships and preserve the final owner #90 passed the full integration, browser, generated-contract, Go and enabled security checks. CI runs the expanded suite for this PR.

Security considerations

Scope administrators do not receive a global account directory. Resource ancestry and membership are rechecked under account/organization locks before writing. Binding updates cannot change their tenant, parent resource or membership. Audits and credential invalidation commit together. No new dependency, shell invocation or credential exposure path. CodeQL remains skipped by repository configuration.

Checklist

  • M2.3c4c1 acceptance met; PLAN/SPEC updated
  • Local static checks, tests and build pass
  • Scope escalation, concurrency and rollback acceptance covered
  • Every grant mutation emits an atomic audit event
  • No secrets or generated artifacts edited manually

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.3c4b-membership-commands branch from e536f50 to 407dfb3 Compare November 5, 2026 14:50
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m2.3c4b-membership-commands to main November 5, 2026 14:51
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m2.3c4c1-resource-bindings branch from 90f1fb7 to 189c640 Compare November 5, 2026 14:52
@samuelmbabhazi
samuelmbabhazi merged commit b716736 into main Nov 5, 2026
2 of 11 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m2.3c4c1-resource-bindings branch November 5, 2026 14:52
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
…ed scope (#92)

## Task

M2.3c4c2, stacked on #91. This completes the application-layer M2.3c
slice; HTTP authorization, project tokens and UI remain M2.3d/e/f.
Review in order; no automatic merge.

## What changed and why

Add the organization member directory and scope-authorized resource
administration queries. Resource views distinguish organization
authority, inherited project roles and direct environment overrides,
including inactive members whose grants need cleanup.
Project/environment administrators see only applicable authority; the
full organization directory requires organization-level member
management.

Effective bindings and pagination use one SQL snapshot, avoiding
inconsistent results when a grant changes between membership and
relation queries. Queries select only administration metadata and reuse
the existing bounded, descending-UUID pagination helper.

CI also exposed an existing quota race: a later request could acquire
the shared IP row before an earlier request, producing a spurious 429
even for quotas without progressive delay. Only progressive policies now
check the next-allowed timestamp; count/window limits remain enforced. A
PostgreSQL regression fails before the correction and passes afterward.

## How it was tested

- All 196 real-PostgreSQL integration tests passed before the quota
correction; the five authentication/quota tests pass afterward,
including the new ordering regression.
- Eleven targeted catalog/administration tests pass with 104 members,
direct/inherited roles, explicit downgrades, scope denials, live changes
and pooled-context cleanup.
- New query/pagination application coverage: 100%
statements/functions/lines, 95% branches.
- API/web/domain lint, typechecks, tests and builds pass; Go tests and
buf lint pass.
- All eight Chromium/HTTPS/PostgreSQL browser scenarios pass after the
quota correction.
- Parent PR #91 passed all enabled CI/security and browser checks.
CodeQL remains skipped by repository configuration.

## Security considerations

The actor's current account version and scope authority are checked
within the query transaction. SQL binds every value and includes
organization/project/environment predicates before pagination. Results
include email/active status only for authorized administration; no
credential fields are queried. No new mutation, dependency, shell
invocation or secret exposure path.

## Checklist

- [x] M2.3c4c2 acceptance met; M2.3c marked complete in PLAN
- [x] SPEC documents scope visibility and effective-role fields
- [x] Full integration and local workspace checks pass
- [x] Read-only queries add no state mutation requiring audit
- [x] No secrets or generated artifacts edited manually

## CI execution blocked

GitHub Actions did not start the latest jobs. Its annotation reports
failed recent account payments or an insufficient spending limit. No
runner steps executed. The account owner must resolve Billing & plans
and rerun the workflows; this is not a passing CI result. CodeQL remains
separately disabled by repository configuration.
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
… enrollment errors (#109)

## Task

Review follow-ups for #90, #91 and #102, plus two rule-audit items. Refs
#22

## What changed

**No directory oracle (#90, #91)**
- `AccountMutationAuthority.confirmPassword()` checks the caller's
password without locks.
- `MembershipCommands.add` and `BindingCommands.assign` call it before
answering `resource_not_found` for an unknown address. An unknown
account and a wrong password now give the same 401, so these commands
cannot list the instance's verified accounts or an organization's
members. The success path still pays one Argon2id verification.

**Environment overrides (#91)**
- An administrator of a single environment can no longer create or
remove an environment override for a member who administers the whole
project. Before, the project admin could not undo such a restriction.
- Project admins and organization owners/admins are unaffected.

**Explicit response fields (#102)**
- `resourceDto` spread whole store rows into responses. It is replaced
by `organizationDto`, `projectDto`, `environmentDto`, `memberViewDto`
and `bindingViewDto`, which list every field. A future column cannot
reach session or bearer clients without a DTO change.
- The HTTP test asserts the exact key sets for project and environment
details.

**Rule audit items**
- The agent's enrollment error keeps its gRPC code (wrapped with `%w`)
and still drops the remote text. Its test fails without the fix
(`Unknown`).
- An `eslint-disable` gains its justification.
- SPEC: directory lookup ordering, the environment-override rule
(section 7), and bearer status codes (401 for bad tokens or token-less
routes, 403 for scope gaps checked before any lookup, so nothing leaks).

## How it was tested

- Local gate on the branch: lint, typecheck, unit tests and build for
all projects; go vet, go test and golangci-lint; no generated-code
drift; Semgrep and Prettier.
- New integration tests: same 401 for unknown and existing accounts on
membership add and binding assign; environment admin refused on a
project admin, owner allowed.
- CI is unavailable (account spending limit), so integration tests did
not run.

## Checklist

- [x] Local gate passes
- [x] Tests added
- [x] No new shell invocation and no new secret exposure path
- [x] Audit events unchanged (refused commands write nothing)
- [x] SPEC updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant