Skip to content

Commit 6ed3e15

Browse files
authored
make is_chained internal only (Azure#31296)
1 parent 98559ae commit 6ed3e15

File tree

12 files changed

+42
-42
lines changed

12 files changed

+42
-42
lines changed

sdk/identity/azure-identity/azure/identity/_credentials/azd_cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ def __init__(
7575
tenant_id: str = "",
7676
additionally_allowed_tenants: Optional[List[str]] = None,
7777
process_timeout: int = 10,
78-
is_chained: bool = False,
78+
_is_chained: bool = False,
7979
) -> None:
8080

8181
self.tenant_id = tenant_id
82-
self._is_chained = is_chained
82+
self._is_chained = _is_chained
8383
self._additionally_allowed_tenants = additionally_allowed_tenants or []
8484
self._process_timeout = process_timeout
8585

@@ -123,7 +123,7 @@ def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken:
123123
)
124124
if tenant:
125125
command += " --tenant-id " + tenant
126-
output = _run_command(command, self._process_timeout, is_chained=self._is_chained)
126+
output = _run_command(command, self._process_timeout, _is_chained=self._is_chained)
127127

128128
token = parse_token(output)
129129
if not token:
@@ -189,7 +189,7 @@ def sanitize_output(output: str) -> str:
189189
return re.sub(r"\"token\": \"(.*?)(\"|$)", "****", output)
190190

191191

192-
def _run_command(command: str, timeout: int, is_chained: bool = False) -> str:
192+
def _run_command(command: str, timeout: int, _is_chained: bool = False) -> str:
193193
# Ensure executable exists in PATH first. This avoids a subprocess call that would fail anyway.
194194
if shutil.which(EXECUTABLE_NAME) is None:
195195
raise CredentialUnavailableError(message=CLI_NOT_FOUND)
@@ -223,7 +223,7 @@ def _run_command(command: str, timeout: int, is_chained: bool = False) -> str:
223223
message = sanitize_output(ex.stderr)
224224
else:
225225
message = "Failed to invoke Azure Developer CLI"
226-
if is_chained:
226+
if _is_chained:
227227
raise CredentialUnavailableError(message=message) from ex
228228
raise ClientAuthenticationError(message=message) from ex
229229
except OSError as ex:

sdk/identity/azure-identity/azure/identity/_credentials/azure_cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def __init__(
5353
tenant_id: str = "",
5454
additionally_allowed_tenants: Optional[List[str]] = None,
5555
process_timeout: int = 10,
56-
is_chained: bool = False,
56+
_is_chained: bool = False,
5757
) -> None:
5858

5959
self.tenant_id = tenant_id
60-
self._is_chained = is_chained
60+
self._is_chained = _is_chained
6161
self._additionally_allowed_tenants = additionally_allowed_tenants or []
6262
self._process_timeout = process_timeout
6363

@@ -97,7 +97,7 @@ def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken:
9797
)
9898
if tenant:
9999
command += " --tenant " + tenant
100-
output = _run_command(command, self._process_timeout, is_chained=self._is_chained)
100+
output = _run_command(command, self._process_timeout, _is_chained=self._is_chained)
101101

102102
token = parse_token(output)
103103
if not token:
@@ -165,7 +165,7 @@ def sanitize_output(output: str) -> str:
165165
return re.sub(r"\"accessToken\": \"(.*?)(\"|$)", "****", output)
166166

167167

168-
def _run_command(command: str, timeout: int, is_chained: bool = False) -> str:
168+
def _run_command(command: str, timeout: int, _is_chained: bool = False) -> str:
169169
# Ensure executable exists in PATH first. This avoids a subprocess call that would fail anyway.
170170
if shutil.which(EXECUTABLE_NAME) is None:
171171
raise CredentialUnavailableError(message=CLI_NOT_FOUND)
@@ -198,7 +198,7 @@ def _run_command(command: str, timeout: int, is_chained: bool = False) -> str:
198198
message = sanitize_output(ex.stderr)
199199
else:
200200
message = "Failed to invoke Azure CLI"
201-
if is_chained:
201+
if _is_chained:
202202
raise CredentialUnavailableError(message=message) from ex
203203
raise ClientAuthenticationError(message=message) from ex
204204
except OSError as ex:

sdk/identity/azure-identity/azure/identity/_credentials/azure_powershell.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ def __init__(
6767
tenant_id: str = "",
6868
additionally_allowed_tenants: Optional[List[str]] = None,
6969
process_timeout: int = 10,
70-
is_chained: bool = False
70+
_is_chained: bool = False
7171
) -> None:
7272

7373
self.tenant_id = tenant_id
74-
self._is_chained = is_chained
74+
self._is_chained = _is_chained
7575
self._additionally_allowed_tenants = additionally_allowed_tenants or []
7676
self._process_timeout = process_timeout
7777

