feat: prelaunch hardening — auth, rate limiting, SSE, consent, IaC#23
Merged
Conversation
Closes out all six workstreams from .workitems/7.md (prelaunch verification). Summary by area: Security (WS1A + WS1B) - Add INTERNAL_SERVICE_TOKEN end-to-end: KV seeding in seed-keyvault.sh, Bicep injection into core + ai-service appSettings, FastAPI HTTP middleware validating X-Internal-Token on /api/ai/* routes, outbound header forwarded from core (public-api.controller, workflows.service, system-health.service) - Tighten AI service CORS to CORE_API_URL only; remove FRONTEND_URL - Add ipSecurityRestrictions to ai-service (prod only: allow snet-app) - Add pe-ai-service.bicep private endpoint module, wired in after RBAC to avoid Bicep circular dependency; add peSubnetId + vnetId outputs to networking.bicep; add id output to app-service-container.bicep Rate limiting (WS3) - Add RedisService (ioredis, fail-open on outage) + RedisModule (@global) - Rewrite RateLimitInterceptor to use Redis INCR+EXPIRE fixed-window counter; falls back to per-instance in-memory map when Redis is down - Register RedisModule in AppModule; install ioredis package SSE streaming (WS2) - Restructure event_generator in streaming.py to hold a named stream reference; catch asyncio.CancelledError/GeneratorExit and always call stream.aclose() in finally — prevents unclosed-generator leaks on client disconnect Migration concurrency guard - Move migration execution out of TypeORM migrationsRun option - Run migrations at bootstrap (main.ts) behind pg_advisory_lock so concurrent App Service instances serialize DDL; later holders find nothing pending and exit cleanly Analytics / consent (WS5) - Add CookieConsentContext (localStorage-persisted pending/accepted/ declined state) and CookieConsent banner component - Add Analytics component: loads GA4 + Microsoft UET scripts via Next.js Script afterInteractive only after consent is accepted - Wire both into app layout and providers Docs + config (WS6) - Add docs/azure/prelaunch-security-audit.md (9-category WS3/WS4 audit, all GO, including explicit section on Easy Auth being intentionally off) - Update docs/azure/architecture.md: system context diagram, networking paragraph, secret inventory table - Update docs/azure/pipeline.md: two service connections, updated variable group table, new §6 prelaunch checklist with GATE items - Add INTERNAL_SERVICE_TOKEN, NEXT_PUBLIC_GA_MEASUREMENT_ID, NEXT_PUBLIC_MS_UET_TAG_ID to .env.example - Update README infrastructure row: Docker · Azure App Service + Bicep
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.
Closes out all six workstreams from .workitems/7.md (prelaunch verification). Summary by area:
Security (WS1A + WS1B)
Rate limiting (WS3)
SSE streaming (WS2)
Migration concurrency guard
Analytics / consent (WS5)
Docs + config (WS6)