Skip to content

feat(auth): staff accounts that can impersonate any user - #415

Merged
nourshoreibah merged 8 commits into
mainfrom
feat/staff-impersonation-backend
Oct 17, 2026
Merged

nourshoreibah merged 8 commits into
mainfrom
feat/staff-impersonation-backend

Conversation

@nourshoreibah

Copy link
Copy Markdown
Collaborator

Part 2 of 3, stacked on the schema PR. It needs that PR's migrations live before it deploys.

How it works

A staff account keeps its own Cognito token. POST /auth/impersonation {targetUserId, mode} creates a server-side session, and the browser then sends X-Impersonate-Session: <id> alongside the Bearer token. authenticateRequest checks four things:

  • the caller has is_staff
  • the session belongs to that caller
  • the session has not ended and has not expired
  • the target is not a staff account

If all four hold, it returns the target's identity and memberships, with user.impersonator naming the staff account. The RBAC subject, list scoping, /auth/me and entered_by therefore all see only the target, with no per-lambda code.

  • RBAC: RbacSubject.isStaff. One gate in authorizeAny denies a staff subject everything except impersonation:console / impersonation:start. While switched in, the subject is the target's, so a switch can't be chained.
  • dispatch:
    • a read-only session gets a 403 on any non-GET request
    • routes marked impersonation: 'blocked' (the MFA routes, because they act on the caller's own Cognito session, which is the staff account's) refuse impersonated requests in both modes
    • every non-GET impersonated request, refused or not, is passed to onImpersonatedWrite, which calls @branch/store's recordImpersonationAction
    • a failed audit write is reported to Sentry and does not change the response
  • Staff are invisible:
    • filtered out of /users (the list and its count), GET/PATCH/DELETE /users/:id (a staff id gets the same 404 as a missing one), assignable-staff, admin rosters and headcounts, and project member validation
    • the column is never returned
  • Routes (auth lambda, so no new gateway route): GET /auth/impersonation/targets?search=, POST /auth/impersonation, DELETE /auth/impersonation/:sessionId. /auth/me now also returns isStaff and impersonation.
  • Provisioning: make create-staff EMAIL=… NAME=… (in apps/backend) runs AdminCreateUser and then createStaffUser. No route can set is_staff.
  • CORS: X-Impersonate-Session is added to the json() helper and to infrastructure/{aws,preview}/api_gateway.tf. API Gateway answers preflights itself, so the terraform apply must land before the frontend PR ships. Existing preview stacks only pick this up after the label is re-added.

Also adds test(lambdas): read DB_PORT in every e2e fixture pool as its own commit. The default is unchanged. It's what let the e2e suites run against a throwaway Postgres instead of the shared dev DB.

Verification

I ran these locally, against a throwaway Postgres 16 built from the migrations:

  • shared packages: rbac 34, lambda-auth 37, lambda-http 45, store 8, all passing.
  • lambdas: donors 59, expenditures 136, projects 163, reports 143, users 70 all pass. Auth: 89 of 92 pass.
  • The 3 auth failures are the existing register e2e tests. They fetch localhost:3000, and another process held that port on my machine. CI runs its own dev-server there, so they should pass in CI.
  • New auth/test/impersonation.e2e.test.ts covers the whole flow through the real authenticateRequest and dispatch: staff sees only the console, a staff target gets 404, read-only refuses writes and is audited, ending a session gives 401 IMPERSONATION_EXPIRED, no chaining, MFA is blocked, another staff account's session can't be used or ended, and a non-staff caller sending the header gets 403.
  • New tests in users and projects check that staff are hidden.

Not done

  • MFA enforcement for staff logins. A Cognito access token doesn't say whether MFA was used, and login can't invent an MFA_SETUP challenge. Staff can enrol on /profile. Enforcing it needs a separate design, probably a Cognito pre-auth check or making MFA required pool-wide.

🤖 Generated with Claude Code

nourshoreibah and others added 4 commits October 15, 2026 16:28
users.is_staff hides an account from every user-facing query; the two
impersonation tables record each staff switch-in and every write made
while switched in. No FKs on the audit tables so the trail outlives the
users it names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every pool but donors' hardcoded 5432, so a suite could only ever run
against the shared dev database. Reading DB_PORT (default unchanged) lets
a run point at a throwaway Postgres instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A hidden staff account (users.is_staff) holds no rights of its own: the
RBAC gate denies it everything but impersonation:*. It starts a session
against any non-staff user, then sends X-Impersonate-Session beside its own
Bearer token. authenticateRequest swaps in the target's identity and
memberships, so policy, scoping and entered_by all see only the target.

- read_only sessions get a 403 on every non-GET; full sessions act as the
  target. Every non-GET impersonated request, refused or not, is recorded
  in branch.impersonation_actions.
