mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 15:42:48 -05:00
env files for compose. fixes to push relays
This commit is contained in:
@ -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))
|
||||
|
@ -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<string, string>
|
||||
{
|
||||
{ "grant_type", "client_credentials" },
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user