Skip to content

Commit 537a981

Browse files
KenHundleyphilasmar
authored andcommitted
Delay SSO Options Validation
1 parent 85af718 commit 537a981

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

sdk/src/Core/Amazon.Runtime/Credentials/_bcl45+netstandard/SSOAWSCredentials.cs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -156,16 +156,6 @@ protected override async Task<CredentialsRefreshState> GenerateNewCredentialsAsy
156156

157157
private void ValidateCredentialsInputs()
158158
{
159-
if (string.IsNullOrEmpty(Options.ClientName))
160-
{
161-
throw new ArgumentNullException($"Options property cannot be empty: {nameof(Options.ClientName)}");
162-
}
163-
164-
if (Options.SsoVerificationCallback == null)
165-
{
166-
throw new ArgumentNullException($"Options property cannot be empty: {nameof(Options.SsoVerificationCallback)}");
167-
}
168-
169159
// Get the name of any empty properties
170160
var emptyPropertyNames = new Dictionary<string, string>
171161
{
@@ -236,6 +226,16 @@ private ImmutableCredentials GetSsoCredentials(ICoreAmazonSSOOIDC oidc, ICoreAma
236226
// Get and cache a SSO token if necessary
237227
if (string.IsNullOrWhiteSpace(token))
238228
{
229+
if (string.IsNullOrEmpty(Options.ClientName))
230+
{
231+
throw new ArgumentNullException($"Options property cannot be empty: {nameof(Options.ClientName)}");
232+
}
233+
234+
if (Options.SsoVerificationCallback == null)
235+
{
236+
throw new ArgumentNullException($"Options property cannot be empty: {nameof(Options.SsoVerificationCallback)}");
237+
}
238+
239239
var response = oidc.GetSsoToken(new GetSsoTokenRequest()
240240
{
241241
ClientName = GetSsoClientName(),
@@ -275,6 +275,16 @@ private async Task<ImmutableCredentials> GetSsoCredentialsAsync(ICoreAmazonSSOOI
275275
// Get and cache a SSO token if necessary
276276
if (string.IsNullOrWhiteSpace(token))
277277
{
278+
if (string.IsNullOrEmpty(Options.ClientName))
279+
{
280+
throw new ArgumentNullException($"Options property cannot be empty: {nameof(Options.ClientName)}");
281+
}
282+
283+
if (Options.SsoVerificationCallback == null)
284+
{
285+
throw new ArgumentNullException($"Options property cannot be empty: {nameof(Options.SsoVerificationCallback)}");
286+
}
287+
278288
var response = await oidc.GetSsoTokenAsync(new GetSsoTokenRequest()
279289
{
280290
ClientName = GetSsoClientName(),

0 commit comments

Comments
 (0)