From 3a630fd18e18696f4aa66eb3cfc8979520aa9c55 Mon Sep 17 00:00:00 2001 From: Rita Chen Date: Thu, 5 Nov 2026 09:36:01 -0500 Subject: [PATCH 1/3] MLE-34176 fix hard-coded credentials in examples --- examples/python-blog-post.ipynb | 20 ++++++++++++-------- examples/release-1.1-examples.ipynb | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/examples/python-blog-post.ipynb b/examples/python-blog-post.ipynb index e827cdb..00bcd8b 100644 --- a/examples/python-blog-post.ipynb +++ b/examples/python-blog-post.ipynb @@ -10,19 +10,23 @@ "# Change this if needed to point to your MarkLogic instance.\n", "base_url = \"http://localhost\"\n", "\n", + "import json\n", + "import os\n", + "from getpass import getpass\n", + "import requests\n", + "from requests.auth import HTTPDigestAuth\n", + "\n", "# The admin account that can be used to create a new user and role.\n", - "adminUser = \"admin\"\n", - "adminPassword = \"admin\"\n", + "# The admin user is read from the environment variable MARKLOGIC_ADMIN_USER, or defaults to \"admin\".\n", + "# Passwords are read from environment variables, or prompted for if not set.\n", + "adminUser = os.environ.get(\"MARKLOGIC_ADMIN_USER\", \"admin\")\n", + "adminPassword = os.environ.get(\"MARKLOGIC_ADMIN_PASSWORD\") or getpass(\"MarkLogic admin password: \")\n", "\n", "# The user to create which will be used for all of the examples.\n", "user = \"python-blog-user\"\n", - "password = \"pyth0n\"\n", + "password = os.environ.get(\"PYTHON_BLOG_USER_PASSWORD\") or getpass(\"Password for the new example user: \")\n", "role_name = \"python-blog-role\"\n", "\n", - "import json\n", - "import requests\n", - "from requests.auth import HTTPDigestAuth\n", - "\n", "# The App-Services app server in your MarkLogic instance is assumed to be on port 8000 and to require either 'digest' \n", "# or 'digestbasic' authentication. If the app server uses a different kind of authentication, you will need to modify \n", "# the two lines below that set the 'auth' fields for the admin and user sessions. The 'admin_session' is also used to \n", @@ -88,7 +92,7 @@ "source": [ "# Load 500 JSON employee documents into the Documents database.\n", "\n", - "r = requests.get(\"https://raw.githubusercontent.com/marklogic/marklogic-spark-connector/master/src/test/resources/500-employees.json\")\n", + "r = requests.get(\"https://raw.githubusercontent.com/marklogic/marklogic-spark-connector/master/marklogic-spark-connector/src/test/resources/500-employees.json\")\n", "\n", "for employee in json.loads(r.text):\n", " user_session.put(\n", diff --git a/examples/release-1.1-examples.ipynb b/examples/release-1.1-examples.ipynb index afb8956..c0d612f 100644 --- a/examples/release-1.1-examples.ipynb +++ b/examples/release-1.1-examples.ipynb @@ -13,7 +13,13 @@ "# Create an instance of the MarkLogic Python client, pointing at the out-of-the-box Documents database.\n", "\n", "from marklogic import Client\n", - "client = Client(\"http://localhost:8000\", digest=(\"python-user\", \"pyth0n\"))" + "import os\n", + "from getpass import getpass\n", + "\n", + "# Credentials are read from environment variables, or prompted for if not set.\n", + "ml_user = os.environ.get(\"MARKLOGIC_USER\", \"python-user\")\n", + "ml_password = os.environ.get(\"MARKLOGIC_PASSWORD\") or getpass(\"MarkLogic password: \")\n", + "client = Client(\"http://localhost:8000\", digest=(ml_user, ml_password))" ] }, { @@ -66,7 +72,7 @@ "from marklogic.documents import Document, DefaultMetadata\n", "import requests\n", "import json\n", - "r = requests.get('https://raw.githubusercontent.com/marklogic/marklogic-spark-connector/master/src/test/resources/500-employees.json')\n", + "r = requests.get('https://raw.githubusercontent.com/marklogic/marklogic-spark-connector/master/marklogic-spark-connector/src/test/resources/500-employees.json')\n", "\n", "docs = [\n", " DefaultMetadata(permissions={\"rest-reader\": [\"read\", \"update\"]}, collections=[\"employee\"])\n", @@ -185,7 +191,10 @@ "# Create a Spark DataFrame via a MarkLogic Optic query.\n", "\n", "df = spark.read.format(\"marklogic\") \\\n", - " .option(\"spark.marklogic.client.uri\", \"python-user:pyth0n@localhost:8000\") \\\n", + " .option(\"spark.marklogic.client.host\", \"localhost\") \\\n", + " .option(\"spark.marklogic.client.port\", \"8000\") \\\n", + " .option(\"spark.marklogic.client.username\", ml_user) \\\n", + " .option(\"spark.marklogic.client.password\", ml_password) \\\n", " .option(\"spark.marklogic.read.opticQuery\", \"op.fromView('example', 'employee', '')\") \\\n", " .load()\n", "\n", From cd05353ecb2ae10e00a7015e9af19d75f7fbb829 Mon Sep 17 00:00:00 2001 From: Rita Chen Date: Thu, 5 Nov 2026 09:51:01 -0500 Subject: [PATCH 2/3] MLE-34176 exclude copyright check for .ipynb files --- .copyrightconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.copyrightconfig b/.copyrightconfig index c58285f..0130fbb 100644 --- a/.copyrightconfig +++ b/.copyrightconfig @@ -10,4 +10,4 @@ startyear: 2023 # - Use sparingly (third_party, generated, binary assets) # - Dotfiles already skipped automatically # Enable by removing the leading '# ' from the next line and editing values. -filesexcluded: .github/*, *.md, Jenkinsfile, gradle/*, *.yml, *.gradle, *.properties, gradlew, gradlew.bat, CODEOWNERS, *.lock, *.toml, *.md, *version, *.json +filesexcluded: .github/*, *.md, Jenkinsfile, gradle/*, *.yml, *.gradle, *.properties, gradlew, gradlew.bat, CODEOWNERS, *.lock, *.toml, *.md, *version, *.json, *.ipynb From a5e0fdaa1a39253440fa765e86bc839d82210b83 Mon Sep 17 00:00:00 2001 From: Rita Chen Date: Thu, 5 Nov 2026 10:43:57 -0500 Subject: [PATCH 3/3] MLE-34176 add "any-uri" privilege to "python-tester" to fix test error "URI privilege required" --- .../src/main/ml-config/security/roles/python-tester.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test-app/src/main/ml-config/security/roles/python-tester.json b/test-app/src/main/ml-config/security/roles/python-tester.json index a529e1f..ebc019d 100644 --- a/test-app/src/main/ml-config/security/roles/python-tester.json +++ b/test-app/src/main/ml-config/security/roles/python-tester.json @@ -14,6 +14,11 @@ "action": "http://marklogic.com/xdmp/privileges/rest-writer", "kind": "execute" }, + { + "privilege-name": "any-uri", + "action": "http://marklogic.com/xdmp/privileges/any-uri", + "kind": "execute" + }, { "privilege-name": "xdbc:eval", "action": "http://marklogic.com/xdmp/privileges/xdbc-eval",