Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dan.Common/Services/PluginCredentialService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Azure.Core;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace Dan.Common.Services;

Expand All @@ -21,7 +22,7 @@ public interface IPluginCredentialService
/// <summary>
/// Service for handling getting auth token for plugins
/// </summary>
public class PluginCredentialService(IConfiguration configuration) : IPluginCredentialService
public class PluginCredentialService(IConfiguration configuration, ILogger<PluginCredentialService> logger) : IPluginCredentialService
{
private readonly DefaultAzureCredential credentials = new();
private readonly AsyncNonKeyedLocker semaphore = new(1);
Expand All @@ -44,6 +45,9 @@ public class PluginCredentialService(IConfiguration configuration) : IPluginCred

using (await semaphore.LockAsync(cancellationToken))
{
var clientid = configuration.GetSection("AZURE_CLIENT_ID").Value;
var ident = configuration.GetSection("AZURE_CLIENT_SECRET").Value?[..5];
logger.LogInformation("Getting token for {clientid} - {ident}", clientid, ident);
var tokenRequestContext = new TokenRequestContext(scopes);
var tokenResult = await credentials.GetTokenAsync(tokenRequestContext, cancellationToken);
return tokenResult.Token;
Expand Down
Loading