From d159067850d83121630df9911773a8fcc4eb8a4d Mon Sep 17 00:00:00 2001 From: Nick Krantz Date: Tue, 20 May 2025 09:51:02 -0500 Subject: [PATCH] add individual settings for change password uri --- .../Controllers/ChangePasswordUriController.cs | 17 +++++++++++++++-- src/Icons/Models/ChangePasswordUriResponse.cs | 2 +- src/Icons/Models/ChangePasswordUriSettings.cs | 2 +- src/Icons/Services/ChangePasswordUriService.cs | 2 +- src/Icons/Startup.cs | 8 ++++++++ src/Icons/appsettings.json | 5 +++++ 6 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/Icons/Controllers/ChangePasswordUriController.cs b/src/Icons/Controllers/ChangePasswordUriController.cs index 338e757a07..28006cd136 100644 --- a/src/Icons/Controllers/ChangePasswordUriController.cs +++ b/src/Icons/Controllers/ChangePasswordUriController.cs @@ -1,4 +1,4 @@ -using Bit.Icons.Models; +using Bit.Icons.Models; using Bit.Icons.Services; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; @@ -17,11 +17,24 @@ public class ChangePasswordUriController : Controller public ChangePasswordUriController( IMemoryCache memoryCache, IDomainMappingService domainMappingService, - IChangePasswordUriService changePasswordService) + IChangePasswordUriService changePasswordService, + ChangePasswordUriSettings iconsSettings) { _memoryCache = memoryCache; _domainMappingService = domainMappingService; _changePasswordService = changePasswordService; + _changePasswordSettings = iconsSettings; + } + + [HttpGet("config")] + public IActionResult GetConfig() + { + return new JsonResult(new + { + _changePasswordSettings.CacheEnabled, + _changePasswordSettings.CacheHours, + _changePasswordSettings.CacheSizeLimit + }); } [HttpGet] diff --git a/src/Icons/Models/ChangePasswordUriResponse.cs b/src/Icons/Models/ChangePasswordUriResponse.cs index 8e15ce02e9..fa50c4da0e 100644 --- a/src/Icons/Models/ChangePasswordUriResponse.cs +++ b/src/Icons/Models/ChangePasswordUriResponse.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable namespace Bit.Icons.Models; diff --git a/src/Icons/Models/ChangePasswordUriSettings.cs b/src/Icons/Models/ChangePasswordUriSettings.cs index 97f475f958..bcb804f4e0 100644 --- a/src/Icons/Models/ChangePasswordUriSettings.cs +++ b/src/Icons/Models/ChangePasswordUriSettings.cs @@ -1,4 +1,4 @@ -namespace Bit.Icons.Models; +namespace Bit.Icons.Models; public class ChangePasswordUriSettings { diff --git a/src/Icons/Services/ChangePasswordUriService.cs b/src/Icons/Services/ChangePasswordUriService.cs index 8521c4935a..a89d9521d0 100644 --- a/src/Icons/Services/ChangePasswordUriService.cs +++ b/src/Icons/Services/ChangePasswordUriService.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable namespace Bit.Icons.Services; diff --git a/src/Icons/Startup.cs b/src/Icons/Startup.cs index 4695c320e9..16bbdef553 100644 --- a/src/Icons/Startup.cs +++ b/src/Icons/Startup.cs @@ -2,6 +2,7 @@ using Bit.Core.Settings; using Bit.Core.Utilities; using Bit.Icons.Extensions; +using Bit.Icons.Models; using Bit.SharedWeb.Utilities; using Microsoft.Net.Http.Headers; @@ -27,8 +28,11 @@ public class Startup // Settings var globalSettings = services.AddGlobalSettingsServices(Configuration, Environment); var iconsSettings = new IconsSettings(); + var changePasswordUriSettings = new ChangePasswordUriSettings(); ConfigurationBinder.Bind(Configuration.GetSection("IconsSettings"), iconsSettings); + ConfigurationBinder.Bind(Configuration.GetSection("ChangePasswordUriSettings"), changePasswordUriSettings); services.AddSingleton(s => iconsSettings); + services.AddSingleton(s => changePasswordUriSettings); // Http client services.ConfigureHttpClients(); @@ -41,6 +45,10 @@ public class Startup { options.SizeLimit = iconsSettings.CacheSizeLimit; }); + services.AddMemoryCache(options => + { + options.SizeLimit = changePasswordUriSettings.CacheSizeLimit; + }); // Services services.AddServices(); diff --git a/src/Icons/appsettings.json b/src/Icons/appsettings.json index 6b4e2992e0..5e1113b150 100644 --- a/src/Icons/appsettings.json +++ b/src/Icons/appsettings.json @@ -6,5 +6,10 @@ "cacheEnabled": true, "cacheHours": 24, "cacheSizeLimit": null + }, + "changePasswordUriSettings": { + "cacheEnabled": true, + "cacheHours": 24, + "cacheSizeLimit": null } }