fix(bootstrap): ANONYMOUS 프로필 요청을 세션 상태와 상관없이 보낸다 (09-01)
조립 루트의 attachCredentials가 operation의 인증 프로필을 보지 않고 세션 상태만 본다. 그래서 auth: "none" operation(ANONYMOUS 프로필)이 로그아웃이면 UNAUTHENTICATED, 로그인이면 세션 헤더가 붙어 CREDENTIAL_HEADER_NOT_ALLOWED로 거절되고, 외부 owner가 없으면 CREDENTIAL_OWNER_UNAVAILABLE로 끝난다. 어느 상태에서도 fetch가 0회다. scope 확인 바로 다음에 INSTALLED_REST_AUTH_PROFILES에서 operation.authProfileId의 transport를 읽고, ANONYMOUS면 세션을 보지 않고 빈 헤더로 READY를 돌려준다. executor에 넘기는 레지스트리와 같은 값을 같은 객체 안에서 읽는다. 그 밖의 프로필은 기존 경로 그대로다. 버린 대안: - executor(http-execution-v3.ts)가 ANONYMOUS면 attachCredentials를 부르지 않게 하기. adapter 공개 동작이 바뀐다. 지금 executor는 익명 프로필에도 협력자를 부르고 헤더를 내면 거절하며, 이 동작을 고정한 계약 테스트가 있다. 세션을 아는 쪽은 조립 루트라서 판단도 거기 둔다. - 리뷰 R1(attachCredentials를 createCredentialAttacher로 꺼내기). 구조 변경이라 이번 범위를 넘는다. 09-02에서 함께 다룬다. 새 테스트가 실제 createRuntimeAdapters를 거치므로 그때도 그대로 쓸 수 있다. - 새 케이스를 tests/unit/runtime-adapters.test.ts에 넣기. vi.mock은 파일 단위라 설치된 계약 묶음을 바꾸면 그 파일의 기존 테스트에도 번진다. 그래서 runtime-adapters-auth-profile.test.ts를 따로 만들었다. 위험·한계: - 로그인 상태의 익명 호출에 토큰이 붙지 않고 owner에게도 가지 않는다. ANONYMOUS 프로필이 자격증명 헤더를 하나도 허용하지 않으니 의도한 결과다. 인증 통합이 실패한 상태에서도 공개 읽기는 나간다. - scope fence는 익명 분기보다 먼저 본다. 모르는 프로필 id는 executor가 attachCredentials 전에 UNKNOWN_AUTH_PROFILE로 막는다. - 브라우저 화면은 보지 않았다. test:sample-removal도 돌리지 않았다. 새 테스트는 템플릿 소유 fixture와 src/contracts의 프로필만 쓴다. - tech-log 제품 쪽 우회는 다음 동기화 때 지운다. 검증: - RED(수정 전): 새 테스트 11건 중 5건 실패. ANONYMOUS 4개 상태가 expected 'UNAUTHENTICATED' to be 'SUCCESS'(demo 로그아웃), expected 'AUTH_INTEGRATION_FAILURE' to be 'SUCCESS'(demo 로그인, 외부 owner 로그인, owner 없음)로 실패. owner의 attachCredential이 1회 불림. 인증 필요 프로필의 UNAUTHENTICATED, CREDENTIAL_OWNER_ UNAVAILABLE 2건, fence 중 ABORTED_BY_SCOPE, 로그인 후 bearer 전송, 익명 요청의 SCOPE_FENCED 6건은 수정 전후 모두 통과. - GREEN: 새 테스트 11/11 통과. - 회귀: runtime-adapters, http-execution-v3(unit·integration), auth-recovery, legacy-http-credential-authority, tests/features, tests/component, 영역 R1 목록 71 files / 485 tests 통과. - tsc(tsconfig.app.json, tsconfig.test.json) 오류 0. 바꾼 두 파일 eslint 통과. check:architecture(pnpm 대신 exec 대행) 통과, 376 modules. Refs: docs/reviews/2026-11-01-maturity-review/09-app-core.md 09-01
This commit is contained in:
@@ -502,6 +502,16 @@ export async function createRuntimeAdapters(
|
||||
if (serverStateScope.getPhase() !== "READY") {
|
||||
return Object.freeze({ kind: "SCOPE_FENCED" as const });
|
||||
}
|
||||
// 09-01. The operation's installed profile decides first, the session
|
||||
// second. An ANONYMOUS profile admits no credential header at all, so it
|
||||
// goes out bare in every session state and never reaches the owner. Every
|
||||
// other profile still needs a session and never downgrades to anonymous.
|
||||
if (
|
||||
INSTALLED_REST_AUTH_PROFILES.get(operation.authProfileId)?.transport ===
|
||||
"ANONYMOUS"
|
||||
) {
|
||||
return Object.freeze({ kind: "READY" as const, headers: {} });
|
||||
}
|
||||
const state = authSession.getState();
|
||||
if (state === "integration-failed") {
|
||||
return Object.freeze({ kind: "UNAVAILABLE" as const });
|
||||
|
||||
Reference in New Issue
Block a user