BAT-006 (REQ-016/017/018): - client token 발급 경로 제거 (issue_client_token, POST /auth/tokens, 관련 스키마/테스트) - service-token rotate unique index revoked_at IS NULL 조건 추가 (Alembic CONCURRENTLY 마이그레이션) - POST /auth/service-tokens body daemon_id forward 누락 보정 (1-line fix) BAT-007 (REQ-022/023): - daemon deactivate 시 바인딩 service token 자동 revoke (CLI --force 옵션 + revoke_tokens_by_daemon_id) - NULL daemon_id legacy token 진단 CLI (migrate-null-daemon --dry-run) 거버넌스 문서: dcy-003/004 Discovery, REQ-016~023/025~032 신규, BAT-006/007 전체 산출물 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
4.8 KiB
4.8 KiB
REQ-018: POST /auth/service-tokens body daemon_id forward 보정
- Status: Approved
- Type: Interface
- Priority: High
- Owner: Justin Ko
Intent
- 현행
POST /auth/service-tokensHTTP route(app/api/auth_routes.py:131-137)가IssueServiceTokenRequest.daemon_id필드를 스키마에서 노출하지만service.issue_service_token호출 시 forward하지 않아 silently drop되는 결함을 정상화한다. - CLI
pfhub service-token issue --daemon-id는 정상 forward하나 HTTP 경로만 daemon binding이 불가능한 상태였다. HTTP/CLI 일관성을 회복한다.
Requirement
app/api/auth_routes.py:131-137의service.issue_service_token(...)호출에daemon_id=payload.daemon_id를 추가한다.- 비존재 또는 비활성 daemon_id가 body로 전달되면
AuthService.issue_service_token의 기존 검증 로직(get_daemon_by_idNone 또는is_active=False)이 ValueError를 발생시키고,_raise_auth_error를 통해 HTTP 4xx로 변환된다. - daemon_id 검증 실패 응답 코드는 ValueError detail에 따라 HTTP 400 또는 404로 분기된다(
_raise_auth_error기존 로직). - 본 REQ는 HTTP body daemon_id 처리만 보정한다. CLI 동작, daemon registry 자체, service token 발급 정책은 변경하지 않는다.
Acceptance Criteria
- Given admin token, When
POST /auth/service-tokensbody{"name": "...", "username": "...", "daemon_id": "<existing-active-daemon-id>"}호출, Then HTTP 201 + issued token의auth_token.daemon_id == <daemon-id>반환. - Given admin token, When
POST /auth/service-tokensbody{"name": "...", "username": "...", "daemon_id": "<non-existing-daemon-id>"}호출, Then HTTP 4xx +_raise_auth_error패턴에 따른 오류 메시지 반환. - Given admin token, When
POST /auth/service-tokensbodydaemon_id필드 미포함 또는 null, Then 기존 동작 유지(daemon binding 없는 service token 발급, HTTP 201). - Given AC-1과 CLI
pfhub service-token issue NAME --user U --daemon-id <daemon-id>실행 결과 비교, When 둘 다 발급된 토큰의daemon_id확인, Then 동일한 값이 저장된다(HTTP/CLI 동등성).
Impacted Area
- Docs:
docs/interface-contract.md— POST /auth/service-tokens body 명세에 daemon_id forward 동작 추가 (REQ-019에서 처리)
- Modules:
app/api/auth_routes.py:131-137—issue_service_token호출 시daemon_id=payload.daemon_id추가
- Tests:
- 갱신
tests/test_auth.py— AC-1~3 HTTP request 시뮬레이션 추가 - 갱신
tests/test_daemon_registry.py— AC-4 HTTP/CLI 동등성 회귀
- 갱신
Notes
- 본 REQ는 1-line 보정에 가까운 단순 결함 수정이지만, HTTP API 사용자에게는 daemon binding 경로가 새로 작동하기 시작하는 의미 있는 변경이라 별도 REQ로 분리.
- daemon registry 자체(존재/활성 검증)는 기존
AuthService.issue_service_token내부 로직이 그대로 처리하므로 본 REQ에서는 daemon 모델을 건드리지 않는다. - HTTP body daemon_id를 누락하거나 null로 보내는 경우의 기본 동작(unbound service token 발급)은 dcy-004 OQ-7에서 "수동 매핑" 정책이 결정되었으므로 본 REQ에서 추가 제한하지 않는다. NULL daemon 토큰의 운영 정리는 REQ-023(마이그레이션 CLI)에서 처리.
- Source: dcy-004 FR-3.
Change Log
CHG-20260520-02
- Date: 2026-05-20
- Author: Justin Ko
Change Summary
- Status: Proposed → Approved
Intent
- 승인 게이트 통과: 필수 필드(Status/Type/Priority/Owner/Intent/Requirement/AC/Impacted Area/Change Log) 모두 충족, AC 구체성 확인 완료, blocker 없음
Acceptance Criteria Delta
- No change
Impacted Area Delta
- No change
Delivery Trace Delta
- Batches: none (미정)
- Releases: none (미정)
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: promote-to-approved
- Follow-up Action: batch 계획 편입
CHG-20260520-01
- Date: 2026-05-20
- Author: Justin Ko
Change Summary
- 최초 생성 — dcy-004 confirm-discovery 후 draft-req 실행. dcy-004 FR-3 산출물.
Intent
- HTTP/CLI 토큰 발급 surface 일관성 회복 (daemon_id forward 누락 결함 정상화).
Acceptance Criteria Delta
- Added:
- AC-1~4 최초 작성
Impacted Area Delta
- Docs: docs/interface-contract.md (REQ-019에서 처리)
- Modules: app/api/auth_routes.py — 최초 지정
- Tests: tests/test_auth.py, tests/test_daemon_registry.py — 최초 지정
Delivery Trace Delta
- Batches: none (미정)
- Releases: none (미정)
Revalidation Impact
- Reverification Needed: no
- Existing Implementation Invalidated: no
- Status Recommendation: keep-current
- Follow-up Action: confirm-req 후 batch 계획 편입
Validation Plan
- pytest TestClient로 AC-1~4 검증; HTTP/CLI 동등성 회귀