Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit b316ea5

Browse files
committed
devops: Update logging to better reflect urls used
1 parent 23924fd commit b316ea5

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

AzureDevOps.Authentication/Src/Authority.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public async Task<bool> PopulateTokenTargetId(TargetUri targetUri, Token authori
289289
}
290290
}
291291

292-
Trace.WriteLine($"failed to acquire the token's target identity for `{targetUri}` [{(int)response.StatusCode}].");
292+
Trace.WriteLine($"failed to acquire the token's target identity for `{requestUri?.QueryUri}` [{(int)response.StatusCode}].");
293293
}
294294
}
295295
catch (HttpRequestException exception)
@@ -372,13 +372,13 @@ internal async Task<TargetUri> GetIdentityServiceUri(TargetUri targetUri, Secret
372372
}
373373
}
374374

375-
Trace.WriteLine($"failed to find Identity Service for '{targetUri}' via location service [{(int)response.StatusCode}].");
375+
Trace.WriteLine($"failed to find Identity Service for '{requestUri?.QueryUri}' via location service [{(int)response.StatusCode}].");
376376
}
377377
}
378378
catch (Exception exception)
379379
{
380380
Trace.WriteException(exception);
381-
throw new LocationServiceException($"Helper for `{targetUri}`.", exception);
381+
throw new LocationServiceException($"Helper for `{requestUri?.QueryUri}`.", exception);
382382
}
383383

384384
return null;
@@ -454,7 +454,7 @@ internal async Task<bool> ValidateSecret(TargetUri targetUri, Secret secret)
454454
// If the server responds with content, and said content matches the anonymous details the credentials are invalid.
455455
if (content != null && Regex.IsMatch(content, AnonymousUserPattern, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase))
456456
{
457-
Trace.WriteLine($"credential validation for '{targetUri}' failed.");
457+
Trace.WriteLine($"credential validation for '{requestUri?.QueryUri}' failed.");
458458

459459
return false;
460460
}
@@ -463,7 +463,7 @@ internal async Task<bool> ValidateSecret(TargetUri targetUri, Secret secret)
463463
if (statusCode >= HttpStatusCode.OK && statusCode < HttpStatusCode.Ambiguous)
464464
return true;
465465

466-
Trace.WriteLine($"credential validation for '{targetUri}' failed [{(int)response.StatusCode}].");
466+
Trace.WriteLine($"credential validation for '{requestUri?.QueryUri}' failed [{(int)response.StatusCode}].");
467467

468468
// Even if the service responded, if the issue isn't a 400 class response then the credentials were likely not rejected.
469469
if (statusCode < HttpStatusCode.BadRequest || statusCode >= HttpStatusCode.InternalServerError)
@@ -474,20 +474,20 @@ internal async Task<bool> ValidateSecret(TargetUri targetUri, Secret secret)
474474
{
475475
// Since we're unable to invalidate the credentials, return optimistic results.
476476
// This avoid credential invalidation due to network instability, etc.
477-
Trace.WriteLine($"unable to validate credentials for '{targetUri}', failure occurred before server could respond.");
477+
Trace.WriteLine($"unable to validate credentials for '{requestUri?.QueryUri}', failure occurred before server could respond.");
478478
Trace.WriteException(exception);
479479

480480
return true;
481481
}
482482
catch (Exception exception)
483483
{
484-
Trace.WriteLine($"credential validation for '{targetUri}' failed.");
484+
Trace.WriteLine($"credential validation for '{requestUri?.QueryUri}' failed.");
485485
Trace.WriteException(exception);
486486

487487
return false;
488488
}
489489

490-
Trace.WriteLine($"credential validation for '{targetUri}' failed.");
490+
Trace.WriteLine($"credential validation for '{requestUri?.QueryUri}' failed.");
491491
return false;
492492
}
493493

@@ -530,7 +530,7 @@ private StringContent GetAccessTokenRequestBody(TargetUri targetUri, TokenScope
530530

531531
string tokenUrl = GetTargetUrl(targetUri, false);
532532

533-
Trace.WriteLine($"creating access token scoped to '{tokenScope}' for '{targetUri}'");
533+
Trace.WriteLine($"creating access token scoped to '{tokenScope}' for '{tokenUrl}'");
534534

535535
string jsonContent = (duration.HasValue && duration.Value > TimeSpan.FromHours(1))
536536
? string.Format(Culture.InvariantCulture, ContentTimedJsonFormat, tokenScope, tokenUrl, Settings.MachineName, DateTime.UtcNow + duration.Value)

0 commit comments

Comments
 (0)