jarredhj0214 commented on code in PR #14755:
URL: https://github.com/apache/gravitino/pull/14755#discussion_r4561172493


##########
docs/spark-connector/spark-rest-catalog-discovery.md:
##########
@@ -79,6 +79,39 @@ Set 
`spark.sql.gravitino.lanceREST.catalogProperties.namespaceDelimiter` when th
 server uses a namespace delimiter other than the default `$`. The property is 
used for the
 discovery request and is also copied to each discovered catalog.
 
+### User identity
+
+When `spark.sql.gravitino.authType` is `simple` (the default), the discovery 
plugin uses
+`SparkContext.sparkUser()` as the Lance user. It sends an HTTP Basic header 
with the UTF-8 encoded
+value `<user>:unused` for discovery and copies it to each automatically 
registered Lance catalog.
+The password is a placeholder. Usernames containing a colon require explicit 
credentials because
+HTTP Basic uses the colon to separate the username from the password.
+
+Set `spark.sql.gravitino.lanceREST.catalogProperties.headers.Authorization` to 
use explicit
+credentials for discovery and as the default for registered catalogs. A 
per-catalog
+`spark.sql.catalog.<name>.headers.Authorization` overrides the global header 
for that catalog's
+operations. Header names are case-insensitive. Within each configuration 
scope, equivalent keys
+with identical values are collapsed and conflicting values are rejected.
+
+The plugin generates a header only when `authType` is `simple`. This setting 
selects the default
+for the Lance endpoint independently of Hadoop security, so a Kerberos-enabled 
Spark application
+can use it to access an independent simple-auth Lance REST server. Configure 
explicit credentials
+when the Lance endpoint uses a different authentication scheme. Manually 
registered catalogs
+require their own configuration.
+
+#### Upgrading existing jobs
+
+Default-simple jobs now send a Basic header even if they previously sent no 
authentication header.
+In auxiliary mode, requests that previously fell back to the Lance REST 
service user may now
+execute as the Spark user. Before upgrading, register that user and grant the 
permissions needed
+for discovery and subsequent operations. Missing grants can cause HTTP 403 
responses, and objects
+created by the job may have a different creator or owner. Configure an 
explicit global

Review Comment:
   Updated in `9d2b2e5fc`. The upgrade note now says to use credentials for the 
original service user to preserve that identity, with a Basic header for that 
user as an example when the endpoint accepts Simple authentication. The note 
leaves empty `Authorization` outside the documented migration procedure.



##########
spark-connector/spark-common/src/test/java/org/apache/gravitino/spark/connector/plugin/restcatalog/lance/TestLanceRESTCatalogProvider.java:
##########
@@ -106,6 +107,36 @@ void testUsesConfiguredNamespaceDelimiter() {
     assertTrue(rawQueries.get(0).contains("delimiter=%23"));
   }
 
+  @Test
+  void testDiscoverySendsConfiguredHeadersOnEveryPage() {
+    List<String> authorizationHeaders = new CopyOnWriteArrayList<>();
+    List<String> customHeaders = new CopyOnWriteArrayList<>();
+    server.createContext(
+        "/lance/v1/namespace/$/list",
+        exchange -> {
+          
authorizationHeaders.addAll(exchange.getRequestHeaders().get("Authorization"));
+          
customHeaders.add(exchange.getRequestHeaders().getFirst("X-Test-User"));
+          if (authorizationHeaders.size() == 1) {
+            respond(exchange, 200, 
"{\"namespaces\":[\"catalog_a\"],\"page_token\":\"next\"}");
+          } else {
+            respond(exchange, 200, "{\"namespaces\":[\"catalog_b\"]}");
+          }
+        });
+    server.start();
+    Map<String, String> properties = new LinkedHashMap<>();
+    properties.put("headers.authorization", "Basic ZXR1c2VyOnVudXNlZA==");
+    properties.put("Headers.Authorization", "Basic ZXR1c2VyOnVudXNlZA==");

Review Comment:
   Updated in `9d2b2e5fc`. The provider tests now verify that identical 
mixed-case `Authorization` keys send exactly one value on each discovery page 
and that conflicting values are rejected before any HTTP request, with only the 
header name in the error. The targeted discovery and provider suites passed on 
Spark 3.5 and 4.0 (94 tests total).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to