Repository navigation
MLE-34235: [Python Client][Security] Cloud token bootstrap bypasses session settings and can use plaintext HTTP - #158
Merged
Merged
Conversation
ngodugu-marklogic
requested review from
RitaChen609,
jonmille,
rjdew-progress and
rjrudin
as code owners
November 19, 2026 07:53
There was a problem hiding this comment.
🟡 Changes recommended
Cloud authentication has two critical defects: configured base paths corrupt token endpoints, and token responses reset the renewal guard, allowing repeated 401 responses to trigger recursion instead of stopping after one retry.
2 open issues
What changed in this PR
This PR hardens cloud API-key authentication in the Python client by enforcing HTTPS and using the existing session for token requests.
Changes:
- Rejects non-HTTPS cloud base URLs and warns when certificate verification is disabled.
- Routes token requests through the session with a 30-second timeout.
- Adds targeted security regression tests and a Code Sight configuration.
| File | Description |
|---|---|
tests/test_cloud_auth_security.py |
Tests HTTPS enforcement, token timeout, and the verification warning. |
marklogic/cloud_auth.py |
Uses session-based token requests, adds a timeout, and warns about disabled verification. |
marklogic/client.py |
Rejects non-HTTPS base URLs when cloud API-key authentication is enabled. |
.codesight/default.json |
Adds local Code Sight/Polaris scan configuration. |
Review effort: Balanced
Comment on lines
+65
to
+69
| response = self._session.post( | ||
| urljoin(self._base_url, "/token"), | ||
| data={"grant_type": "apikey", "key": self._api_key}, | ||
| verify=self._session.verify, | ||
| params=params, | ||
| timeout=DEFAULT_TOKEN_REQUEST_TIMEOUT, |
ngodugu-marklogic
force-pushed
the
MLE-34235
branch
2 times, most recently
from
November 19, 2026 08:20
4aa1839 to
310eca6
Compare
RitaChen609
reviewed
Nov 19, 2026
RitaChen609
reviewed
Nov 19, 2026
ngodugu-marklogic
force-pushed
the
MLE-34235
branch
from
November 20, 2026 06:54
310eca6 to
d87f95d
Compare
ngodugu-marklogic
force-pushed
the
MLE-34235
branch
from
November 20, 2026 13:46
d87f95d to
b889ffb
Compare
RitaChen609
approved these changes
Nov 20, 2026
jonmille
approved these changes
Nov 20, 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.

This PR hardens cloud token bootstrap for security and reliability.
Summary:
Tests: