Skip to content

Commit 73f13f7

Browse files
YalpeCarl Tremblay
andauthored
Only trace authentication activity if the token is not cached (#177)
Co-authored-by: Carl Tremblay <carl.tremblay@workleap.com>
1 parent 8d335f8 commit 73f13f7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/Workleap.Extensions.Http.Authentication.ClientCredentialsGrant/ClientCredentialsTokenHttpMessageHandler.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public ClientCredentialsTokenHttpMessageHandler(IClientCredentialsTokenManagemen
4040
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
4141
{
4242
this.EnsureRequestIsSentOverHttps(request);
43-
using var activity = TracingHelper.StartAuthenticationActivity(this._options.ClientId);
4443
return await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
4544
}
4645

src/Workleap.Extensions.Http.Authentication.ClientCredentialsGrant/ClientCredentialsTokenManagementService.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// This file is based on https://github.com/DuendeSoftware/Duende.AccessTokenManagement/blob/1.1.0/src/Duende.AccessTokenManagement/ClientCredentialsTokenManagementService.cs
1+
// This file is based on https://github.com/DuendeSoftware/Duende.AccessTokenManagement/blob/1.1.0/src/Duende.AccessTokenManagement/ClientCredentialsTokenManagementService.cs
22
// Copyright (c) Brock Allen & Dominick Baier, licensed under the Apache License, Version 2.0. All rights reserved.
33
//
44
// The original file has been significantly modified, and these modifications are Copyright (c) Workleap, 2023.
@@ -81,6 +81,8 @@ private async Task<ClientCredentialsToken> SynchronizeAsync(string clientName, F
8181

8282
private Func<Task<ClientCredentialsToken>> GetNewTokenTaskFactory(string clientName, CancellationToken cancellationToken) => async () =>
8383
{
84+
using var activity = TracingHelper.StartAuthenticationActivity(this._optionsMonitor.Get(clientName).ClientId);
85+
8486
var newToken = await this._tokenEndpointService.RequestTokenAsync(clientName, cancellationToken).ConfigureAwait(false);
8587

8688
var cacheAbsoluteExpiration = await this._tokenCache.SetAsync(clientName, newToken, cancellationToken).ConfigureAwait(false);

0 commit comments

Comments
 (0)