mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
push notification relay service and relay send api
This commit is contained in:
@ -289,5 +289,41 @@ namespace Bit.Core.Utilities
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string Base64UrlEncode(byte[] input)
|
||||
{
|
||||
var output = Convert.ToBase64String(input)
|
||||
.Replace('+', '-')
|
||||
.Replace('/', '_')
|
||||
.Replace("=", string.Empty);
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] Base64UrlDecode(string input)
|
||||
{
|
||||
var output = input;
|
||||
// 62nd char of encoding
|
||||
output = output.Replace('-', '+');
|
||||
// 63rd char of encoding
|
||||
output = output.Replace('_', '/');
|
||||
// Pad with trailing '='s
|
||||
switch(output.Length % 4)
|
||||
{
|
||||
case 0:
|
||||
// No pad chars in this case
|
||||
break;
|
||||
case 2:
|
||||
// Two pad chars
|
||||
output += "=="; break;
|
||||
case 3:
|
||||
// One pad char
|
||||
output += "="; break;
|
||||
default:
|
||||
throw new InvalidOperationException("Illegal base64url string!");
|
||||
}
|
||||
|
||||
// Standard base64 decoder
|
||||
return Convert.FromBase64String(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,21 +71,26 @@ namespace Bit.Core.Utilities
|
||||
services.AddSingleton<IMailDeliveryService, NoopMailDeliveryService>();
|
||||
}
|
||||
|
||||
#if NET461
|
||||
if(globalSettings.SelfHosted)
|
||||
if(globalSettings.SelfHosted &&
|
||||
CoreHelpers.SettingHasValue(globalSettings.PushRelayBaseUri) &&
|
||||
globalSettings.Installation?.Id != null &&
|
||||
CoreHelpers.SettingHasValue(globalSettings.Installation?.Key))
|
||||
{
|
||||
services.AddSingleton<IPushNotificationService, NoopPushNotificationService>();
|
||||
services.AddSingleton<IPushRegistrationService, NoopPushRegistrationService>();
|
||||
services.AddSingleton<IPushNotificationService, RelayPushNotificationService>();
|
||||
services.AddSingleton<IPushRegistrationService, RelayPushRegistrationService>();
|
||||
}
|
||||
else
|
||||
#if NET461
|
||||
else if(!globalSettings.SelfHosted)
|
||||
{
|
||||
services.AddSingleton<IPushNotificationService, NotificationHubPushNotificationService>();
|
||||
services.AddSingleton<IPushRegistrationService, NotificationHubPushRegistrationService>();
|
||||
}
|
||||
#else
|
||||
services.AddSingleton<IPushNotificationService, NoopPushNotificationService>();
|
||||
services.AddSingleton<IPushRegistrationService, NoopPushRegistrationService>();
|
||||
#endif
|
||||
else
|
||||
{
|
||||
services.AddSingleton<IPushNotificationService, NoopPushNotificationService>();
|
||||
services.AddSingleton<IPushRegistrationService, NoopPushRegistrationService>();
|
||||
}
|
||||
|
||||
if(CoreHelpers.SettingHasValue(globalSettings.Storage.ConnectionString))
|
||||
{
|
||||
|
Reference in New Issue
Block a user