Repository navigation
Conversation
jonmille
requested review from
RitaChen609,
ngodugu-marklogic,
rjdew-progress and
rjrudin
as code owners
November 18, 2026 16:24
There was a problem hiding this comment.
🟡 Changes recommended
Redirect handling can leak credentials across origins, and inconsistent Unicode hostname normalization blocks legitimate same-origin Cloud Auth renewal.
2 open issues
What changed in this PR
This PR adds origin checks to the MarkLogic Python client to keep credentials and bearer tokens scoped to the configured server.
Changes:
- Adds shared origin comparison and rejects cross-origin request URLs.
- Restricts Cloud Auth token renewal and retries to same-origin responses.
- Adds security regression tests and a unit-test marker that skips database cleanup.
| File | Description |
|---|---|
tests/test_client_security.py |
Tests URL restrictions, redirect token handling, and same-origin renewal. |
tests/conftest.py |
Skips database cleanup for unit-marked tests. |
pyproject.toml |
Registers the unit-test marker. |
marklogic/internal/url.py |
Adds origin comparison with default-port handling. |
marklogic/cloud_auth.py |
Guards token renewal and retry by origin. |
marklogic/client.py |
Rejects cross-origin URLs during request preparation. |
Review effort: Balanced
RitaChen609
approved these changes
Nov 18, 2026
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
Prevent the Python client from sending credentials or bearer tokens to an origin other than its configured MarkLogic host.
Changes
Testing
User impact
Intended same-origin use is unchanged. Requests targeting another origin are now rejected, and Cloud Auth no longer retries a foreign-origin 401.