fix(cli): prefer user/api audience for mixed-aud JWTs#2828
fix(cli): prefer user/api audience for mixed-aud JWTs#2828SergioChan wants to merge 2 commits intochainloop-dev:mainfrom
Conversation
b3a0ca9 to
5885882
Compare
|
Thanks for the checks — I force-pushed an amended commit with DCO sign-off so the DCO status should now pass. No functional code changes were introduced in this push. |
|
Thanks for the contribution Could you elaborate on what was the root cause of the problem? Thanks |
|
Thanks for the detailed review feedback 鈥?I鈥檓 working through the requested updates and will post a focused patch (or direct answers) shortly. |
1 similar comment
|
Thanks for the detailed review feedback 鈥?I鈥檓 working through the requested updates and will post a focused patch (or direct answers) shortly. |
|
Thanks for asking — root cause was in the CLI audience selection logic, not tmux itself. Before this patch, we effectively trusted the first value when That caused the CLI to classify the token via the generic audience path and then fall back to issuer resolution ( The fix changes audience handling to treat |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
The issue mentions a possible race condition between tmux sessions affecting the local config. Does this fix address the root cause? Consider adding a negative case for a multi-audience token where none match the known audiences ( |
|
Good callout — thank you. Short answer: this PR addresses the audience-selection bug in mixed-aud tokens (which surfaced as the I’ll add the negative multi-audience case you suggested ( |
Signed-off-by: Sergio <c@rct.ai>
Signed-off-by: sergiochan <yuheng9211@qq.com>
5885882 to
2eef292
Compare
|
Thanks for the suggestion — I’ve pushed an update that adds the requested negative multi-audience case:
Validation run:
|
|
Thanks for the contribution. But I'm still struggling to identify the root cause, because today it is not possible to have two audiences in the checkloop token. So the problem that we are solving here is non-existent. |
|
Some findings after investigating the root cause of #2812: The user token audience ( The likely root cause of #2812 is a stale token + newer control plane scenario:
The fix in this PR (smarter audience selection via |
Summary
audclaims as an ordered set instead of trusting the first item in an arrayapi-token-auth.chainloopanduser-auth.chainloopahead of genericchainloopwhen multiple audiences are present["chainloop", "user-auth.chainloop"]) so user identity is selected instead of issuer fallbackTesting
go test ./app/cli/internal/tokenRelated