@@ -109,7 +109,7 @@ def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken:
109109
)
110110
command_line = get_command_line(scopes, tenant_id)
111111
output = run_command_line(command_line, self._process_timeout)
112-
token = parse_token(output, is_chained=self._is_chained)
112+
token = parse_token(output, _is_chained=self._is_chained)
113113
return token
114114

115115

@@ -155,13 +155,13 @@ def start_process(args: List[str]) -> "subprocess.Popen":
155155
return proc
156156

157157

158-
def parse_token(output: str, is_chained: bool = False) -> AccessToken:
158+
def parse_token(output: str, _is_chained: bool = False) -> AccessToken:
159159
for line in output.split():
160160
if line.startswith("azsdk%"):
161161
_, token, expires_on = line.split("%")
162162
return AccessToken(token, int(expires_on))
163163

164-
if is_chained:
164+
if _is_chained:
165165
raise CredentialUnavailableError(message='Unexpected output from Get-AzAccessToken: "{}"'.format(output))
166166
raise ClientAuthenticationError(message='Unexpected output from Get-AzAccessToken: "{}"'.format(output))
167167

sdk/identity/azure-identity/azure/identity/_credentials/browser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, **kwargs: Any) -> None:
7878
else:
7979
self._parsed_url = None
8080

81-
self._is_chained = kwargs.pop("is_chained", False)
81+
self._is_chained = kwargs.pop("_is_chained", False)
8282
self._login_hint = kwargs.pop("login_hint", None)
8383
self._timeout = kwargs.pop("timeout", 300)
8484
self._server_class = kwargs.pop("_server_class", AuthCodeRedirectServer)

sdk/identity/azure-identity/azure/identity/_credentials/default.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,33 +173,33 @@ def __init__(self, **kwargs: Any) -> None: # pylint: disable=too-many-statement
173173
username=shared_cache_username,
174174
tenant_id=shared_cache_tenant_id,
175175
authority=authority,
176-
is_chained=True,
176+
_is_chained=True,
177177
**kwargs
178178
)
179179
credentials.append(shared_cache)
180180
except Exception as ex: # pylint:disable=broad-except
181181
_LOGGER.info("Shared token cache is unavailable: '%s'", ex)
182182
if not exclude_visual_studio_code_credential:
183-
credentials.append(VisualStudioCodeCredential(is_chained=True, **vscode_args))
183+
credentials.append(VisualStudioCodeCredential(_is_chained=True, **vscode_args))
184184
if not exclude_cli_credential:
185-
credentials.append(AzureCliCredential(process_timeout=process_timeout, is_chained=True))
185+
credentials.append(AzureCliCredential(process_timeout=process_timeout, _is_chained=True))
186186
if not exclude_powershell_credential:
187-
credentials.append(AzurePowerShellCredential(process_timeout=process_timeout, is_chained=True))
187+
credentials.append(AzurePowerShellCredential(process_timeout=process_timeout, _is_chained=True))
188188
if not exclude_developer_cli_credential:
189-
credentials.append(AzureDeveloperCliCredential(process_timeout=process_timeout, is_chained=True))
189+
credentials.append(AzureDeveloperCliCredential(process_timeout=process_timeout, _is_chained=True))
190190
if not exclude_interactive_browser_credential:
191191
if interactive_browser_client_id:
192192
credentials.append(
193193
InteractiveBrowserCredential(
194194
tenant_id=interactive_browser_tenant_id,
195195
client_id=interactive_browser_client_id,
196-
is_chained=True,
196+
_is_chained=True,
197197
**kwargs
198198
)
199199
)
200200
else:
201201
credentials.append(
202-
InteractiveBrowserCredential(tenant_id=interactive_browser_tenant_id, is_chained=True, **kwargs)
202+
InteractiveBrowserCredential(tenant_id=interactive_browser_tenant_id, _is_chained=True, **kwargs)
203203
)
204204

205205
super(DefaultAzureCredential, self).__init__(*credentials)

sdk/identity/azure-identity/azure/identity/_credentials/silent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
# authenticate in the tenant that produced the record unless "tenant_id" specifies another
3939
self._tenant_id = tenant_id or self._auth_record.tenant_id
4040
validate_tenant_id(self._tenant_id)
41-
self._is_chained = kwargs.pop("is_chained", False)
41+
self._is_chained = kwargs.pop("_is_chained", False)
4242
self._cache = kwargs.pop("_cache", None)
4343
self._cache_persistence_options = kwargs.pop("cache_persistence_options", None)
4444
self._client_applications: Dict[str, PublicClientApplication] = {}

sdk/identity/azure-identity/azure/identity/_credentials/vscode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, **kwargs: Any) -> None:
2929
super(_VSCodeCredentialBase, self).__init__()
3030

