Skip to content

Commit 677a1da

Browse files
authored
Disallow space character when validating tenant id and scopes as input for AzureCliCredential. (#5085)
* Disallow space character when validating tenant id and scopes as input for AzureCliCredential. * Address PR feedback.
1 parent bc2bb8d commit 677a1da

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

sdk/identity/azure-identity/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
### Bugs Fixed
1010

11+
- Disallow space character when validating tenant id and scopes as input for `AzureCliCredential`.
12+
1113
### Other Changes
1214

1315
## 1.6.0-beta.3 (2023-10-12)

sdk/identity/azure-identity/src/azure_cli_credential.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ void AzureCliCredential::ThrowIfNotSafeCmdLineInput(
6868
case '.':
6969
case '-':
7070
case '_':
71-
case ' ':
7271
break;
7372

7473
default:

sdk/identity/azure-identity/test/ut/azure_cli_credential_test.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,33 @@ TEST(AzureCliCredential, UnsafeChars)
344344
}
345345
}
346346

347+
TEST(AzureCliCredential, SpaceNotAllowed)
348+
{
349+
std::string const invalid = "space character";
350+
351+
{
352+
AzureCliCredentialOptions options;
353+
options.TenantId = "01234567-89AB-CDEF-0123-456789ABCDEF";
354+
options.TenantId += invalid;
355+
AzureCliCredential azCliCred(options);
356+
357+
TokenRequestContext trc;
358+
trc.Scopes.push_back(std::string("https://storage.azure.com/.default"));
359+
EXPECT_THROW(static_cast<void>(azCliCred.GetToken(trc, {})), AuthenticationException);
360+
}
361+
362+
{
363+
AzureCliCredentialOptions options;
364+
options.CliProcessTimeout = std::chrono::hours(24);
365+
AzureCliCredential azCliCred(options);
366+
367+
TokenRequestContext trc;
368+
trc.Scopes.push_back(std::string("https://storage.azure.com/.default") + invalid);
369+
370+
EXPECT_THROW(static_cast<void>(azCliCred.GetToken(trc, {})), AuthenticationException);
371+
}
372+
}
373+
347374
TEST(AzureCliCredential, StrictIso8601TimeFormat)
348375
{
349376
constexpr auto Token = "{\"accessToken\":\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\","

0 commit comments

Comments
 (0)