diff --git a/docker/docker-compose.linux.yml b/docker/docker-compose.linux.yml index b85b6eff4c..9badb61b77 100644 --- a/docker/docker-compose.linux.yml +++ b/docker/docker-compose.linux.yml @@ -4,6 +4,9 @@ services: mssql: volumes: - /etc/bitwarden/mssql_data:/var/opt/mssql/data + env_file: + - mssql.env + - /etc/bitwarden/docker/mssql.override.env web: volumes: - /etc/bitwarden/web:/etc/bitwarden/web @@ -13,10 +16,16 @@ services: api: volumes: - /etc/bitwarden/core:/etc/bitwarden/core + env_file: + - global.env + - /etc/bitwarden/docker/global.override.env identity: volumes: - /etc/bitwarden/identity:/etc/bitwarden/identity - /etc/bitwarden/core:/etc/bitwarden/core + env_file: + - global.env + - /etc/bitwarden/docker/global.override.env nginx: volumes: - /etc/bitwarden/nginx:/etc/bitwarden/nginx diff --git a/docker/docker-compose.override.yml b/docker/docker-compose.override.yml deleted file mode 100644 index 6d2239f58c..0000000000 --- a/docker/docker-compose.override.yml +++ /dev/null @@ -1,26 +0,0 @@ -version: '3' - -services: - mssql: - volumes: - - mssql_data:/var/opt/mssql/data - web: - volumes: - - c:/bitwarden/web:/etc/bitwarden/web - attachments: - volumes: - - c:/bitwarden/core/attachments:/etc/bitwarden/core/attachments - api: - volumes: - - c:/bitwarden/core:/etc/bitwarden/core - identity: - volumes: - - c:/bitwarden/identity:/etc/bitwarden/identity - - c:/bitwarden/core:/etc/bitwarden/core - nginx: - volumes: - - c:/bitwarden/nginx:/etc/bitwarden/nginx - - c:/bitwarden/letsencrypt:/etc/letsencrypt - - c:/bitwarden/ssl:/etc/ssl -volumes: - mssql_data: diff --git a/docker/docker-compose.prod.yml b/docker/docker-compose.prod.yml deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/docker/docker-compose.windows.yml b/docker/docker-compose.windows.yml index 6d2239f58c..07ecf6676b 100644 --- a/docker/docker-compose.windows.yml +++ b/docker/docker-compose.windows.yml @@ -4,6 +4,9 @@ services: mssql: volumes: - mssql_data:/var/opt/mssql/data + env_file: + - mssql.env + - c:/bitwarden/docker/mssql.override.env web: volumes: - c:/bitwarden/web:/etc/bitwarden/web @@ -13,10 +16,16 @@ services: api: volumes: - c:/bitwarden/core:/etc/bitwarden/core + env_file: + - global.env + - c:/bitwarden/docker/global.override.env identity: volumes: - c:/bitwarden/identity:/etc/bitwarden/identity - c:/bitwarden/core:/etc/bitwarden/core + env_file: + - global.env + - c:/bitwarden/docker/global.override.env nginx: volumes: - c:/bitwarden/nginx:/etc/bitwarden/nginx diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index b309c27b6b..9507929726 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -7,7 +7,6 @@ services: restart: always env_file: - mssql.env - - mssql.override.env ports: - '1433:1433' @@ -27,14 +26,12 @@ services: restart: always env_file: - global.env - - global.override.env identity: image: bitwarden/identity container_name: identity env_file: - global.env - - global.override.env nginx: image: bitwarden/nginx diff --git a/scripts/setup.ps1 b/scripts/setup.ps1 index b84415dd34..1ce111e4d9 100644 --- a/scripts/setup.ps1 +++ b/scripts/setup.ps1 @@ -20,9 +20,9 @@ if($letsEncrypt -eq "y") { if(!(Test-Path -Path $letsEncryptPath )){ New-Item -ItemType directory -Path $letsEncryptPath } - docker run -it --rm -p 80:80 -v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot certonly --standalone --noninteractive --preferred-challenges http --email $email --agree-tos -d $domain + docker run -it --rm --name letsencrypt -p 80:80 -v $outputDir/letsencrypt:/etc/letsencrypt/ certbot/certbot certonly --standalone --noninteractive --preferred-challenges http --email $email --agree-tos -d $domain } -docker run -it --rm -v ${outputDir}:/bitwarden bitwarden/setup dotnet Setup.dll -domain ${domain} -letsencrypt ${letsEncrypt} -db_pass ${databasePassword} +docker run -it --rm --name setup -v ${outputDir}:/bitwarden bitwarden/setup dotnet Setup.dll -domain ${domain} -letsencrypt ${letsEncrypt} -db_pass ${databasePassword} echo "Setup complete" diff --git a/src/Api/Controllers/PushController.cs b/src/Api/Controllers/PushController.cs index 9ae0155e34..fc759fd4fc 100644 --- a/src/Api/Controllers/PushController.cs +++ b/src/Api/Controllers/PushController.cs @@ -35,7 +35,7 @@ namespace Bit.Api.Controllers } [HttpPost("register")] - public async Task PostRegister(PushRegistrationRequestModel model) + public async Task PostRegister([FromBody]PushRegistrationRequestModel model) { CheckUsage(); await _pushRegistrationService.CreateOrUpdateRegistrationAsync(model.PushToken, Prefix(model.DeviceId), @@ -50,7 +50,7 @@ namespace Bit.Api.Controllers } [HttpPut("add-organization")] - public async Task PutAddOrganization(PushUpdateRequestModel model) + public async Task PutAddOrganization([FromBody]PushUpdateRequestModel model) { CheckUsage(); await _pushRegistrationService.AddUserRegistrationOrganizationAsync( @@ -58,7 +58,7 @@ namespace Bit.Api.Controllers } [HttpPut("delete-organization")] - public async Task PutDeleteOrganization(PushUpdateRequestModel model) + public async Task PutDeleteOrganization([FromBody]PushUpdateRequestModel model) { CheckUsage(); await _pushRegistrationService.DeleteUserRegistrationOrganizationAsync( @@ -66,13 +66,13 @@ namespace Bit.Api.Controllers } [HttpPost("send")] - public async Task PostSend(PushSendRequestModel model) + public async Task PostSend([FromBody]PushSendRequestModel model) { CheckUsage(); if(!string.IsNullOrWhiteSpace(model.UserId)) { - await _pushNotificationService.SendPayloadToUserAsync(Prefix(model.OrganizationId), + await _pushNotificationService.SendPayloadToUserAsync(Prefix(model.UserId), model.Type.Value, model.Payload, Prefix(model.Identifier)); } else if(!string.IsNullOrWhiteSpace(model.OrganizationId)) diff --git a/src/Core/Services/Implementations/BaseRelayPushNotificationService.cs b/src/Core/Services/Implementations/BaseRelayPushNotificationService.cs index fe855d48e1..a604308fe0 100644 --- a/src/Core/Services/Implementations/BaseRelayPushNotificationService.cs +++ b/src/Core/Services/Implementations/BaseRelayPushNotificationService.cs @@ -7,6 +7,7 @@ using System; using Newtonsoft.Json.Linq; using Bit.Core.Utilities; using System.Net; +using System.Net.Http.Headers; namespace Bit.Core.Services { @@ -24,11 +25,13 @@ namespace Bit.Core.Services { BaseAddress = new Uri(globalSettings.PushRelayBaseUri) }; + PushClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); IdentityClient = new HttpClient { BaseAddress = new Uri(globalSettings.Installation.IdentityUri) }; + IdentityClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); } protected HttpClient PushClient { get; private set; } @@ -52,7 +55,7 @@ namespace Bit.Core.Services var requestMessage = new HttpRequestMessage { Method = HttpMethod.Post, - RequestUri = new Uri(IdentityClient.BaseAddress, "connect/token"), + RequestUri = new Uri(string.Concat(IdentityClient.BaseAddress, "/connect/token")), Content = new FormUrlEncodedContent(new Dictionary { { "grant_type", "client_credentials" }, diff --git a/src/Core/Services/Implementations/RelayPushNotificationService.cs b/src/Core/Services/Implementations/RelayPushNotificationService.cs index f9313fbeb2..0a4c94bda4 100644 --- a/src/Core/Services/Implementations/RelayPushNotificationService.cs +++ b/src/Core/Services/Implementations/RelayPushNotificationService.cs @@ -165,7 +165,7 @@ namespace Bit.Core.Services var message = new TokenHttpRequestMessage(requestModel, AccessToken) { Method = HttpMethod.Post, - RequestUri = new Uri(PushClient.BaseAddress, "send") + RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/send")) }; await PushClient.SendAsync(message); } diff --git a/src/Core/Services/Implementations/RelayPushRegistrationService.cs b/src/Core/Services/Implementations/RelayPushRegistrationService.cs index 8036410ba0..2ef33ec9f7 100644 --- a/src/Core/Services/Implementations/RelayPushRegistrationService.cs +++ b/src/Core/Services/Implementations/RelayPushRegistrationService.cs @@ -38,7 +38,7 @@ namespace Bit.Core.Services var message = new TokenHttpRequestMessage(requestModel, AccessToken) { Method = HttpMethod.Post, - RequestUri = new Uri(PushClient.BaseAddress, "register") + RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/register")) }; await PushClient.SendAsync(message); } @@ -54,7 +54,7 @@ namespace Bit.Core.Services var message = new TokenHttpRequestMessage(AccessToken) { Method = HttpMethod.Delete, - RequestUri = new Uri(PushClient.BaseAddress, deviceId) + RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/", deviceId)) }; await PushClient.SendAsync(message); } @@ -76,7 +76,7 @@ namespace Bit.Core.Services var message = new TokenHttpRequestMessage(requestModel, AccessToken) { Method = HttpMethod.Put, - RequestUri = new Uri(PushClient.BaseAddress, "add-organization") + RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/add-organization")) }; await PushClient.SendAsync(message); } @@ -98,7 +98,7 @@ namespace Bit.Core.Services var message = new TokenHttpRequestMessage(requestModel, AccessToken) { Method = HttpMethod.Put, - RequestUri = new Uri(PushClient.BaseAddress, "delete-organization") + RequestUri = new Uri(string.Concat(PushClient.BaseAddress, "/push/delete-organization")) }; await PushClient.SendAsync(message); } diff --git a/util/Setup/Program.cs b/util/Setup/Program.cs index 2e358e6746..88448ebb56 100644 --- a/util/Setup/Program.cs +++ b/util/Setup/Program.cs @@ -54,9 +54,9 @@ namespace Setup _url = _ssl ? $"https://{_domain}" : $"http://{_domain}"; BuildNginxConfig(); - Console.Write("Installation ID: "); + Console.Write("Installation id (get it at https://bitwarden.com/host/): "); _installationId = Console.ReadLine().ToLowerInvariant(); - Console.Write("Installation key: "); + Console.Write("Installation key (get it at https://bitwarden.com/host/): "); _installationKey = Console.ReadLine().ToLowerInvariant(); Console.Write("Do you want to use push notifications? (y/n): "); _push = Console.ReadLine().ToLowerInvariant() == "y"; @@ -272,7 +272,7 @@ globalSettings:attachment:baseUrl={_url}/attachments globalSettings:dataProtection:directory={_outputDir}/core/aspnet-dataprotection globalSettings:logDirectory={_outputDir}/core/logs globalSettings:licenseDirectory={_outputDir}/core/licenses -globalSettings:duo:aKey={Helpers.SecureRandomString(32, alpha: true, numeric: true)} +globalSettings:duo:aKey={Helpers.SecureRandomString(64, alpha: true, numeric: true)} globalSettings:installation:id={_installationId} globalSettings:installation:key={_installationKey} globalSettings:yubico:clientId=REPLACE @@ -280,7 +280,8 @@ globalSettings:yubico:key=REPLACE"); if(!_push) { - sw.Write("globalSettings:pushRelayBaseUri=REPLACE"); + sw.Write(@" +globalSettings:pushRelayBaseUri=REPLACE"); } }