Validate OIDC allowed hosts before authenticator reuse#2801
Open
NguyenCong2k wants to merge 1 commit into
Open
Validate OIDC allowed hosts before authenticator reuse#2801NguyenCong2k wants to merge 1 commit into
NguyenCong2k wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens MONGODB-OIDC host allowlisting by ensuring authOIDCAllowedHosts is validated before reusing a cached OIDC authenticator, preventing a cached authenticator from bypassing host restrictions when connecting to a different (disallowed) host. It applies the same ordering change to both the synchronous and asynchronous OIDC auth helpers and adds regression tests for the cached-authenticator scenario.
Changes:
- Reordered
_get_authenticatorlogic so allowed-host validation happens before returningcredentials.cache.data(sync + async). - Added regression tests verifying that a cached authenticator cannot be reused when the requested host is not in
ALLOWED_HOSTS(sync + async tests).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/test_auth_oidc.py | Adds a regression test covering cached authenticator reuse with a disallowed host. |
| test/asynchronous/test_auth_oidc.py | Adds the async-side equivalent regression test for cached authenticator reuse. |
| pymongo/synchronous/auth_oidc.py | Moves cached-authenticator reuse to occur after allowed-host validation. |
| pymongo/asynchronous/auth_oidc.py | Mirrors the sync fix by moving cached-authenticator reuse to occur after allowed-host validation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test