3131
user_settings = get_user_settings()
32-
self._is_chained = kwargs.pop("is_chained", False)
32+
self._is_chained = kwargs.pop("_is_chained", False)
3333
self._cloud = user_settings.get("azure.cloud", "AzureCloud")
3434
self._refresh_token = None
3535
self._unavailable_reason = ""

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __init__(
9292
self._authority = normalize_authority(authority) if authority else get_default_authority()
9393
environment = urlparse(self._authority).netloc
9494
self._environment_aliases = KNOWN_ALIASES.get(environment) or frozenset((environment,))
95-
self._is_chained = kwargs.pop("is_chained", False)
95+
self._is_chained = kwargs.pop("_is_chained", False)
9696
self._username = username
9797
self._tenant_id = tenant_id
9898
self._cache = kwargs.pop("_cache", None)

sdk/identity/azure-identity/azure/identity/aio/_credentials/azd_cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ def __init__(
7272
tenant_id: str = "",
7373
additionally_allowed_tenants: Optional[List[str]] = None,
7474
process_timeout: int = 10,
75-
is_chained: bool = False,
75+
_is_chained: bool = False,
7676
) -> None:
7777

7878
self.tenant_id = tenant_id
79-
self._is_chained = is_chained
79+
self._is_chained = _is_chained
8080
self._additionally_allowed_tenants = additionally_allowed_tenants or []
8181
self._process_timeout = process_timeout
8282

@@ -113,7 +113,7 @@ async def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken:
113113

114114
if tenant:
115115
command += " --tenant-id " + tenant
116-
output = await _run_command(command, self._process_timeout, is_chained=self._is_chained)
116+
output = await _run_command(command, self._process_timeout, _is_chained=self._is_chained)
117117

118118
token = parse_token(output)
119119
if not token:
@@ -133,7 +133,7 @@ async def close(self) -> None:
133133
"""Calling this method is unnecessary"""
134134

135135

136-
async def _run_command(command: str, timeout: int, is_chained: bool = False) -> str:
136+
async def _run_command(command: str, timeout: int, _is_chained: bool = False) -> str:
137137
# Ensure executable exists in PATH first. This avoids a subprocess call that would fail anyway.
138138
if shutil.which(EXECUTABLE_NAME) is None:
139139
raise CredentialUnavailableError(message=CLI_NOT_FOUND)
@@ -175,6 +175,6 @@ async def _run_command(command: str, timeout: int, is_chained: bool = False) ->
175175
raise CredentialUnavailableError(message=NOT_LOGGED_IN)
176176

177177
message = sanitize_output(stderr) if stderr else "Failed to invoke Azure Developer CLI"
178-
if is_chained:
178+
if _is_chained:
179179
raise CredentialUnavailableError(message=message)
180180
raise ClientAuthenticationError(message=message)

sdk/identity/azure-identity/azure/identity/aio/_credentials/azure_cli.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ def __init__(
5353
tenant_id: str = "",
5454
additionally_allowed_tenants: Optional[List[str]] = None,
5555
process_timeout: int = 10,
56-
is_chained: bool = False,
56+
_is_chained: bool = False,
5757
) -> None:
5858

5959
self.tenant_id = tenant_id
60-
self._is_chained = is_chained
60+
self._is_chained = _is_chained
6161
self._additionally_allowed_tenants = additionally_allowed_tenants or []
6262
self._process_timeout = process_timeout
6363

@@ -91,7 +91,7 @@ async def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken:
9191

9292
if tenant:
9393
command += " --tenant " + tenant
94-
output = await _run_command(command, self._process_timeout, is_chained=self._is_chained)
94+
output = await _run_command(command, self._process_timeout, _is_chained=self._is_chained)
9595

9696
token = parse_token(output)
9797
if not token:
@@ -111,7 +111,7 @@ async def close(self) -> None:
111111
"""Calling this method is unnecessary"""
112112

113113

114-
async def _run_command(command: str, timeout: int, is_chained: bool = False) -> str:
114+
async def _run_command(command: str, timeout: int, _is_chained: bool = False) -> str:
115115
# Ensure executable exists in PATH first. This avoids a subprocess call that would fail anyway.
116116
if shutil.which(EXECUTABLE_NAME) is None:
117117
raise CredentialUnavailableError(message=CLI_NOT_FOUND)
@@ -153,6 +153,6 @@ async def _run_command(command: str, timeout: int, is_chained: bool = False) ->
153153
raise CredentialUnavailableError(message=NOT_LOGGED_IN)
154154

155155
message = sanitize_output(stderr) if stderr else "Failed to invoke Azure CLI"
156-
if is_chained:
156+
if _is_chained:
157157
raise CredentialUnavailableError(message=message)
158158
raise ClientAuthenticationError(message=message)

0 commit comments

Comments
 (0)