Skip to content

Commit 8a6980c

Browse files
authored
Pop client_secret to protect pipeline (#36947)
1 parent 99bfd77 commit 8a6980c

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

sdk/identity/azure-identity/azure/identity/_internal/aad_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ def _run_pipeline(self, request: HttpRequest, **kwargs: Any) -> AccessToken:
6868
# tenant_id is already part of `request` at this point
6969
kwargs.pop("tenant_id", None)
7070
kwargs.pop("claims", None)
71+
kwargs.pop("client_secret", None)
7172
enable_cae = kwargs.pop("enable_cae", False)
7273
now = int(time.time())
7374
response = self._pipeline.run(request, retry_on_methods=self._POST, **kwargs)

sdk/identity/azure-identity/azure/identity/aio/_internal/aad_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ async def _run_pipeline(self, request: HttpRequest, **kwargs) -> AccessToken:
8888
# tenant_id is already part of `request` at this point
8989
kwargs.pop("tenant_id", None)
9090
kwargs.pop("claims", None)
91+
kwargs.pop("client_secret", None)
9192
enable_cae = kwargs.pop("enable_cae", False)
9293
now = int(time.time())
9394
response = await self._pipeline.run(request, retry_on_methods=self._POST, **kwargs)

sdk/identity/azure-identity/tests/test_aad_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ def send(request, **_):
107107
client.obtain_token_by_authorization_code("scope", "code", "uri")
108108
client.obtain_token_by_refresh_token("scope", "refresh token")
109109

110+
# obtain_token_by_refresh_token is client_secret safe
111+
client.obtain_token_by_refresh_token("scope", "refresh token", client_secret="secret")
112+
110113
# authority can be configured via environment variable
111114
with patch.dict("os.environ", {EnvironmentVariables.AZURE_AUTHORITY_HOST: authority}, clear=True):
112115
client = AadClient(tenant_id=tenant_id, client_id="client id", transport=Mock(send=send))

sdk/identity/azure-identity/tests/test_aad_client_async.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ async def send(request, **_):
179179
await client.obtain_token_by_authorization_code("scope", "code", "uri")
180180
await client.obtain_token_by_refresh_token("scope", "refresh token")
181181

182+
# obtain_token_by_refresh_token is client_secret safe
183+
client.obtain_token_by_refresh_token("scope", "refresh token", client_secret="secret")
184+
182185
# authority can be configured via environment variable
183186
with patch.dict("os.environ", {EnvironmentVariables.AZURE_AUTHORITY_HOST: authority}, clear=True):
184187
client = AadClient(tenant_id=tenant_id, client_id="client id", transport=Mock(send=send))

0 commit comments

Comments
 (0)