Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit508faf1

Browse files
committed
Update client_id and redirect port for published Azure Client
1 parenta2a840a commit508faf1

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

‎src/databricks/sql/auth/auth.py‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ def get_auth_provider(cfg: ClientContext):
7676

7777
PYSQL_OAUTH_SCOPES= ["sql","offline_access"]
7878
PYSQL_OAUTH_CLIENT_ID="databricks-sql-python"
79-
PYSQL_OAUTH_AZURE_EXPERIMENTAL_CLIENT_ID="a743d78c-536a-4ffc-b110-edfb231e90dc"
79+
PYSQL_OAUTH_AZURE_CLIENT_ID="96eecda7-19ea-49cc-abb5-240097d554f5"
8080
PYSQL_OAUTH_REDIRECT_PORT_RANGE=list(range(8020,8025))
81+
PYSQL_OAUTH_AZURE_REDIRECT_PORT_RANGE= [8030]
8182

8283

8384
defnormalize_host_name(hostname:str):
@@ -86,15 +87,16 @@ def normalize_host_name(hostname: str):
8687
returnf"{maybe_scheme}{hostname}{maybe_trailing_slash}"
8788

8889

89-
defget_client_id(hostname:str):
90+
defget_client_id_and_redirect_port(hostname:str):
9091
return (
91-
PYSQL_OAUTH_CLIENT_ID
92+
(PYSQL_OAUTH_CLIENT_ID,PYSQL_OAUTH_REDIRECT_PORT_RANGE)
9293
ifinfer_cloud_from_host(hostname)==CloudType.AWS
93-
elsePYSQL_OAUTH_AZURE_EXPERIMENTAL_CLIENT_ID
94+
else(PYSQL_OAUTH_AZURE_CLIENT_ID,PYSQL_OAUTH_AZURE_REDIRECT_PORT_RANGE)
9495
)
9596

9697

9798
defget_python_sql_connector_auth_provider(hostname:str,**kwargs):
99+
(client_id,redirect_port_range)=get_client_id_and_redirect_port(hostname)
98100
cfg=ClientContext(
99101
hostname=normalize_host_name(hostname),
100102
auth_type=kwargs.get("auth_type"),
@@ -104,10 +106,10 @@ def get_python_sql_connector_auth_provider(hostname: str, **kwargs):
104106
use_cert_as_auth=kwargs.get("_use_cert_as_auth"),
105107
tls_client_cert_file=kwargs.get("_tls_client_cert_file"),
106108
oauth_scopes=PYSQL_OAUTH_SCOPES,
107-
oauth_client_id=kwargs.get("oauth_client_id")orget_client_id(hostname),
109+
oauth_client_id=kwargs.get("oauth_client_id")orclient_id,
108110
oauth_redirect_port_range=[kwargs["oauth_redirect_port"]]
109111
ifkwargs.get("oauth_client_id")andkwargs.get("oauth_redirect_port")
110-
elsePYSQL_OAUTH_REDIRECT_PORT_RANGE,
112+
elseredirect_port_range,
111113
oauth_persistence=kwargs.get("experimental_oauth_persistence"),
112114
credentials_provider=kwargs.get("credentials_provider"),
113115
)

‎src/databricks/sql/auth/endpoint.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ def get_openid_config_url(self, hostname: str) -> str:
6767

6868

6969
classAzureOAuthEndpointCollection(OAuthEndpointCollection):
70-
DATATRICKS_AZURE_TENANT_ID="2ff814a6-3304-4ab8-85cb-cd0e6f879c1d"
70+
DATATRICKS_AZURE_APP="2ff814a6-3304-4ab8-85cb-cd0e6f879c1d"
7171

7272
defget_scopes_mapping(self,scopes:List[str])->List[str]:
7373
# There is no corresponding scopes in Azure, instead, access control will be delegated to Databricks
7474
tenant_id=os.getenv(
7575
"DATABRICKS_AZURE_TENANT_ID",
76-
AzureOAuthEndpointCollection.DATATRICKS_AZURE_TENANT_ID,
76+
AzureOAuthEndpointCollection.DATATRICKS_AZURE_APP,
7777
)
7878
azure_scope=f"{tenant_id}/user_impersonation"
7979
mapped_scopes= [azure_scope]

‎tests/unit/test_auth.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55

66
fromdatabricks.sql.auth.authimportAccessTokenAuthProvider,BasicAuthProvider,AuthProvider,ExternalAuthProvider
77
fromdatabricks.sql.auth.authimportget_python_sql_connector_auth_provider
8+
fromdatabricks.sql.auth.oauthimportOAuthManager
9+
fromdatabricks.sql.auth.authenticatorsimportDatabricksOAuthProvider
10+
fromdatabricks.sql.auth.endpointimportCloudType,AwsOAuthEndpointCollection,AzureOAuthEndpointCollection
811
fromdatabricks.sql.auth.authenticatorsimportCredentialsProvider,HeaderFactory
12+
fromdatabricks.sql.experimental.oauth_persistenceimportOAuthPersistenceCache
913

1014

1115
classAuth(unittest.TestCase):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp