Skip to content

fix: lagoon api token caching - #499

Merged
shreddedbacon merged 1 commit into
mainfrom
fix-token-caching
Aug 28, 2026
Merged

shreddedbacon merged 1 commit into
mainfrom
fix-token-caching

Conversation

@rocketeerbkw

@rocketeerbkw rocketeerbkw commented Aug 27, 2026 •

Copy link
Copy Markdown
Member

General Checklist

  • Affected Issues have been mentioned in the Closing issues section
  • Documentation has been written/updated
  • PR title is ready for inclusion in changelog

Token caching can be broken for some users, meaning every invocation of the cli causes a token fetch. When using the cli in a loop in a bash script, this adds very significant overhead.

The bug is in the JWT parser. The StandardClaims Audience field is a string but a Lagoon token can be an array "aud": ["realm-management", "account"],. The ParseUnverified call errors with json: cannot unmarshal array into Go struct field StandardClaims.aud of type string but the error check return false silently, forcing a token fetch.

Using MapClaims{} is more forgiving and still validates the exp of the token.

Closing issues

n/a

@shreddedbacon
shreddedbacon merged commit 38a7b36 into main Aug 28, 2026
8 checks passed
@shreddedbacon
shreddedbacon deleted the fix-token-caching branch August 28, 2026 05:26
@smlx

smlx commented Aug 31, 2026

Copy link
Copy Markdown
Member

Just to note here: v3 of golang-jwt is no longer supported and v5 does correctly support an array of audience string. Maybe upgrading would be better than working around this bug?

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.

3 participants