- MFA routes are blocked while impersonating: they act on the caller's own
  Cognito session, which is then the staff account's.
- Staff are filtered from every user list, count, roster, picker and
  member validation, and the column is never returned. A staff id answers
  like a missing one.
- make create-staff provisions one (AdminCreateUser + createStaffUser);
  no route can set is_staff.
- X-Impersonate-Session added to CORS in the lambdas and API Gateway.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

This PR contains a database migration

(no newly added migration files in this PR)

It will be applied to the production database automatically when this PR merges, before the new lambda code is deployed. Please confirm before requesting review:

  • Applied and tested locally. cd apps/backend && make migrate, then run the affected lambda's tests (cd apps/backend/lambdas/<name> && npm test). make show-migrations shows what applied.
  • Safe for the code that is live right now. During the deploy window -- and indefinitely if the deploy fails -- the currently deployed lambdas run against your new schema. Additive changes (CREATE TABLE, nullable ADD COLUMN, CREATE INDEX) are fine in one PR. DROP COLUMN, renames, ADD COLUMN NOT NULL with no default, and new UNIQUE/CHECK/FOREIGN KEY constraints need two merged PRs -- see the expand/contract rules in apps/backend/db/README.md.
  • Kept separate from unrelated changes. A migration PR should ideally contain the migration, the code that needs it, and nothing else. It changes production state, it is the one thing here that redeploying cannot roll back, and a reviewer should be able to see the whole schema change without scrolling past unrelated work.
  • No already-merged migration was edited. Fix an old migration by adding a new one; there is no down.

shared/types/db-types.d.ts is regenerated and pushed to this branch automatically -- don't hand-edit it. Expect one red migrations-fresh check before that commit lands.

This PR also changes 66 files outside apps/backend/db/. If any are unrelated to this schema change, consider splitting them into a separate PR.

@github-actions

Copy link
Copy Markdown
Contributor

Database Types Check Complete

The database schema files were modified, but the regenerated TypeScript types are identical to the existing ones.

No changes were needed and the type definitions are already up to date.

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Database Types Check Complete

The database schema files were modified, but the regenerated TypeScript types are identical to the existing ones.

No changes were needed and the type definitions are already up to date.

Base automatically changed from feat/staff-impersonation-schema to main October 17, 2026 01:12
@nourshoreibah nourshoreibah added the no-review The PR review bot won't run label Oct 17, 2026
@nourshoreibah
nourshoreibah marked this pull request as ready for review October 17, 2026 01:14
nourshoreibah and others added 2 commits October 16, 2026 21:17
RbacSubject.isStaff is required as of this PR; the frontend fixture
builder failed typecheck without it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Terraform Plan 📖 infrastructure/aws

Terraform Initialization ⚙️success

Terraform Validation 🤖success

Terraform Plan 📖success

