Skip to content

feat(ai): authenticate proposal audit through signed gateway context - #109

Merged
seonghobae merged 112 commits into
mainfrom
feat/ai-authenticated-gateway-context
Aug 4, 2026
Merged

feat(ai): authenticate proposal audit through signed gateway context#109
seonghobae merged 112 commits into
mainfrom
feat/ai-authenticated-gateway-context

Conversation

@seonghobae

@seonghobae seonghobae commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Completes the next ai.auditable-proposals trust-boundary slice after #105.

  • derives workspace and actor identity only from authenticated identity-service session introspection
  • adds a same-origin web BFF for proposal generation, proposal history, proposal detail, decision history, and accept/reject decisions
  • signs short-lived HMAC-SHA-256 service context bound to workspace, actor, issuance time, uppercase method, and exact AI path
  • rejects direct client-selected ownership headers, stale/forged context, and method/path replay at AI service
  • bounds cookies, browser JSON, origins, dependency streams, response shapes, timeouts, and credential-free RFC 9457 problems
  • preserves inert proposal operations and append-only decision evidence with no apply/execute route
  • keeps AI service independently deployable behind any compatible trusted proxy
  • records current RFC, NIST, and OWASP ASVS 5.0.0 research with APA 7 references
  • enforces 100% AI-service statement, branch, function, and line coverage

Capability boundary

The shared HMAC secret authenticates the private proxy workload, not the end user. The proxy must authenticate the identity session and authorize workspace membership before signing. Browser credentials are sent only to identity-service. Proposal and decision operations remain inert audit evidence and do not execute user-data commands. Multi-key rotation, asymmetric workload identity, external model transport, and separately authorized execution remain independent reviewed slices.

Validation gate

Merge only when formatting, lint, type checking, complete coverage, PostgreSQL integration tests, build, Compose validation, AppGuardrail, SAST Semgrep, Security Scan, Commercial Readiness, CodeRabbit, and all human/security review feedback pass on the exact current head with no unresolved actionable finding.

Closes #108.
Refs #46, #21, and #105.

Summary by CodeRabbit

릴리스 노트

  • 보안 강화

    • AI 제안 요청에 HMAC 기반 암호화 서명 인증 추가
    • 브라우저 자격증명 격리 및 메서드/경로 바인딩을 통한 요청 위변조 방지
  • 설정 변경

    • 새로운 환경 설정 변수 추가: AI_SERVICE_ORIGIN, AI_GATEWAY_CONTEXT_SECRET
  • 테스트 및 검증

    • AI 제안 및 감사 기능에 대한 포괄적인 인증 테스트 추가

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a84d79d6-c55b-4b46-bfef-7f72935065db

📥 Commits

Reviewing files that changed from the base of the PR and between 41ed8d7 and c97780c.

📒 Files selected for processing (23)
  • .env.example
  • CHANGELOG.md
  • apps/ai-service/migrations/README.md
  • apps/ai-service/src/ai-http-boundary.test.ts
  • apps/ai-service/src/ai-http-boundary.ts
  • apps/ai-service/src/main.ts
  • apps/ai-service/src/no-silent-mutation.integration.test.ts
  • apps/ai-service/src/proposal-audit-http.integration.test.ts
  • apps/ai-service/src/quality-coverage.test.ts
  • apps/ai-service/src/runtime-wiring-coverage.test.ts
  • apps/web/app/ai-proposal-client-core.ts
  • apps/web/app/ai-proposal-client.test.ts
  • apps/web/app/ai-proposal-client.ts
  • apps/web/app/ai-proposal-identity-stream-regression.test.ts
  • apps/web/app/ai-proposal-scope-regression.test.ts
  • apps/web/app/api/ai/proposals/[proposalId]/decisions/route.ts
  • apps/web/app/api/ai/proposals/[proposalId]/route.ts
  • apps/web/app/api/ai/proposals/route.ts
  • apps/web/app/api/ai/proposals/routes.test.ts
  • apps/web/package.json
  • docs/research/2026-08-04-ai-gateway-context-standards.md
  • docs/superpowers/plans/2026-08-04-ai-authenticated-gateway-context.md
  • docs/superpowers/specs/2026-08-04-ai-authenticated-gateway-context-design.md

📝 Walkthrough

Walkthrough

AI 제안 요청에 세션 기반 workspace·actor 범위와 단기 HMAC 컨텍스트 검증을 적용했습니다. 웹 BFF와 Next.js 라우트를 추가하고, AI 서비스 엔드포인트와 테스트·운영 문서를 갱신했습니다.

Changes

AI 제안 인증 경계

Layer / File(s) Summary
HMAC 컨텍스트 검증과 AI 서비스 연결
apps/ai-service/src/ai-http-boundary.ts, apps/ai-service/src/main.ts, apps/ai-service/src/*integration.test.ts, apps/ai-service/src/quality-coverage.test.ts
AI 서비스가 workspace, actor, 발급 시각, HTTP 메서드, 정확한 경로와 HMAC 서명을 검증합니다. 검증된 식별자를 제안·감사 엔드포인트에 전달합니다.
세션 기반 BFF와 범위 검증
apps/web/app/ai-proposal-client-core.ts, apps/web/app/ai-proposal-client.ts, apps/web/app/ai-proposal-client.test.ts, apps/web/app/*regression.test.ts
BFF가 identity 세션에서 workspace와 actor를 추출하고 브라우저 자격 증명을 AI 서비스에 전달하지 않습니다. 요청·응답 크기, 형식, 범위와 오류를 검증합니다.
Next.js API 라우트 위임
apps/web/app/api/ai/proposals/..., apps/web/app/api/ai/proposals/routes.test.ts
제안 목록·생성·상세 조회와 결정 조회·추가 라우트를 공통 BFF 핸들러에 위임합니다. 테스트는 upstream 메서드와 경로를 확인합니다.
환경·운영 계약과 검증 범위
.env.example, apps/ai-service/migrations/README.md, docs/research/*, docs/superpowers/*, CHANGELOG.md, apps/web/package.json, apps/ai-service/src/runtime-wiring-coverage.test.ts
AI 서비스 origin, gateway secret, 키 교체 절차, 신뢰 프록시 계약, 런타임 wiring과 테스트 명령을 문서화하고 등록합니다.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related issues

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant NextRoutes
  participant IdentityService
  participant AiProposalClient
  participant AiService
  Browser->>NextRoutes: AI 제안 또는 결정 요청
  NextRoutes->>AiProposalClient: route와 Request 전달
  AiProposalClient->>IdentityService: 세션 쿠키로 principal 조회
  IdentityService-->>AiProposalClient: workspaceId·actorId 반환
  AiProposalClient->>AiService: 메서드·경로 결합 HMAC 컨텍스트 전달
  AiService-->>AiProposalClient: 제안·감사·결정 응답
  AiProposalClient-->>Browser: 범위 검증 후 credential-free 응답
Loading
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/ai-authenticated-gateway-context

Comment @coderabbitai help to get the list of available commands.

@seonghobae
seonghobae marked this pull request as ready for review August 4, 2026 11:33

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Rate Limit Exceeded

@seonghobae have exceeded the limit for the number of chat messages per hour. Please wait 18 minutes and 28 seconds before sending another message.

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@seonghobae
seonghobae merged commit f5cb401 into main Aug 4, 2026
33 checks passed

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

Derive AI proposal audit scope through authenticated signed service context

2 participants