Skip to content

Add gateway tenant ownership enforcement#79

Merged
chrisbliss18 merged 6 commits into
v2from
stack-07-gateway-tenant
Apr 28, 2026
Merged

Add gateway tenant ownership enforcement#79
chrisbliss18 merged 6 commits into
v2from
stack-07-gateway-tenant

Conversation

@chrisbliss18
Copy link
Copy Markdown
Contributor

Stacked PR 7 of 9.

Base: stack-06-deliverer-openapi-ops
Head: stack-07-gateway-tenant
Previous PR: #78

Summary:

  • Defines the public API tenant boundary.
  • Adds tenant ownership hooks for outbound resources.
  • Enforces gateway tenant context for outbound API resources and site APIs.
  • Imports gateway site tenant mappings.
  • Cleans up gateway docs and lint compatibility.

Review notes:
This PR is intentionally isolated because tenant enforcement changes access-control behavior and should be reviewed independently from the base API mechanics.

Chris Jean added 6 commits April 27, 2026 20:18
Add a planning note for the future gateway-to-Jetmon tenant contract, including request context headers, gateway versus Jetmon ownership checks, public error handling, and migration order.

Link the contract from the internal API docs and roadmap so the next public-API work starts from an explicit boundary instead of inferring tenant rules from the internal-only API.
Add nullable owner_tenant_id columns for webhooks and alert contacts while preserving the existing unscoped internal API behavior.

Thread the owner through repository models and add tenant-scoped CRUD helpers so future gateway-routed handlers can enforce customer ownership without changing delivery workers.
Parse gateway-derived tenant headers only for the gateway consumer, attach the accepted context to API audit metadata, and reject public-context headers from other internal callers.

Use the tenant context to scope webhook and alert-contact CRUD, delivery history, manual retry, and alert-contact send-test paths while keeping normal internal requests unscoped.
Add a jetmon_site_tenants mapping table so gateway-routed site visibility can support shared or delegated ownership without changing the legacy site row.

Scope site, event, stats, and trigger-now handlers through that mapping when gateway context is present, while preserving unscoped behavior for normal internal callers.
Refresh the public API gateway contract and API reference so they describe the tenant ownership checks that now run for gateway-routed requests.

Replace the test-only use of t.Context with context.Background so vet continues to pass under the module's Go 1.22 target, and remove a stale httptest compile guard.
Add a site-tenants import CLI that validates tenant_id,blog_id CSV input, skips duplicate rows, and upserts mappings into jetmon_site_tenants for the gateway ownership backfill path.

Keep the import additive so pruning stale mappings can be handled by a later source-specific reconciliation policy, and update the docs/roadmap to describe that boundary.
@chrisbliss18 chrisbliss18 changed the base branch from stack-06-deliverer-openapi-ops to v2 April 28, 2026 14:55
@chrisbliss18 chrisbliss18 merged commit e7ce3d9 into v2 Apr 28, 2026
@chrisbliss18 chrisbliss18 deleted the stack-07-gateway-tenant branch April 28, 2026 15:08
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.

1 participant