Show Plan
data.archive_file.lambda_placeholder: Reading...
data.archive_file.lambda_placeholder: Read complete after 0s [id=96878a51e358033297a32b882fd5223cc95fb8a7]
aws_acm_certificate.frontend[0]: Refreshing state... [id=arn:aws:acm:us-east-1:404813129370:certificate/ff647d49-05a1-4ca4-a652-dc48faec1688]
data.infisical_secrets.sentry_folder: Reading...
data.infisical_secrets.grafana_folder: Reading...
data.aws_route53_zone.app[0]: Reading...
aws_api_gateway_rest_api.branch_api: Refreshing state... [id=btt3bl5139]
aws_acm_certificate.api[0]: Refreshing state... [id=arn:aws:acm:us-east-2:404813129370:certificate/836032c9-c55f-461a-b4fb-8e5d76fae957]
aws_dsql_cluster.branch: Refreshing state...
data.aws_region.current: Reading...
aws_cloudfront_function.rewrite_index: Refreshing state... [id=branch-frontend-rewrite-index]
data.aws_region.current: Read complete after 0s [id=us-east-2]
aws_s3_bucket.reports_bucket: Refreshing state... [id=c4c-branch-generated-reports20260830181426405600000001]
aws_iam_role.lambda_role: Refreshing state... [id=branch-lambda-role]
data.infisical_secrets.grafana_folder: Read complete after 0s
aws_ses_domain_identity.app[0]: Refreshing state... [id=branchaccounting.org]
data.infisical_secrets.sentry_folder: Read complete after 0s
data.aws_caller_identity.current: Reading...
data.aws_caller_identity.current: Read complete after 0s [id=404813129370]
aws_cloudfront_origin_access_control.frontend: Refreshing state... [id=E1ZI46GY0YEFAD]
aws_cloudwatch_log_group.lambda["donors"]: Refreshing state... [id=/aws/lambda/branch-donors]
aws_iam_openid_connect_provider.github: Refreshing state... [id=arn:aws:iam::404813129370:oidc-provider/token.actions.githubusercontent.com]
aws_cloudwatch_log_group.lambda["expenditures"]: Refreshing state... [id=/aws/lambda/branch-expenditures]
aws_cloudwatch_log_group.lambda["projects"]: Refreshing state... [id=/aws/lambda/branch-projects]
aws_cloudwatch_log_group.lambda["reports"]: Refreshing state... [id=/aws/lambda/branch-reports]
data.aws_route53_zone.app[0]: Read complete after 0s [id=Z05958263TSNBU4JSXID1]
aws_cloudwatch_log_group.lambda["users"]: Refreshing state... [id=/aws/lambda/branch-users]
aws_cloudwatch_log_group.lambda["auth"]: Refreshing state... [id=/aws/lambda/branch-auth]
aws_s3_bucket.lambda_deployments: Refreshing state... [id=branch-lambda-deployments-404813129370]
aws_s3_bucket.frontend: Refreshing state... [id=branch-frontend-404813129370]
aws_ses_domain_mail_from.app[0]: Refreshing state... [id=branchaccounting.org]
aws_ses_domain_dkim.app[0]: Refreshing state... [id=branchaccounting.org]
aws_api_gateway_gateway_response.cors["DEFAULT_4XX"]: Refreshing state... [id=aggr-btt3bl5139-DEFAULT_4XX]
aws_api_gateway_gateway_response.cors["DEFAULT_5XX"]: Refreshing state... [id=aggr-btt3bl5139-DEFAULT_5XX]
aws_api_gateway_resource.lambda_resources["projects"]: Refreshing state... [id=5rlpdk]
aws_api_gateway_resource.lambda_resources["reports"]: Refreshing state... [id=fbius2]
aws_api_gateway_resource.lambda_resources["donors"]: Refreshing state... [id=ooaugc]
aws_api_gateway_resource.lambda_resources["expenditures"]: Refreshing state... [id=x3f6cx]
aws_api_gateway_resource.lambda_resources["auth"]: Refreshing state... [id=j2bjjp]
aws_api_gateway_resource.lambda_resources["users"]: Refreshing state... [id=r6frgh]
data.aws_iam_policy_document.ci_plan_assume: Reading...
data.aws_iam_policy_document.ci_plan_assume: Read complete after 0s [id=1050147292]
data.aws_iam_policy_document.ci_apply_assume: Reading...
data.aws_iam_policy_document.ci_migrate_assume: Reading...
data.aws_iam_policy_document.ci_migrate_assume: Read complete after 0s [id=3606114350]
data.aws_iam_policy_document.ci_apply_assume: Read complete after 0s [id=3235391464]
data.aws_iam_policy_document.ci_preview_assume: Reading...
aws_iam_role.ci_plan: Refreshing state... [id=branch-ci-plan]
data.aws_iam_policy_document.ci_preview_assume: Read complete after 0s [id=245163413]
aws_iam_role.ci_migrate: Refreshing state... [id=branch-ci-migrate]
aws_iam_role.ci_apply: Refreshing state... [id=branch-ci-apply]
aws_route53_record.spf[0]: Refreshing state... [id=Z05958263TSNBU4JSXID1_branchaccounting.org_TXT]
aws_route53_record.ses_verification[0]: Refreshing state... [id=Z05958263TSNBU4JSXID1__amazonses.branchaccounting.org_TXT]
aws_route53_record.ses_dkim[1]: Refreshing state... [id=Z05958263TSNBU4JSXID1_yka5xbfuragci7thfnkbnpsibjvkkbu7._domainkey.branchaccounting.org_CNAME]
aws_route53_record.ses_dkim[2]: Refreshing state... [id=Z05958263TSNBU4JSXID1_4ngjy5faumusypdxako3jdie73lihmud._domainkey.branchaccounting.org_CNAME]
aws_route53_record.ses_dkim[0]: Refreshing state... [id=Z05958263TSNBU4JSXID1_um5rslhbpotxdh2ojg7ho3ajwkz4ouom._domainkey.branchaccounting.org_CNAME]
aws_route53_record.ses_mail_from_mx[0]: Refreshing state... [id=Z05958263TSNBU4JSXID1_mail.branchaccounting.org_MX]
aws_route53_record.ses_mail_from_spf[0]: Refreshing state... [id=Z05958263TSNBU4JSXID1_mail.branchaccounting.org_TXT]
aws_route53_record.frontend_cert_validation["branchaccounting.org"]: Refreshing state... [id=Z05958263TSNBU4JSXID1__6e4f9a0f55e3f295054f4aebd1cde0c8.branchaccounting.org._CNAME]
aws_route53_record.dmarc[0]: Refreshing state... [id=Z05958263TSNBU4JSXID1__dmarc.branchaccounting.org_TXT]
aws_route53_record.api_cert_validation["api.branchaccounting.org"]: Refreshing state... [id=Z05958263TSNBU4JSXID1__4fac00187cd968edbe71cbc7664d4601.api.branchaccounting.org._CNAME]
aws_iam_role.ci_preview: Refreshing state... [id=branch-ci-preview]
aws_iam_role_policy.lambda_dsql_connect: Refreshing state... [id=branch-lambda-role:branch-lambda-dsql-connect]
aws_iam_role_policy.lambda_ses_send: Refreshing state... [id=branch-lambda-role:branch-lambda-ses-send]
aws_iam_role_policy_attachment.lambda_basic: Refreshing state... [id=branch-lambda-role/arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole]
aws_api_gateway_resource.lambda_proxy["projects"]: Refreshing state... [id=zofyad]
aws_api_gateway_resource.lambda_proxy["auth"]: Refreshing state... [id=7tjm3k]
aws_api_gateway_resource.lambda_proxy["reports"]: Refreshing state... [id=qpfkcg]
aws_api_gateway_resource.lambda_proxy["donors"]: Refreshing state... [id=37l1nw]
aws_api_gateway_resource.lambda_proxy["users"]: Refreshing state... [id=0s4etn]
aws_api_gateway_resource.lambda_proxy["expenditures"]: Refreshing state... [id=2haqg7]
aws_api_gateway_method.lambda_methods["expenditures-POST"]: Refreshing state... [id=agm-btt3bl5139-x3f6cx-POST]
aws_api_gateway_method.lambda_methods["users-OPTIONS"]: Refreshing state... [id=agm-btt3bl5139-r6frgh-OPTIONS]
aws_api_gateway_method.lambda_methods["users-GET"]: Refreshing state... [id=agm-btt3bl5139-r6frgh-GET]
aws_api_gateway_method.lambda_methods["projects-GET"]: Refreshing state... [id=agm-btt3bl5139-5rlpdk-GET]
aws_api_gateway_method.lambda_methods["reports-POST"]: Refreshing state... [id=agm-btt3bl5139-fbius2-POST]
aws_api_gateway_method.lambda_methods["users-DELETE"]: Refreshing state... [id=agm-btt3bl5139-r6frgh-DELETE]
aws_api_gateway_method.lambda_methods["projects-POST"]: Refreshing state... [id=agm-btt3bl5139-5rlpdk-POST]
aws_api_gateway_method.lambda_methods["reports-OPTIONS"]: Refreshing state... [id=agm-btt3bl5139-fbius2-OPTIONS]
aws_api_gateway_method.lambda_methods["auth-POST"]: Refreshing state... [id=agm-btt3bl5139-j2bjjp-POST]
aws_api_gateway_method.lambda_methods["expenditures-GET"]: Refreshing state... [id=agm-btt3bl5139-x3f6cx-GET]
aws_api_gateway_method.lambda_methods["auth-GET"]: Refreshing state... [id=agm-btt3bl5139-j2bjjp-GET]
aws_api_gateway_method.lambda_methods["users-PATCH"]: Refreshing state... [id=agm-btt3bl5139-r6frgh-PATCH]
aws_api_gateway_method.lambda_methods["expenditures-PATCH"]: Refreshing state... [id=agm-btt3bl5139-x3f6cx-PATCH]
aws_api_gateway_method.lambda_methods["donors-POST"]: Refreshing state... [id=agm-btt3bl5139-ooaugc-POST]
aws_api_gateway_method.lambda_methods["donors-OPTIONS"]: Refreshing state... [id=agm-btt3bl5139-ooaugc-OPTIONS]
aws_api_gateway_method.lambda_methods["projects-OPTIONS"]: Refreshing state... [id=agm-btt3bl5139-5rlpdk-OPTIONS]
aws_api_gateway_method.lambda_methods["auth-OPTIONS"]: Refreshing state... [id=agm-btt3bl5139-j2bjjp-OPTIONS]
aws_api_gateway_method.lambda_methods["donors-GET"]: Refreshing state... [id=agm-btt3bl5139-ooaugc-GET]
aws_api_gateway_method.lambda_methods["users-POST"]: Refreshing state... [id=agm-btt3bl5139-r6frgh-POST]
aws_api_gateway_method.lambda_methods["expenditures-OPTIONS"]: Refreshing state... [id=agm-btt3bl5139-x3f6cx-OPTIONS]
aws_api_gateway_method.lambda_methods["reports-GET"]: Refreshing state... [id=agm-btt3bl5139-fbius2-GET]
aws_iam_role_policy.lambda_s3_objects: Refreshing state... [id=branch-lambda-role:branch-lambda-s3-objects]
aws_s3_bucket_public_access_block.reports_bucket_public_access: Refreshing state... [id=c4c-branch-generated-reports20260830181426405600000001]
aws_iam_role_policy_attachment.ci_apply_admin: Refreshing state... [id=branch-ci-apply/arn:aws:iam::aws:policy/AdministratorAccess]
aws_iam_role_policy_attachment.ci_plan_readonly: Refreshing state... [id=branch-ci-plan/arn:aws:iam::aws:policy/ReadOnlyAccess]
aws_iam_role_policy.ci_plan_state_lock: Refreshing state... [id=branch-ci-plan:tfstate-lock]
aws_iam_role_policy_attachment.ci_plan_dsql_readonly: Refreshing state... [id=branch-ci-plan/arn:aws:iam::aws:policy/AmazonAuroraDSQLReadOnlyAccess]
aws_acm_certificate_validation.frontend[0]: Refreshing state... [id=2026-10-14 22:54:31.121 +0000 UTC]
aws_acm_certificate_validation.api[0]: Refreshing state... [id=2026-10-14 22:54:35.419 +0000 UTC]
aws_api_gateway_method.lambda_proxy_any["expenditures"]: Refreshing state... [id=agm-btt3bl5139-2haqg7-ANY]
aws_api_gateway_method.lambda_proxy_any["auth"]: Refreshing state... [id=agm-btt3bl5139-7tjm3k-ANY]
aws_api_gateway_method.lambda_proxy_any["users"]: Refreshing state... [id=agm-btt3bl5139-0s4etn-ANY]
aws_api_gateway_method.lambda_proxy_any["projects"]: Refreshing state... [id=agm-btt3bl5139-zofyad-ANY]
aws_api_gateway_method.lambda_proxy_any["donors"]: Refreshing state... [id=agm-btt3bl5139-37l1nw-ANY]
aws_api_gateway_method.lambda_proxy_any["reports"]: Refreshing state... [id=agm-btt3bl5139-qpfkcg-ANY]
aws_api_gateway_method.cors_proxy_options["users"]: Refreshing state... [id=agm-btt3bl5139-0s4etn-OPTIONS]
aws_api_gateway_method.cors_proxy_options["donors"]: Refreshing state... [id=agm-btt3bl5139-37l1nw-OPTIONS]
aws_api_gateway_method.cors_proxy_options["expenditures"]: Refreshing state... [id=agm-btt3bl5139-2haqg7-OPTIONS]
aws_api_gateway_method.cors_proxy_options["auth"]: Refreshing state... [id=agm-btt3bl5139-7tjm3k-OPTIONS]
aws_api_gateway_method.cors_proxy_options["projects"]: Refreshing state... [id=agm-btt3bl5139-zofyad-OPTIONS]
aws_api_gateway_method.cors_proxy_options["reports"]: Refreshing state... [id=agm-btt3bl5139-qpfkcg-OPTIONS]
aws_iam_role_policy.ci_preview: Refreshing state... [id=branch-ci-preview:preview-env]
aws_s3_bucket_server_side_encryption_configuration.lambda_deployments: Refreshing state... [id=branch-lambda-deployments-404813129370]
aws_s3_bucket_versioning.lambda_deployments: Refreshing state... [id=branch-lambda-deployments-404813129370]
aws_s3_object.lambda_placeholder["users"]: Refreshing state... [id=branch-lambda-deployments-404813129370/users/initial.zip]
aws_s3_object.lambda_placeholder["auth"]: Refreshing state... [id=branch-lambda-deployments-404813129370/auth/initial.zip]
aws_s3_object.lambda_placeholder["donors"]: Refreshing state... [id=branch-lambda-deployments-404813129370/donors/initial.zip]
aws_s3_object.lambda_placeholder["projects"]: Refreshing state... [id=branch-lambda-deployments-404813129370/projects/initial.zip]
aws_s3_object.lambda_placeholder["expenditures"]: Refreshing state... [id=branch-lambda-deployments-404813129370/expenditures/initial.zip]
aws_s3_object.lambda_placeholder["reports"]: Refreshing state... [id=branch-lambda-deployments-404813129370/reports/initial.zip]
aws_s3_bucket_public_access_block.frontend: Refreshing state... [id=branch-frontend-404813129370]
aws_api_gateway_domain_name.api[0]: Refreshing state... [id=api.branchaccounting.org]
aws_cloudfront_distribution.frontend: Refreshing state... [id=EOTKQTE3WUELO]
aws_api_gateway_method_response.cors["auth-proxy"]: Refreshing state... [id=agmr-btt3bl5139-7tjm3k-OPTIONS-200]
aws_api_gateway_method_response.cors["auth"]: Refreshing state... [id=agmr-btt3bl5139-j2bjjp-OPTIONS-200]
aws_api_gateway_method_response.cors["expenditures-proxy"]: Refreshing state... [id=agmr-btt3bl5139-2haqg7-OPTIONS-200]
aws_api_gateway_method_response.cors["reports-proxy"]: Refreshing state... [id=agmr-btt3bl5139-qpfkcg-OPTIONS-200]
aws_api_gateway_method_response.cors["donors"]: Refreshing state... [id=agmr-btt3bl5139-ooaugc-OPTIONS-200]
aws_api_gateway_method_response.cors["users"]: Refreshing state... [id=agmr-btt3bl5139-r6frgh-OPTIONS-200]
aws_api_gateway_method_response.cors["projects"]: Refreshing state... [id=agmr-btt3bl5139-5rlpdk-OPTIONS-200]
aws_api_gateway_method_response.cors["reports"]: Refreshing state... [id=agmr-btt3bl5139-fbius2-OPTIONS-200]
aws_api_gateway_method_response.cors["donors-proxy"]: Refreshing state... [id=agmr-btt3bl5139-37l1nw-OPTIONS-200]
aws_api_gateway_method_response.cors["projects-proxy"]: Refreshing state... [id=agmr-btt3bl5139-zofyad-OPTIONS-200]
aws_api_gateway_method_response.cors["expenditures"]: Refreshing state... [id=agmr-btt3bl5139-x3f6cx-OPTIONS-200]
aws_api_gateway_method_response.cors["users-proxy"]: Refreshing state... [id=agmr-btt3bl5139-0s4etn-OPTIONS-200]
aws_api_gateway_integration.cors["expenditures"]: Refreshing state... [id=agi-btt3bl5139-x3f6cx-OPTIONS]
aws_api_gateway_integration.cors["projects"]: Refreshing state... [id=agi-btt3bl5139-5rlpdk-OPTIONS]
aws_api_gateway_integration.cors["projects-proxy"]: Refreshing state... [id=agi-btt3bl5139-zofyad-OPTIONS]
aws_api_gateway_integration.cors["donors-proxy"]: Refreshing state... [id=agi-btt3bl5139-37l1nw-OPTIONS]
aws_api_gateway_integration.cors["users-proxy"]: Refreshing state... [id=agi-btt3bl5139-0s4etn-OPTIONS]
aws_api_gateway_integration.cors["expenditures-proxy"]: Refreshing state... [id=agi-btt3bl5139-2haqg7-OPTIONS]
aws_api_gateway_integration.cors["reports"]: Refreshing state... [id=agi-btt3bl5139-fbius2-OPTIONS]
aws_api_gateway_integration.cors["users"]: Refreshing state... [id=agi-btt3bl5139-r6frgh-OPTIONS]
aws_api_gateway_integration.cors["auth-proxy"]: Refreshing state... [id=agi-btt3bl5139-7tjm3k-OPTIONS]
aws_api_gateway_integration.cors["reports-proxy"]: Refreshing state... [id=agi-btt3bl5139-qpfkcg-OPTIONS]
aws_api_gateway_integration.cors["auth"]: Refreshing state... [id=agi-btt3bl5139-j2bjjp-OPTIONS]
aws_api_gateway_integration.cors["donors"]: Refreshing state... [id=agi-btt3bl5139-ooaugc-OPTIONS]
aws_route53_record.api[0]: Refreshing state... [id=Z05958263TSNBU4JSXID1_api.branchaccounting.org_A]
data.aws_iam_policy_document.frontend_bucket: Reading...
data.aws_iam_policy_document.frontend_bucket: Read complete after 0s [id=1913669945]
aws_s3_bucket_cors_configuration.reports_bucket_cors: Refreshing state... [id=c4c-branch-generated-reports20260830181426405600000001]
aws_route53_record.frontend[0]: Refreshing state... [id=Z05958263TSNBU4JSXID1_branchaccounting.org_A]
aws_s3_bucket_policy.frontend: Refreshing state... [id=branch-frontend-404813129370]
aws_cognito_user_pool.branch_user_pool: Refreshing state... [id=us-east-2_ES8vlp7b4]
aws_iam_role_policy.lambda_cognito_admin: Refreshing state... [id=branch-lambda-role:branch-lambda-cognito-admin]
aws_cognito_user_pool_client.branch_client: Refreshing state... [id=26r3n4d9ttjp6fvhdg1erd2eli]
aws_lambda_function.functions["reports"]: Refreshing state... [id=branch-reports]
aws_lambda_function.functions["donors"]: Refreshing state... [id=branch-donors]
aws_lambda_function.functions["users"]: Refreshing state... [id=branch-users]
aws_lambda_function.functions["auth"]: Refreshing state... [id=branch-auth]
aws_lambda_function.functions["expenditures"]: Refreshing state... [id=branch-expenditures]
aws_lambda_function.functions["projects"]: Refreshing state... [id=branch-projects]
aws_iam_role_policy.ci_migrate: Refreshing state... [id=branch-ci-migrate:db-migrate]
aws_api_gateway_integration.lambda_proxy_integrations["donors"]: Refreshing state... [id=agi-btt3bl5139-37l1nw-ANY]
aws_api_gateway_integration.lambda_proxy_integrations["auth"]: Refreshing state... [id=agi-btt3bl5139-7tjm3k-ANY]
aws_api_gateway_integration.lambda_proxy_integrations["expenditures"]: Refreshing state... [id=agi-btt3bl5139-2haqg7-ANY]
aws_api_gateway_integration.lambda_proxy_integrations["users"]: Refreshing state... [id=agi-btt3bl5139-0s4etn-ANY]
aws_api_gateway_integration.lambda_proxy_integrations["reports"]: Refreshing state... [id=agi-btt3bl5139-qpfkcg-ANY]
aws_api_gateway_integration.lambda_proxy_integrations["projects"]: Refreshing state... [id=agi-btt3bl5139-zofyad-ANY]
aws_api_gateway_integration.lambda_integrations["users-DELETE"]: Refreshing state... [id=agi-btt3bl5139-r6frgh-DELETE]
aws_api_gateway_integration.lambda_integrations["auth-GET"]: Refreshing state... [id=agi-btt3bl5139-j2bjjp-GET]
aws_api_gateway_integration.lambda_integrations["donors-POST"]: Refreshing state... [id=agi-btt3bl5139-ooaugc-POST]
aws_api_gateway_integration.lambda_integrations["auth-POST"]: Refreshing state... [id=agi-btt3bl5139-j2bjjp-POST]
aws_api_gateway_integration.lambda_integrations["expenditures-GET"]: Refreshing state... [id=agi-btt3bl5139-x3f6cx-GET]
aws_api_gateway_integration.lambda_integrations["users-POST"]: Refreshing state... [id=agi-btt3bl5139-r6frgh-POST]
aws_api_gateway_integration.lambda_integrations["users-PATCH"]: Refreshing state... [id=agi-btt3bl5139-r6frgh-PATCH]
aws_api_gateway_integration.lambda_integrations["projects-POST"]: Refreshing state... [id=agi-btt3bl5139-5rlpdk-POST]
aws_api_gateway_integration.lambda_integrations["reports-POST"]: Refreshing state... [id=agi-btt3bl5139-fbius2-POST]
aws_api_gateway_integration.lambda_integrations["projects-GET"]: Refreshing state... [id=agi-btt3bl5139-5rlpdk-GET]
aws_api_gateway_integration.lambda_integrations["expenditures-POST"]: Refreshing state... [id=agi-btt3bl5139-x3f6cx-POST]
aws_api_gateway_integration.lambda_integrations["expenditures-PATCH"]: Refreshing state... [id=agi-btt3bl5139-x3f6cx-PATCH]
aws_api_gateway_integration.lambda_integrations["users-GET"]: Refreshing state... [id=agi-btt3bl5139-r6frgh-GET]
aws_api_gateway_integration.lambda_integrations["reports-GET"]: Refreshing state... [id=agi-btt3bl5139-fbius2-GET]
aws_api_gateway_integration.lambda_integrations["donors-GET"]: Refreshing state... [id=agi-btt3bl5139-ooaugc-GET]
aws_lambda_permission.api_gateway_permissions["users"]: Refreshing state... [id=AllowAPIGatewayInvoke]
aws_lambda_permission.api_gateway_permissions["expenditures"]: Refreshing state... [id=AllowAPIGatewayInvoke]
aws_lambda_permission.api_gateway_permissions["projects"]: Refreshing state... [id=AllowAPIGatewayInvoke]
aws_lambda_permission.api_gateway_permissions["auth"]: Refreshing state... [id=AllowAPIGatewayInvoke]
aws_lambda_permission.api_gateway_permissions["donors"]: Refreshing state... [id=AllowAPIGatewayInvoke]
aws_lambda_permission.api_gateway_permissions["reports"]: Refreshing state... [id=AllowAPIGatewayInvoke]
aws_api_gateway_integration_response.cors["expenditures-proxy"]: Refreshing state... [id=agir-btt3bl5139-2haqg7-OPTIONS-200]
aws_api_gateway_integration_response.cors["reports"]: Refreshing state... [id=agir-btt3bl5139-fbius2-OPTIONS-200]
aws_api_gateway_integration_response.cors["auth-proxy"]: Refreshing state... [id=agir-btt3bl5139-7tjm3k-OPTIONS-200]
aws_api_gateway_integration_response.cors["donors-proxy"]: Refreshing state... [id=agir-btt3bl5139-37l1nw-OPTIONS-200]
aws_api_gateway_integration_response.cors["projects"]: Refreshing state... [id=agir-btt3bl5139-5rlpdk-OPTIONS-200]
aws_api_gateway_integration_response.cors["projects-proxy"]: Refreshing state... [id=agir-btt3bl5139-zofyad-OPTIONS-200]
aws_api_gateway_integration_response.cors["donors"]: Refreshing state... [id=agir-btt3bl5139-ooaugc-OPTIONS-200]
aws_api_gateway_integration_response.cors["expenditures"]: Refreshing state... [id=agir-btt3bl5139-x3f6cx-OPTIONS-200]
aws_api_gateway_integration_response.cors["users"]: Refreshing state... [id=agir-btt3bl5139-r6frgh-OPTIONS-200]
aws_api_gateway_integration_response.cors["users-proxy"]: Refreshing state... [id=agir-btt3bl5139-0s4etn-OPTIONS-200]
aws_api_gateway_integration_response.cors["reports-proxy"]: Refreshing state... [id=agir-btt3bl5139-qpfkcg-OPTIONS-200]
aws_api_gateway_integration_response.cors["auth"]: Refreshing state... [id=agir-btt3bl5139-j2bjjp-OPTIONS-200]
aws_api_gateway_deployment.branch_deployment: Refreshing state... [id=etptwb]
aws_api_gateway_stage.branch_stage: Refreshing state... [id=ags-btt3bl5139-prod]
aws_api_gateway_base_path_mapping.api[0]: Refreshing state... [id=api.branchaccounting.org/]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
+/- create replacement and then destroy

