feat(m7.1): wire tenant claims, status enforcement, and db scoping helper #82
Closed
sharang
wants to merge 2 commits from
feat/m7.1-tenant-claims into main
pull from: feat/m7.1-tenant-claims
merge into: :main
:main
:migrate/ci-breakpilot-tld
:fix/plc-refresh-control-refs
:fix/plc-control-mapping
:fix/refresh-control-refs
:docs/mcp-loop
:fix/mcp-tenant-context
:feat/promote-grounded-controls
:docs/control-mapping
:feat/tune-semantic-retrieval
:fix/embed-batch-chunking
:feat/b3-architectural-controls
:feat/b2-grounded-surface-checks
:feat/b1-cra-semgrep-rules
:feat/semantic-index-cache-autowire
:feat/semantic-control-mapping
:feat/oscal-emit-unmapped-mcp
:feat/grounded-control-check
:feat/oscal-assess-live
:feat/oscal-assessment
:feat/oscal-controls-provider
:feat/werkbank-runnable-loop
:feat/werkbank-exec-crate
:feat/werkbank-runner-endpoints
:feat/werkbank-job-queue
:feat/werkbank-job-contract
:feat/plc-provision-and-test
:docs/plc-runtimes
:docs/plc-soft-plc-architecture
:feat/dast-http-scheme
:feat/enable-optin-scans
:feat/plc-control-logic-scanner
:refactor/rip-out-legacy-repository
:feat/onboarding-validation-edit
:feat/real-nix-firmware-sbom
:fix/bump-tramiton-0.4.1
:feat/firmware-sbom-repro-build
:feat/firmware-sbom-tramiton
:feat/dashboard-targets-dropdowns
:fix/targets-visibility-unified-default
:feat/onboarding-scan-trigger
:fix/ci-concurrency-no-cancel-main
:fix/ci-docker-tramiton-dashboard-mcp
:feat/onboarding-scan-detection
:feat/onboarding-pipeline
:feat/onboarding-wizard
:fix/ci-docker-tramiton-fetch
:feat/onboarding-api
:feat/onboarding-migration
:feat/ci-kellnr-sccache
:feat/onboarding-ingest-classify
:feat/onboarding-foundation
:feat/dashboard-token-refresh
:fix/dashboard-bearer-token
:feat/m7.1-agent-wire
:fix/m7.1-jwks-refresh
:feat/m7.1-smoke-harness
:feat/m7.1-tenant-claims
:feat/light-mode-theme-toggle
:fix/embedding-build-progress
:fix/cve-scan-http-timeout
:fix/scan-resource-limits-and-script-error
:fix/multiple-issues
:feat/cve-alerts
:feat/e2e-tests
:feat/help-chat-widget
:fix/cascade-delete-repo
:feat/refine-llm-prompts
:fix/gitea-pr-review-error-handling
:test/dummy-bad-code
:fix/remove-code-review-from-findings
:feat/pentest-onboarding
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
cb7b1b86f5 |
fix(m7.1): correct middleware layer order so JwksState is visible
CI / Check (pull_request) Successful in 11m31s
CI / Detect Changes (pull_request) Has been skipped
CI / Deploy Agent (pull_request) Has been skipped
CI / Deploy Dashboard (pull_request) Has been skipped
CI / Deploy Docs (pull_request) Has been skipped
CI / Deploy MCP (pull_request) Has been skipped
Axum applies layers outermost-first. With the previous ordering (`Extension(jwks_state)` first, `require_jwt_auth` last), the JWT middleware ran before the Extension layer attached `JwksState` to the request, so `request.extensions().get::<JwksState>()` always returned None and the middleware silently passed through every request as if Keycloak weren't configured. Verified end-to-end against the local CERTifAI Keycloak realm: - no token / bad token -> 401 - active / trial -> 200 read, write reaches handler - frozen -> 200 read, 402 on writes - archived -> 410 on every method The bug was invisible to the unit + integration tests because they construct the layer stack manually; only the live wiring exhibited it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
05c01ea547 |
feat(m7.1): wire tenant claims, status enforcement, and db scoping helper
CI / Check (pull_request) Successful in 10m50s
CI / Detect Changes (pull_request) Has been skipped
CI / Deploy Agent (pull_request) Has been skipped
CI / Deploy Dashboard (pull_request) Has been skipped
CI / Deploy Docs (pull_request) Has been skipped
CI / Deploy MCP (pull_request) Has been skipped
Lays the platform-wide multi-tenancy infrastructure on top of the existing Keycloak signature validation. JWTs now carry tenant_id, tenant_slug, org_roles, products, plan, and tenant_status; the middleware decodes them into a TenantContext and attaches it to the request extensions. A TenantCtx Axum extractor exposes the context to handlers, and a tenant_status middleware enforces the §5c lifecycle (frozen tenants are 402 on writes; archived tenants are 410 on every method). A db::tenant_filter helper in compliance-core gives every future collection a single grep-able pattern for tenant-scoped queries. Per-collection wiring (adding tenant_id to each model + threading the filter through every find/update/delete call) lands in a follow-up. Tests: 6 inline unit tests for claims→context mapping, 2 for the extractor, 6 integration tests for status middleware, 3 for db filter. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |