mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 16:12:49 -05:00
All feature state access through config API (#2785)
This commit is contained in:
@ -1,4 +1,6 @@
|
||||
using Bit.Api.Models.Response;
|
||||
using Bit.Core.Context;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core.Settings;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@ -9,15 +11,22 @@ namespace Bit.Api.Controllers;
|
||||
public class ConfigController : Controller
|
||||
{
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly ICurrentContext _currentContext;
|
||||
private readonly IFeatureService _featureService;
|
||||
|
||||
public ConfigController(IGlobalSettings globalSettings)
|
||||
public ConfigController(
|
||||
IGlobalSettings globalSettings,
|
||||
ICurrentContext currentContext,
|
||||
IFeatureService featureService)
|
||||
{
|
||||
_globalSettings = globalSettings;
|
||||
_currentContext = currentContext;
|
||||
_featureService = featureService;
|
||||
}
|
||||
|
||||
[HttpGet("")]
|
||||
public ConfigResponseModel GetConfigs()
|
||||
{
|
||||
return new ConfigResponseModel(_globalSettings);
|
||||
return new ConfigResponseModel(_globalSettings, _featureService.GetAll(_currentContext));
|
||||
}
|
||||
}
|
||||
|
@ -10,15 +10,19 @@ public class ConfigResponseModel : ResponseModel
|
||||
public string GitHash { get; set; }
|
||||
public ServerConfigResponseModel Server { get; set; }
|
||||
public EnvironmentConfigResponseModel Environment { get; set; }
|
||||
public IDictionary<string, object> FeatureStates { get; set; }
|
||||
|
||||
public ConfigResponseModel(string obj = "config") : base(obj)
|
||||
public ConfigResponseModel() : base("config")
|
||||
{
|
||||
Version = AssemblyHelpers.GetVersion();
|
||||
GitHash = AssemblyHelpers.GetGitHash();
|
||||
Environment = new EnvironmentConfigResponseModel();
|
||||
FeatureStates = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
public ConfigResponseModel(IGlobalSettings globalSettings, string obj = "config") : base(obj)
|
||||
public ConfigResponseModel(
|
||||
IGlobalSettings globalSettings,
|
||||
IDictionary<string, object> featureStates) : base("config")
|
||||
{
|
||||
Version = AssemblyHelpers.GetVersion();
|
||||
GitHash = AssemblyHelpers.GetGitHash();
|
||||
@ -30,6 +34,7 @@ public class ConfigResponseModel : ResponseModel
|
||||
Notifications = globalSettings.BaseServiceUri.Notifications,
|
||||
Sso = globalSettings.BaseServiceUri.Sso
|
||||
};
|
||||
FeatureStates = featureStates;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user