mirror of
https://github.com/bitwarden/server.git
synced 2025-04-25 23:02:17 -05:00
Add InstallationUrl to support local development
- Support .pw domains
This commit is contained in:
parent
4379e326a5
commit
ce6270337c
@ -185,6 +185,7 @@ public class Context
|
|||||||
{
|
{
|
||||||
public Guid InstallationId { get; set; }
|
public Guid InstallationId { get; set; }
|
||||||
public string InstallationKey { get; set; }
|
public string InstallationKey { get; set; }
|
||||||
|
public string InstallationUrl { get; set; }
|
||||||
public CloudRegion CloudRegion { get; set; }
|
public CloudRegion CloudRegion { get; set; }
|
||||||
public bool DiffieHellman { get; set; }
|
public bool DiffieHellman { get; set; }
|
||||||
public bool Trusted { get; set; }
|
public bool Trusted { get; set; }
|
||||||
|
@ -8,4 +8,6 @@ public enum CloudRegion
|
|||||||
US = 0,
|
US = 0,
|
||||||
[Display(Name = "EU")]
|
[Display(Name = "EU")]
|
||||||
EU = 1,
|
EU = 1,
|
||||||
|
[Display(Name = "DEV")]
|
||||||
|
DEV = 2,
|
||||||
}
|
}
|
||||||
|
@ -205,6 +205,7 @@ public class Program
|
|||||||
{
|
{
|
||||||
var installationId = string.Empty;
|
var installationId = string.Empty;
|
||||||
var installationKey = string.Empty;
|
var installationKey = string.Empty;
|
||||||
|
var InstallationUrl = string.Empty;
|
||||||
CloudRegion cloudRegion;
|
CloudRegion cloudRegion;
|
||||||
|
|
||||||
if (_context.Parameters.ContainsKey("install-id"))
|
if (_context.Parameters.ContainsKey("install-id"))
|
||||||
@ -243,6 +244,11 @@ public class Program
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Environment.GetEnvironmentVariable("BW_INSTALLATION_URL") != null)
|
||||||
|
{
|
||||||
|
InstallationUrl = Environment.GetEnvironmentVariable("BW_INSTALLATION_URL");
|
||||||
|
}
|
||||||
|
|
||||||
if (_context.Parameters.ContainsKey("cloud-region"))
|
if (_context.Parameters.ContainsKey("cloud-region"))
|
||||||
{
|
{
|
||||||
Enum.TryParse(_context.Parameters["cloud-region"], out cloudRegion);
|
Enum.TryParse(_context.Parameters["cloud-region"], out cloudRegion);
|
||||||
@ -263,22 +269,35 @@ public class Program
|
|||||||
|
|
||||||
_context.Install.InstallationId = installationidGuid;
|
_context.Install.InstallationId = installationidGuid;
|
||||||
_context.Install.InstallationKey = installationKey;
|
_context.Install.InstallationKey = installationKey;
|
||||||
|
_context.Install.InstallationUrl = InstallationUrl;
|
||||||
_context.Install.CloudRegion = cloudRegion;
|
_context.Install.CloudRegion = cloudRegion;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string url;
|
string regionBaseUrl;
|
||||||
switch (cloudRegion)
|
switch (cloudRegion)
|
||||||
{
|
{
|
||||||
case CloudRegion.EU:
|
case CloudRegion.EU:
|
||||||
url = "https://api.bitwarden.eu/installations/";
|
regionBaseUrl = "bitwarden.eu";
|
||||||
break;
|
break;
|
||||||
case CloudRegion.US:
|
case CloudRegion.US:
|
||||||
default:
|
default:
|
||||||
url = "https://api.bitwarden.com/installations/";
|
regionBaseUrl = "bitwarden.com";
|
||||||
|
break;
|
||||||
|
case CloudRegion.DEV:
|
||||||
|
regionBaseUrl = "bitwarden.pw";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
var response = new HttpClient().GetAsync(url + _context.Install.InstallationId).GetAwaiter().GetResult();
|
|
||||||
|
HttpResponseMessage response;
|
||||||
|
if (_context.Install.InstallationUrl != null)
|
||||||
|
{
|
||||||
|
response = new HttpClient().GetAsync($"https://api.{_context.Install.InstallationUrl}.{regionBaseUrl}/installations/{_context.Install.InstallationId}").GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
response = new HttpClient().GetAsync($"https://api.{regionBaseUrl}/installations/{_context.Install.InstallationId}").GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user