You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "ephraimbuddy (via GitHub)" <gi...@apache.org> on 2023/07/12 15:09:04 UTC

[GitHub] [airflow] ephraimbuddy commented on a diff in pull request #32082: Fix where account url is build if not provided using login (account name)

ephraimbuddy commented on code in PR #32082:
URL: https://github.com/apache/airflow/pull/32082#discussion_r1261328000


##########
airflow/providers/microsoft/azure/hooks/wasb.py:
##########
@@ -200,22 +190,33 @@ def get_conn(self) -> BlobServiceClient:
             token_credential = ClientSecretCredential(tenant, app_id, app_secret, **client_secret_auth_config)
             return BlobServiceClient(account_url=conn.host, credential=token_credential, **extra)
 
+        account_url = conn.host if conn.host else f"https://{conn.login}.blob.core.windows.net/"
+
+        if self.public_read:
+            # Here we use anonymous public read
+            # more info
+            # https://docs.microsoft.com/en-us/azure/storage/blobs/storage-manage-access-to-resources
+            return BlobServiceClient(account_url=account_url, **extra)
+
+        shared_access_key = self._get_field(extra, "shared_access_key")
+        if shared_access_key:
+            # using shared access key
+            return BlobServiceClient(account_url=account_url, credential=shared_access_key, **extra)
+
         sas_token = self._get_field(extra, "sas_token")
         if sas_token:
             if sas_token.startswith("https"):
                 return BlobServiceClient(account_url=sas_token, **extra)
             else:
-                return BlobServiceClient(
-                    account_url=f"https://{conn.login}.blob.core.windows.net/{sas_token}", **extra
-                )
+                return BlobServiceClient(account_url=f"{account_url}/{sas_token}", **extra)

Review Comment:
   This will give incorrect url if account_url ends with a slash e.g:
   account_url = https://{conn.login}.blob.core.windows.net/
   then here we will end up with:
   account_url = https://{conn.login}.blob.core.windows.net//sas_token



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org