Skip to content

Fix authMethod default not stored in auth options (AO2) - #2313

Open
cpruijsen wants to merge 1 commit into
ably:mainfrom
cpruijsen:fix/issue-2205
Open

cpruijsen wants to merge 1 commit into
ably:mainfrom
cpruijsen:fix/issue-2205

Conversation

@cpruijsen

@cpruijsen cpruijsen commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When authMethod is omitted, auth.authOptions.authMethod is 'GET' (AO2 / AO2d). The GET default was already applied at request time (authMethod.toLowerCase() === 'post' is the only POST path) but was not stored on the options object.

_saveTokenOptions writes the default when the property is absent, using the same 'prop' in options guard as other ClientOptions defaults. The existing UTS test is un-skipped and the AO2 deviations.md entry is removed.

Fixes #2205

What I chose and the alternative

authMethod: 'GET' is stored in _saveTokenOptions when the property is absent, not in Defaults.normaliseOptions (the tls / queueMessages path). _saveTokenOptions is where stored AuthOptions are assigned, including authorize() replacements that never go through normaliseOptions. The failing test inspects client.auth.authOptions.

Can also or instead set the default in normaliseOptions and/or _saveBasicOptions if you want every AuthOptions view, including key-only basic-auth clients, to show 'GET'.

The constructor shares the normalised ClientOptions object with auth.authOptions, so client.options.authMethod also becomes 'GET'. That matches how other defaults already appear on client.options.

Test plan

  • AO2 - authMethod defaults to GET fails without the source change (expected undefined to equal 'GET') and passes with it
  • Sibling AO2 - authUrl and authMethod options still stores explicit POST
  • Full test/uts/rest/unit/types/options_types.test.ts: 10 passing
  • test/uts/rest/unit/auth/*.test.ts: 87 passing, 7 pending (RSA8c GET/POST wire behaviour unchanged)
  • Full UTS unit suite under Node 20 (tsx, same ignore set as test:uts:unit): 1419 passing, 47 pending

Summary by CodeRabbit

  • Bug Fixes
    • Authentication options now default to the GET method when no method is specified. Explicitly configured methods remain unchanged. This behavior applies when authentication options are saved, so callers that omit a method receive a consistent default.

@coderabbitai

coderabbitai Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2f2b13b7-9fbe-45fe-8c35-afdf2bd74f3e
📥 Commits

Reviewing files that changed from the base of the PR and between da547fd and 1a9c4df.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ed7100e7-ef0a-43f1-872d-c52d36b6b016
📥 Commits

Reviewing files that changed from the base of the PR and between e0ed57c and da547fd.

📒 Files selected for processing (1)
  • test/uts/rest/unit/types/options_types.test.ts
💤 Files with no reviewable changes (1)
  • test/uts/rest/unit/types/options_types.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.


Walkthrough

When _saveTokenOptions receives auth options without authMethod, it now stores GET in the options. The related test runs without the RUN_DEVIATIONS skip, and the matching deviation entry is removed.

Changes

Auth method default

Layer / File(s) Summary
Store and test the default
src/common/lib/client/auth.ts, test/uts/rest/unit/types/options_types.test.ts, test/uts/deviations.md
_saveTokenOptions sets authMethod to GET when it is missing and preserves supplied values. The default test no longer skips, and its deviation entry is removed.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: ttypic

Merge Risk: ⚪ Minimal · up to da547

The stored auth method now defaults to GET when omitted. No actionable issue remains before merge, subject to normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to e0ed5

The existing GET default becomes visible in stored token-auth options. The inspected token-request path still uses GET when no method is supplied and preserves an explicit POST. No new authentication bypass was identified, though external consumers of the stored options were not fully covered.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The directly inspected effect is the method value exposed on a client’s token-auth options; the inspected authUrl transport retains its prior GET-versus-POST selection. Downstream external option consumers remain outside the established scope.

Trust Boundaries and Controls

  • observed — authorize rejects a supplied key that conflicts with the client’s existing key before saving replacement token options; the new GET assignment does not alter that check.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: storing the default authMethod in auth options.
Linked Issues check ✅ Passed Issue #2205 requires omitted authMethod to default to 'GET' and appear on the auth options object. The PR summary reports that _saveTokenOptions sets 'GET' only when the property is absent, th…
Out of Scope Changes check ✅ Passed The reported changes are limited to the authMethod default in src/common/lib/client/auth.ts, its AO2 test, and removal of the matching deviation entry. These changes implement or verify issue #220…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR

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

A rabbit checked the options at dawn,
And found GET where the default was gone.
The test now runs clear,
The deviation disappears,
While the auth method hops along.<!-- -->

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

@ttypic ttypic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for contribution!

_saveTokenOptions assigned the caller's AuthOptions unchanged, so
auth.authOptions.authMethod stayed undefined when omitted. The GET
default was applied only at request time. Store authMethod: 'GET' on
the options object when the property is absent, matching other option
defaults, and un-skip the existing UTS test.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

authMethod default not stored in auth options (AO2)

2 participants