1
0
mirror of https://github.com/bitwarden/server.git synced 2025-05-28 23:04:50 -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 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]

View File

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

View File

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

View File

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

View File

@ -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();

View File

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