Skip to content

Commit

Permalink
Update all setting scope to use snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
bcgov-hl committed Nov 21, 2023
1 parent 4ba878d commit cd6a5ec
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion OFM.Infrastructure.WebAPI/Extensions/ApiKeyMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public ApiKeyMiddleware(RequestDelegate next, ILoggerFactory loggerFactory)
}

public async Task InvokeAsync(HttpContext context,
IOptions<AuthenticationSettings> options)
IOptionsSnapshot<AuthenticationSettings> options)
{
var apiKeys = options.Value.Schemes.ApiKeyScheme.Keys;
var apiKeyPresentInHeader = context.Request.Headers.TryGetValue(options.Value.Schemes.ApiKeyScheme.ApiKeyName ?? "", out var extractedApiKey);
Expand Down
2 changes: 1 addition & 1 deletion OFM.Infrastructure.WebAPI/Handlers/EnvironmentHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class EnvironmentHandlers
/// <param name="options"></param>
/// <returns></returns>
public static Results<ProblemHttpResult, Ok<JsonObject>> Get(
IOptions<D365AuthSettings> options)
IOptionsSnapshot<D365AuthSettings> options)
{
var _authConfig = options.Value;
_authConfig.AZAppUsers = new List<AZAppUser>();
Expand Down
2 changes: 1 addition & 1 deletion OFM.Infrastructure.WebAPI/Handlers/OperationsHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static class OperationsHandlers

public static async Task<Results<BadRequest<string>, ProblemHttpResult, Ok<JsonObject>>> GetAsync(
HttpContext context,
IOptions<AppSettings> appSettings,
IOptionsSnapshot<AppSettings> appSettings,
ID365AppUserService appUserService,
ID365WebApiService d365WebApiService,
ILoggerFactory loggerFactory,
Expand Down
4 changes: 2 additions & 2 deletions OFM.Infrastructure.WebAPI/OFM.Infrastructure.WebAPI.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace OFM.Infrastructure.WebAPI.Services.AppUsers;
public class D365AppUserService : ID365AppUserService
{
readonly D365AuthSettings? _authSettings;
public D365AppUserService(IOptions<D365AuthSettings> authSettings) => _authSettings = authSettings.Value;
public D365AppUserService(IOptionsSnapshot<D365AuthSettings> authSettings) => _authSettings = authSettings.Value;

public AZAppUser AZPortalAppUser => GetAZAppUser(Setup.AppUserType.Portal);

Expand All @@ -17,6 +17,6 @@ public class D365AppUserService : ID365AppUserService

public AZAppUser GetAZAppUser(string userType)
{
return _authSettings?.AZAppUsers.First(u => u.Type == userType) ?? throw new KeyNotFoundException( $"Integration User not found for {userType} - {nameof(D365AppUserService)}");
return _authSettings?.AZAppUsers.First(u => u.Type == userType) ?? throw new KeyNotFoundException($"Integration User not found for {userType} - {nameof(D365AppUserService)}");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class D365AuthServiceMSAL : ID365AuthenticationService
private readonly ID365TokenService _tokenService;
private readonly IHttpClientFactory _httpClientFactory;

public D365AuthServiceMSAL(IOptions<D365AuthSettings> authSettings, ID365TokenService tokenService, IHttpClientFactory factory)
public D365AuthServiceMSAL(IOptionsSnapshot<D365AuthSettings> authSettings, ID365TokenService tokenService, IHttpClientFactory factory)
{
_authSettings = authSettings.Value;
_tokenService = tokenService ?? throw new ArgumentNullException(nameof(tokenService));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class D365WebAPIService : ID365WebApiService
private readonly ID365AuthenticationService _authenticationService;
private readonly D365AuthSettings _d365AuthSettings;

public D365WebAPIService(ILoggerFactory loggerFactory, IOptions<D365AuthSettings> d365AuthSettings, ID365AuthenticationService authenticationService)
public D365WebAPIService(ILoggerFactory loggerFactory, IOptionsSnapshot<D365AuthSettings> d365AuthSettings, ID365AuthenticationService authenticationService)
{
_logger = loggerFactory.CreateLogger(LogCategory.Process);
_d365AuthSettings = d365AuthSettings.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class P200EmailReminderProvider : ID365ProcessProvider
private readonly TimeProvider _timeProvider;
private ProcessData? _data;

public P200EmailReminderProvider(IOptions<NotificationSettings> notificationSettings, ID365AppUserService appUserService, ID365WebApiService d365WebApiService, ILoggerFactory loggerFactory, TimeProvider timeProvider)
public P200EmailReminderProvider(IOptionsSnapshot<NotificationSettings> notificationSettings, ID365AppUserService appUserService, ID365WebApiService d365WebApiService, ILoggerFactory loggerFactory, TimeProvider timeProvider)
{
_notificationSettings = notificationSettings.Value;
_appUserService = appUserService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class P205SendNotificationProvider : ID365ProcessProvider
private ProcessData? _data;
private ProcessParameter? _processParams;

public P205SendNotificationProvider(IOptions<NotificationSettings> notificationSettings, ID365AppUserService appUserService, ID365WebApiService d365WebApiService, ILoggerFactory loggerFactory, TimeProvider timeProvider)
public P205SendNotificationProvider(IOptionsSnapshot<NotificationSettings> notificationSettings, ID365AppUserService appUserService, ID365WebApiService d365WebApiService, ILoggerFactory loggerFactory, TimeProvider timeProvider)
{
_notificationSettings = notificationSettings.Value;
_appUserService = appUserService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class P100InactiveRequestProvider : ID365ProcessProvider
private readonly TimeProvider _timeProvider;
private ProcessData? _data;

public P100InactiveRequestProvider(IOptions<ProcessSettings> processSettings, ID365AppUserService appUserService, ID365WebApiService d365WebApiService, ILoggerFactory loggerFactory, TimeProvider timeProvider)
public P100InactiveRequestProvider(IOptionsSnapshot<ProcessSettings> processSettings, ID365AppUserService appUserService, ID365WebApiService d365WebApiService, ILoggerFactory loggerFactory, TimeProvider timeProvider)
{
_processSettings = processSettings.Value;
_appUserService = appUserService;
Expand Down

0 comments on commit cd6a5ec

Please sign in to comment.