This is an automated email from the ASF dual-hosted git repository.

xiangfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 25f4ca05836 [pinot-adls] Add SAS token authentication support in 
ADLSGen2PinotFS (#16343)
25f4ca05836 is described below

commit 25f4ca0583600f826cc963f49b96bc2d7c68b36a
Author: Suvodeep Pyne <[email protected]>
AuthorDate: Wed Jul 16 16:52:36 2025 -0700

    [pinot-adls] Add SAS token authentication support in ADLSGen2PinotFS 
(#16343)
---
 .../pinot/plugin/filesystem/ADLSGen2PinotFS.java   | 14 ++++++-
 .../filesystem/test/ADLSGen2PinotFSTest.java       | 48 ++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)

diff --git 
a/pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/ADLSGen2PinotFS.java
 
b/pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/ADLSGen2PinotFS.java
index ed40b34cc09..47613387398 100644
--- 
a/pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/ADLSGen2PinotFS.java
+++ 
b/pinot-plugins/pinot-file-system/pinot-adls/src/main/java/org/apache/pinot/plugin/filesystem/ADLSGen2PinotFS.java
@@ -18,6 +18,7 @@
  */
 package org.apache.pinot.plugin.filesystem;
 
+import com.azure.core.credential.AzureSasCredential;
 import com.azure.core.http.ProxyOptions;
 import com.azure.core.http.netty.NettyAsyncHttpClientBuilder;
 import com.azure.core.http.rest.PagedIterable;
@@ -74,7 +75,7 @@ public class ADLSGen2PinotFS extends BasePinotFS {
   private static final Logger LOGGER = 
LoggerFactory.getLogger(ADLSGen2PinotFS.class);
 
   private enum AuthenticationType {
-    ACCESS_KEY, AZURE_AD, AZURE_AD_WITH_PROXY, ANONYMOUS_ACCESS, DEFAULT
+    ACCESS_KEY, AZURE_AD, AZURE_AD_WITH_PROXY, ANONYMOUS_ACCESS, DEFAULT, 
SAS_TOKEN
   }
 
   private static final String AUTHENTICATION_TYPE = "authenticationType";
@@ -91,6 +92,7 @@ public class ADLSGen2PinotFS extends BasePinotFS {
   private static final String PROXY_PORT = "proxyPort";
   private static final String PROXY_USERNAME = "proxyUsername";
   private static final String PROXY_PASSWORD = "proxyPassword";
+  private static final String SAS_TOKEN = "sasToken";
 
   private static final String HTTPS_URL_PREFIX = "https://";;
 
@@ -140,6 +142,7 @@ public class ADLSGen2PinotFS extends BasePinotFS {
     String proxyUsername = config.getProperty(PROXY_USERNAME);
     String proxyPassword = config.getProperty(PROXY_PASSWORD);
     String proxyPort = config.getProperty(PROXY_PORT);
+    String sasToken = config.getProperty(SAS_TOKEN);
 
     String dfsServiceEndpointUrl = HTTPS_URL_PREFIX + accountName + 
AZURE_STORAGE_DNS_SUFFIX;
 
@@ -156,6 +159,15 @@ public class ADLSGen2PinotFS extends BasePinotFS {
         dataLakeServiceClientBuilder.credential(sharedKeyCredential);
         break;
       }
+      case SAS_TOKEN: {
+        LOGGER.info("Authenticating using the sas token for the account.");
+        Preconditions.checkNotNull(accountName, "Account Name cannot be null");
+        Preconditions.checkNotNull(sasToken, "SAS Token cannot be null");
+
+        AzureSasCredential azureSasCredential = new 
AzureSasCredential(sasToken);
+        dataLakeServiceClientBuilder.credential(azureSasCredential);
+        break;
+      }
       case AZURE_AD: {
         LOGGER.info("Authenticating using Azure Active Directory");
         Preconditions.checkNotNull(clientId, "Client ID cannot be null");
diff --git 
a/pinot-plugins/pinot-file-system/pinot-adls/src/test/java/org/apache/pinot/plugin/filesystem/test/ADLSGen2PinotFSTest.java
 
b/pinot-plugins/pinot-file-system/pinot-adls/src/test/java/org/apache/pinot/plugin/filesystem/test/ADLSGen2PinotFSTest.java
index 3474cd5c2e5..4202ae7fdfd 100644
--- 
a/pinot-plugins/pinot-file-system/pinot-adls/src/test/java/org/apache/pinot/plugin/filesystem/test/ADLSGen2PinotFSTest.java
+++ 
b/pinot-plugins/pinot-file-system/pinot-adls/src/test/java/org/apache/pinot/plugin/filesystem/test/ADLSGen2PinotFSTest.java
@@ -115,6 +115,54 @@ public class ADLSGen2PinotFSTest {
     _adlsGen2PinotFsUnderTest.init(pinotConfiguration);
   }
 
+  @Test
+  public void testSasTokenAuthentication() {
+    PinotConfiguration pinotConfiguration = new PinotConfiguration();
+    pinotConfiguration.setProperty("authenticationType", "SAS_TOKEN");
+    pinotConfiguration.setProperty("sasToken", 
"sp=rwdl&se=2025-12-31T23:59:59Z&sv=2022-11-02&sr=c&sig=test");
+    pinotConfiguration.setProperty("accountName", "testaccount");
+    pinotConfiguration.setProperty("fileSystemName", "testcontainer");
+
+    
when(_mockServiceClient.getFileSystemClient("testcontainer")).thenReturn(_mockFileSystemClient);
+    when(_mockFileSystemClient.getProperties()).thenReturn(null);
+
+    // Mock the creation of the service client
+    ADLSGen2PinotFS sasTokenFS = new ADLSGen2PinotFS() {
+      @Override
+      public DataLakeFileSystemClient 
getOrCreateClientWithFileSystem(DataLakeServiceClient serviceClient,
+          String fileSystemName) {
+        return _mockFileSystemClient;
+      }
+    };
+
+    sasTokenFS.init(pinotConfiguration);
+
+    // Verify that the filesystem client was set properly
+    assertTrue(sasTokenFS != null);
+  }
+
+  @Test(expectedExceptions = NullPointerException.class)
+  public void testSasTokenMissingToken() {
+    PinotConfiguration pinotConfiguration = new PinotConfiguration();
+    pinotConfiguration.setProperty("authenticationType", "SAS_TOKEN");
+    pinotConfiguration.setProperty("accountName", "testaccount");
+    pinotConfiguration.setProperty("fileSystemName", "testcontainer");
+    // Missing sasToken property
+
+    _adlsGen2PinotFsUnderTest.init(pinotConfiguration);
+  }
+
+  @Test(expectedExceptions = NullPointerException.class)
+  public void testSasTokenNullToken() {
+    PinotConfiguration pinotConfiguration = new PinotConfiguration();
+    pinotConfiguration.setProperty("authenticationType", "SAS_TOKEN");
+    pinotConfiguration.setProperty("sasToken", (String) null);
+    pinotConfiguration.setProperty("accountName", "testaccount");
+    pinotConfiguration.setProperty("fileSystemName", "testcontainer");
+
+    _adlsGen2PinotFsUnderTest.init(pinotConfiguration);
+  }
+
   @Test
   public void testGetOrCreateClientWithFileSystemGet() {
     
when(_mockServiceClient.getFileSystemClient(MOCK_FILE_SYSTEM_NAME)).thenReturn(_mockFileSystemClient);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to