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.
This commit is contained in:
Ahson Khan 2023-11-01 19:04:26 -07:00 committed by GitHub
parent bc2bb8da0b
commit 677a1da61e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 1 deletions

View File

@ -8,6 +8,8 @@
### Bugs Fixed
- Disallow space character when validating tenant id and scopes as input for `AzureCliCredential`.
### Other Changes
## 1.6.0-beta.3 (2023-10-12)

View File

@ -68,7 +68,6 @@ void AzureCliCredential::ThrowIfNotSafeCmdLineInput(
case '.':
case '-':
case '_':
case ' ':
break;
default:

View File

@ -344,6 +344,33 @@ TEST(AzureCliCredential, UnsafeChars)
}
}
TEST(AzureCliCredential, SpaceNotAllowed)
{
std::string const invalid = "space character";
{
AzureCliCredentialOptions options;
options.TenantId = "01234567-89AB-CDEF-0123-456789ABCDEF";
options.TenantId += invalid;
AzureCliCredential azCliCred(options);
TokenRequestContext trc;
trc.Scopes.push_back(std::string("https://storage.azure.com/.default"));
EXPECT_THROW(static_cast<void>(azCliCred.GetToken(trc, {})), AuthenticationException);
}
{
AzureCliCredentialOptions options;
options.CliProcessTimeout = std::chrono::hours(24);
AzureCliCredential azCliCred(options);
TokenRequestContext trc;
trc.Scopes.push_back(std::string("https://storage.azure.com/.default") + invalid);
EXPECT_THROW(static_cast<void>(azCliCred.GetToken(trc, {})), AuthenticationException);
}
}
TEST(AzureCliCredential, StrictIso8601TimeFormat)
{
constexpr auto Token = "{\"accessToken\":\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\","