Skip to content

fix(oauth): honor allowed hosts when requesting tokens - #189

Merged
Vincent Biret (baywet) merged 1 commit into
mainfrom
fix/oauth-host-validation
Oct 23, 2026
Merged

Vincent Biret (baywet) merged 1 commit into
mainfrom
fix/oauth-host-validation

Conversation

@baywet

Copy link
Copy Markdown
Member

Description

Return a Fiber yielding nil for missing or disallowed request targets before initializing scopes or requesting a token. Preserve token acquisition for allowed HTTPS hosts and when no host list is configured.

Validation

  • Regression tests executed before the fix: 5 examples, 3 expected failures.
  • After the fix: 5 focused examples passing; 134 OAuth and abstractions examples passing.
  • OAuth component rake task passes (10 examples).
  • RuboCop passes for both changed files.
  • All Ruby validation ran in a Ruby 3.3 Docker container.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2e6eea48-9037-4100-8df3-1fc558e359dc
Copilot AI balanced review requested due to automatic review settings October 23, 2026 12:05

Copilot AI 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.

🟢 Approval recommended

The focused fix preserves the caller’s Fiber contract, and the regression tests cover rejected targets and successful token acquisition.

No open issues 🎉

What changed in this PR

Fixes OAuth allowed-host enforcement by returning a Fiber yielding nil for missing or disallowed targets before scope initialization or token acquisition.

Changes:

  • Adds an explicit early return while preserving the Fiber contract.
  • Adds regression tests for rejected targets, allowed hosts, unrestricted host configuration, and authorization-header omission.
File Description
components/​authentication/​oauth/​spec/​oauth_access_token_provider_spec.rb Tests host filtering, missing targets, token acquisition, and header behavior.
components/​authentication/​oauth/​lib/​microsoft_kiota_authentication_oauth/​oauth_access_token_provider.rb Stops processing missing or disallowed targets with a nil-returning Fiber.

Review effort: Balanced

@baywet
Vincent Biret (baywet) merged commit cc909a5 into main Oct 23, 2026
122 checks passed
@baywet
Vincent Biret (baywet) deleted the fix/oauth-host-validation branch October 23, 2026 17:50
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