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

[SM-90] Add Config Endpoint Phase 1 (#2130)

* Add config endpoint with version and gitHash in response

* Remove gitHash from version, formatting and other improvements

* change name of variable in ConfigController

* Update to properly get gitHash

* SM-94: Add global settings for api url

* SM-94: ConfigController cleanup

* SM-94: Make version and gitHash available for all projects, using AssemblyHelper

* Update ConfigResponseModel GetVersion() call

* Change AssemblyHelpers.cs to use the UTF-8 charset

* SM-94: Use AssemblyHelpers.GetVersion and deprecate CoreHelpers.GetVersion

* SM-90: Add other BaseServiceUriSettings urls

* SM-94: Fix dotnet format issue

* remove old GetVersion method

* Add back the linebreak

* Fix typo in Directory.Build.props

Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>

Co-authored-by: Oscar Hinton <Hinton@users.noreply.github.com>
This commit is contained in:
Colton Hurst
2022-09-05 11:19:04 -04:00
committed by GitHub
parent 9a12992b59
commit ed1406acc2
19 changed files with 150 additions and 26 deletions

View File

@ -32,5 +32,5 @@
<PackageReference Include="Azure.Messaging.EventGrid" Version="4.10.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.1" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,23 @@
using Bit.Api.Models.Response;
using Bit.Core.Settings;
using Microsoft.AspNetCore.Mvc;
namespace Bit.Api.Controllers;
[Route("config")]
public class ConfigController : Controller
{
private readonly IGlobalSettings _globalSettings;
public ConfigController(IGlobalSettings globalSettings)
{
_globalSettings = globalSettings;
}
[HttpGet("")]
public ConfigResponseModel GetConfigs()
{
return new ConfigResponseModel(_globalSettings);
}
}

View File

@ -15,7 +15,7 @@ public class InfoController : Controller
[HttpGet("~/version")]
public JsonResult GetVersion()
{
return Json(CoreHelpers.GetVersion());
return Json(AssemblyHelpers.GetVersion());
}
[HttpGet("~/ip")]

View File

@ -0,0 +1,51 @@
using Bit.Core.Models.Api;
using Bit.Core.Settings;
using Bit.Core.Utilities;
namespace Bit.Api.Models.Response;
public class ConfigResponseModel : ResponseModel
{
public string Version { get; set; }
public string GitHash { get; set; }
public ServerConfigResponseModel Server { get; set; }
public EnvironmentConfigResponseModel Environment { get; set; }
public ConfigResponseModel(string obj = "config") : base(obj)
{
Version = AssemblyHelpers.GetVersion();
GitHash = AssemblyHelpers.GetGitHash();
Environment = new EnvironmentConfigResponseModel();
}
public ConfigResponseModel(IGlobalSettings globalSettings, string obj = "config") : base(obj)
{
Version = AssemblyHelpers.GetVersion();
GitHash = AssemblyHelpers.GetGitHash();
Environment = new EnvironmentConfigResponseModel
{
Vault = globalSettings.BaseServiceUri.Vault,
Api = globalSettings.BaseServiceUri.Api,
Identity = globalSettings.BaseServiceUri.Identity,
Admin = globalSettings.BaseServiceUri.Admin,
Notifications = globalSettings.BaseServiceUri.Notifications,
Sso = globalSettings.BaseServiceUri.Sso
};
}
}
public class ServerConfigResponseModel
{
public string Name { get; set; }
public string Url { get; set; }
}
public class EnvironmentConfigResponseModel
{
public string Vault { get; set; }
public string Api { get; set; }
public string Identity { get; set; }
public string Admin { get; set; }
public string Notifications { get; set; }
public string Sso { get; set; }
}