mirror of
https://github.com/bitwarden/server.git
synced 2025-04-16 10:38:17 -05:00

* 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>
35 lines
858 B
C#
35 lines
858 B
C#
using Bit.Core.Utilities;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Bit.Api.Controllers;
|
|
|
|
public class InfoController : Controller
|
|
{
|
|
[HttpGet("~/alive")]
|
|
[HttpGet("~/now")]
|
|
public DateTime GetAlive()
|
|
{
|
|
return DateTime.UtcNow;
|
|
}
|
|
|
|
[HttpGet("~/version")]
|
|
public JsonResult GetVersion()
|
|
{
|
|
return Json(AssemblyHelpers.GetVersion());
|
|
}
|
|
|
|
[HttpGet("~/ip")]
|
|
public JsonResult Ip()
|
|
{
|
|
var headerSet = new HashSet<string> { "x-forwarded-for", "cf-connecting-ip", "client-ip" };
|
|
var headers = HttpContext.Request?.Headers
|
|
.Where(h => headerSet.Contains(h.Key.ToLower()))
|
|
.ToDictionary(h => h.Key);
|
|
return new JsonResult(new
|
|
{
|
|
Ip = HttpContext.Connection?.RemoteIpAddress?.ToString(),
|
|
Headers = headers,
|
|
});
|
|
}
|
|
}
|