Terraform will perform the following actions:

  # aws_api_gateway_deployment.branch_deployment must be replaced
+/- resource "aws_api_gateway_deployment" "branch_deployment" {
      ~ created_date = "2026-10-16T23:03:24Z" -> (known after apply)
      ~ id           = "etptwb" -> (known after apply)
      ~ triggers     = { # forces replacement
          ~ "redeploy" = "131e666e1b020b84dc026207d7d9ac76833c5174" -> "89c871fe9fcfe2423f6edcf4336aae189170b526"
        }
        # (3 unchanged attributes hidden)
    }

  # aws_api_gateway_gateway_response.cors["DEFAULT_4XX"] will be updated in-place
  ~ resource "aws_api_gateway_gateway_response" "cors" {
        id                  = "aggr-btt3bl5139-DEFAULT_4XX"
      ~ response_parameters = {
          ~ "gatewayresponse.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (2 unchanged elements hidden)
        }
        # (5 unchanged attributes hidden)
    }

  # aws_api_gateway_gateway_response.cors["DEFAULT_5XX"] will be updated in-place
  ~ resource "aws_api_gateway_gateway_response" "cors" {
        id                  = "aggr-btt3bl5139-DEFAULT_5XX"
      ~ response_parameters = {
          ~ "gatewayresponse.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (2 unchanged elements hidden)
        }
        # (5 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["auth"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-j2bjjp-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["auth-proxy"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-7tjm3k-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["donors"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-ooaugc-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["donors-proxy"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-37l1nw-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["expenditures"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-x3f6cx-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["expenditures-proxy"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-2haqg7-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["projects"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-5rlpdk-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["projects-proxy"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-zofyad-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["reports"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-fbius2-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["reports-proxy"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-qpfkcg-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["users"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-r6frgh-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_integration_response.cors["users-proxy"] will be updated in-place
  ~ resource "aws_api_gateway_integration_response" "cors" {
        id                  = "agir-btt3bl5139-0s4etn-OPTIONS-200"
      ~ response_parameters = {
          ~ "method.response.header.Access-Control-Allow-Headers" = "'Content-Type,Authorization'" -> "'Content-Type,Authorization,X-Impersonate-Session'"
            # (3 unchanged elements hidden)
        }
        # (8 unchanged attributes hidden)
    }

  # aws_api_gateway_stage.branch_stage will be updated in-place
  ~ resource "aws_api_gateway_stage" "branch_stage" {
      ~ deployment_id         = "etptwb" -> (known after apply)
        id                    = "ags-btt3bl5139-prod"
        tags                  = {}
        # (15 unchanged attributes hidden)
    }

Plan: 1 to add, 15 to change, 1 to destroy.

─────────────────────────────────────────────────────────────────────────────

Saved the plan to: tfplan

To perform exactly these actions, run the following command to apply:
    terraform apply "tfplan"

Pushed by: @nourshoreibah, Action: pull_request

@nourshoreibah
nourshoreibah merged commit 4e3ccdc into main Oct 17, 2026
17 checks passed
@nourshoreibah
nourshoreibah deleted the feat/staff-impersonation-backend branch October 17, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-review The PR review bot won't run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant