Skip to content

Commit

Permalink
Add constructor overload for MAuthAuthenticator to allow passing http…
Browse files Browse the repository at this point in the history
… client
  • Loading branch information
lyndon-gabriel committed Dec 13, 2024
1 parent 9f87ee3 commit f9f758d
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Medidata.MAuth.Core/MAuthAuthenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,24 @@ public MAuthAuthenticator(MAuthOptionsBase options, ILogger logger, ICacheServic
_lazyHttpClient = new Lazy<HttpClient>(() => CreateHttpClient(options));
_dateTimeOffsetWrapper = options.DateTimeOffsetWrapper;
}

public MAuthAuthenticator(MAuthOptionsBase options, ILogger logger, HttpClient httpClient, ICacheService cacheService = null)
{
if (options.ApplicationUuid == default)
throw new ArgumentException(nameof(options.ApplicationUuid));

if (options.MAuthServiceUrl == null)
throw new ArgumentNullException(nameof(options.MAuthServiceUrl));

if (string.IsNullOrWhiteSpace(options.PrivateKey))
throw new ArgumentNullException(nameof(options.PrivateKey));

_cache = cacheService ?? new MemoryCacheService(new MemoryCache(new MemoryCacheOptions()));
_options = options;
_logger = logger;
_lazyHttpClient = new Lazy<HttpClient>(() => httpClient);
_dateTimeOffsetWrapper = options.DateTimeOffsetWrapper;
}

/// <summary>
/// Verifies if the <see cref="HttpRequestMessage"/> request is authenticated or not.
Expand Down

0 comments on commit f9f758d

Please sign in to comment.