Skip to content

perf(access): read the token once instead of once per header step - #24

Merged
rohilsurana merged 1 commit into
mainfrom
perf/decode-token-once
Sep 16, 2026
Merged

rohilsurana merged 1 commit into
mainfrom
perf/decode-token-once

Conversation

@rohilsurana

@rohilsurana rohilsurana commented Sep 15, 2026

Copy link
Copy Markdown
Member

Follow up to #23, which has merged. Rebased onto main, so the diff here is just
this change.

append_claims_as_headers and verify_organization_id_header each decoded the
same token, so a request that used both read it twice. run() now decodes once
and passes the claims to both.

The decode still does not happen at all when nothing needs the claims.
verify_organization_id_header used to read the org header itself and return
early when it was missing, so run() now reads it once and passes the value
down to keep that.

Only the decode moved. Each function keeps its own handling of an unreadable
payload: the claim headers refuse the request, the org check drops the header.
Merging those into one guard would have turned the second into a 401.

Four cases count decodes through a wrapper around the real decoder. On the old
code the first one fails with expected 1 got 2; the other three pass either
way, because the double decode only happened when both steps ran and the client
actually sent the org header.

73 passed on Kong 3.4 and 3.9, up from 69. luacheck unchanged, 0 errors.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rohilsurana
rohilsurana force-pushed the perf/decode-token-once branch from 14525f3 to 4deb146 Compare September 16, 2026 08:10
@rohilsurana
rohilsurana changed the base branch from feat/cache-authn-token to main September 16, 2026 08:10
@rohilsurana
rohilsurana marked this pull request as ready for review September 16, 2026 09:08
@rohilsurana
rohilsurana merged commit bab7ea7 into main Sep 16, 2026
1 check passed
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.

2 participants