Skip to content

fix: 토큰 assertion audience 인코딩 정정 - #123

Merged
yessjun merged 1 commit into
mainfrom
fix/gcp-token-audience
Sep 10, 2026
Merged

fix: 토큰 assertion audience 인코딩 정정#123
yessjun merged 1 commit into
mainfrom
fix/gcp-token-audience

Conversation

@yessjun

@yessjun yessjun commented Sep 10, 2026

Copy link
Copy Markdown
Member

📝 작업내용

  • 서비스 계정 assertion의 aud를 배열이 아닌 문자열로 인코딩. audience().add()는 값이 하나여도 JSON 배열을 내고 Google 토큰 엔드포인트는 문자열을 요구
  • 응답이 invalid_grant에 "Failed audience check. The right audience is "이고 이미 보낸 값을 되읊어 주므로 값 오류로 오독됨. 키 파일의 token_uri는 정상
  • 시험 단언을 우리 코드가 실제로 만든 assertion의 원문 payload로 이동. 종전 단언은 토큰을 되파싱해 audience 값만 확인

⭐️ 검증

  • 테스트 1364개 통과, 실패 0, 오류 0
  • 옛 인코딩으로 되돌려 강화한 단언이 빨간불이 되는 것을 확인 후 원복
  • 라이브 로그 실측이 원인 근거. 관리자 재동기화가 vhost 8개를 적용하고 DNS 조정만 HTTP 400으로 건너뜀

💬 리뷰 포인트

  • 파서로 되비추면 문자열과 원소 하나짜리 배열이 구별되지 않는 축이라, 원문 payload를 읽는 단언을 택한 것

The service-account assertion built its aud claim with audience().add(),
which serialises even a single audience as a JSON array. Google's token
endpoint requires the string form and answers the array with
invalid_grant, "Failed audience check. The right audience is <uri>" —
naming the value it was already sent, so the message reads as though the
value were wrong. It was not; the key file's token_uri is exactly that.

Nothing in this path has ever authenticated. The startup line that reports
the provider as configured says the settings are present, not that a call
succeeds, and the first call is a reconcile that logs and moves on.

The test could not see it. It parsed the assertion back and asserted the
audience value, and a parser reads a string and a one-element array alike,
so it passed either way — the only thing that distinguishes them is the
endpoint. The assertion now reads the raw payload of the token this code
actually produced, which is the one property a round trip through our own
parser cannot check.
@yessjun
yessjun merged commit 868deac into main Sep 10, 2026
1 check passed
@yessjun
yessjun deleted the fix/gcp-token-audience branch September 10, 2026 06:57
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.

1 participant