1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-30 15:50:33 -05:00

add individual settings for change password uri

This commit is contained in:
Nick Krantz 2025-05-20 09:51:02 -05:00
parent 07390ef9fb
commit d159067850
No known key found for this signature in database
GPG Key ID: FF670021ABCAB82E
6 changed files with 31 additions and 5 deletions

View File

@ -1,4 +1,4 @@
using Bit.Icons.Models; using Bit.Icons.Models;
using Bit.Icons.Services; using Bit.Icons.Services;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.Caching.Memory;
@ -17,11 +17,24 @@ public class ChangePasswordUriController : Controller
public ChangePasswordUriController( public ChangePasswordUriController(
IMemoryCache memoryCache, IMemoryCache memoryCache,
IDomainMappingService domainMappingService, IDomainMappingService domainMappingService,
IChangePasswordUriService changePasswordService) IChangePasswordUriService changePasswordService,
ChangePasswordUriSettings iconsSettings)
{ {
_memoryCache = memoryCache; _memoryCache = memoryCache;
_domainMappingService = domainMappingService; _domainMappingService = domainMappingService;
_changePasswordService = changePasswordService; _changePasswordService = changePasswordService;
_changePasswordSettings = iconsSettings;
}
[HttpGet("config")]
public IActionResult GetConfig()
{
return new JsonResult(new
{
_changePasswordSettings.CacheEnabled,
_changePasswordSettings.CacheHours,
_changePasswordSettings.CacheSizeLimit
});
} }
[HttpGet] [HttpGet]

View File

@ -1,4 +1,4 @@
#nullable enable #nullable enable
namespace Bit.Icons.Models; namespace Bit.Icons.Models;

View File

@ -1,4 +1,4 @@
namespace Bit.Icons.Models; namespace Bit.Icons.Models;
public class ChangePasswordUriSettings public class ChangePasswordUriSettings
{ {

View File

@ -1,4 +1,4 @@
#nullable enable #nullable enable
namespace Bit.Icons.Services; namespace Bit.Icons.Services;

View File

@ -2,6 +2,7 @@
using Bit.Core.Settings; using Bit.Core.Settings;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using Bit.Icons.Extensions; using Bit.Icons.Extensions;
using Bit.Icons.Models;
using Bit.SharedWeb.Utilities; using Bit.SharedWeb.Utilities;
using Microsoft.Net.Http.Headers; using Microsoft.Net.Http.Headers;
@ -27,8 +28,11 @@ public class Startup
// Settings // Settings
var globalSettings = services.AddGlobalSettingsServices(Configuration, Environment); var globalSettings = services.AddGlobalSettingsServices(Configuration, Environment);
var iconsSettings = new IconsSettings(); var iconsSettings = new IconsSettings();
var changePasswordUriSettings = new ChangePasswordUriSettings();
ConfigurationBinder.Bind(Configuration.GetSection("IconsSettings"), iconsSettings); ConfigurationBinder.Bind(Configuration.GetSection("IconsSettings"), iconsSettings);
ConfigurationBinder.Bind(Configuration.GetSection("ChangePasswordUriSettings"), changePasswordUriSettings);
services.AddSingleton(s => iconsSettings); services.AddSingleton(s => iconsSettings);
services.AddSingleton(s => changePasswordUriSettings);
// Http client // Http client
services.ConfigureHttpClients(); services.ConfigureHttpClients();
@ -41,6 +45,10 @@ public class Startup
{ {
options.SizeLimit = iconsSettings.CacheSizeLimit; options.SizeLimit = iconsSettings.CacheSizeLimit;
}); });
services.AddMemoryCache(options =>
{
options.SizeLimit = changePasswordUriSettings.CacheSizeLimit;
});
// Services // Services
services.AddServices(); services.AddServices();

View File

@ -6,5 +6,10 @@
"cacheEnabled": true, "cacheEnabled": true,
"cacheHours": 24, "cacheHours": 24,
"cacheSizeLimit": null "cacheSizeLimit": null
},
"changePasswordUriSettings": {
"cacheEnabled": true,
"cacheHours": 24,
"cacheSizeLimit": null
} }
} }