Skip to content

fix(theme): dedupe auth scheme reused by OR security alternatives - #1707

Open
CloudCorpRecords wants to merge 1 commit into
PaloAltoNetworks:mainfrom
CloudCorpRecords:fix-1703-dedupe-auth-scheme
Open

CloudCorpRecords wants to merge 1 commit into
PaloAltoNetworks:mainfrom
CloudCorpRecords:fix-1703-dedupe-auth-scheme

Conversation

@CloudCorpRecords

Copy link
Copy Markdown

Summary

Fixes #1703.

When an operation declares multiple OpenAPI security alternatives that reuse the same scheme with different scopes (logical OR), createAuth collapsed them into one auth option (the option id is built only from scheme names) but pushed the scheme into that option once per alternative. buildPostmanRequest then emitted the scheme's header once per entry, so an apiKey scheme named Authorization (or an http bearer scheme) produced a duplicated Authorization header that browsers merge into token, token, which JWT APIs reject.

Fix

In createAuth (ApiExplorer/Authorization/slice.ts), add each scheme to an option at most once, deduped by scheme key. The first alternative's entry is kept; scopes remain alternatives (OR), not two credentials applied together. AND combinations of different schemes (e.g. BearerAuth and ApiKey) are unchanged, as are distinct OR alternatives.

Tests

New ApiExplorer/Authorization/slice.test.ts covering:

  • OR alternatives reusing the same apiKey scheme (the reported repro) produce a single scheme entry
  • OR alternatives reusing the same http bearer scheme produce a single scheme entry
  • AND of different schemes still yields both schemes in one option
  • Distinct OR alternatives still yield separate options

Before the fix the two dedupe tests failed (scheme array length 2); after the fix all pass:

  • slice.test.ts: 4 passed
  • Full ApiExplorer jest area (--selectProjects default): 6 suites, 183 tests passed
  • Prettier check on both changed files: clean

Signed-off-by: Rene Turcios 95189389+CloudCorpRecords@users.noreply.github.com

OR security alternatives that reuse the same scheme collapsed into a
single auth option in createAuth, but the scheme was added to that
option once per alternative. buildPostmanRequest then emitted the
scheme's header (e.g. Authorization) multiple times, which browsers
merge into a duplicated header value that JWT APIs reject.

Add each scheme to an option at most once, keyed by scheme key.
AND combinations of different schemes are unchanged.

Fixes PaloAltoNetworks#1703

Signed-off-by: Rene Turcios <95189389+CloudCorpRecords@users.noreply.github.com>

This branch is waiting to be deployed

1 waiting deployment
default — 498d5207 Waiting Nov 4, 2026 by CloudCorpRecords via Analyze Unsafe (javascript) #2473
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.

Duplicate Authorization header when OR security alternatives reuse the same scheme

1 participant