1
0
mirror of https://github.com/bitwarden/server.git synced 2024-12-31 18:27:49 +01:00

add support for azuresignalr services

This commit is contained in:
Kyle Spearrin 2018-08-22 16:04:27 -04:00
parent 6a2e64f2a0
commit d992125b5f
3 changed files with 22 additions and 5 deletions

View File

@ -19,7 +19,7 @@ namespace Bit.Core
public virtual MailSettings Mail { get; set; } = new MailSettings();
public virtual StorageSettings Storage { get; set; } = new StorageSettings();
public virtual StorageSettings Events { get; set; } = new StorageSettings();
public virtual StorageSettings Notifications { get; set; } = new StorageSettings();
public virtual NotificationsSettings Notifications { get; set; } = new NotificationsSettings();
public virtual AttachmentSettings Attachment { get; set; } = new AttachmentSettings();
public virtual IdentityServerSettings IdentityServer { get; set; } = new IdentityServerSettings();
public virtual DataProtectionSettings DataProtection { get; set; } = new DataProtectionSettings();
@ -129,6 +129,11 @@ namespace Bit.Core
public string Dsn { get; set; }
}
public class NotificationsSettings : StorageSettings
{
public string AzureSignalRConnectionString { get; set; }
}
public class NotificationHubSettings
{
private string _connectionString;

View File

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv" Version="2.1.2" />
<PackageReference Include="Microsoft.Azure.SignalR" Version="1.0.0-preview1-10015" />
</ItemGroup>
<ItemGroup>

View File

@ -54,7 +54,14 @@ namespace Bit.Notifications
});
// SignalR
services.AddSignalR();
if(!string.IsNullOrWhiteSpace(globalSettings.Notifications?.AzureSignalRConnectionString))
{
services.AddSignalR().AddAzureSignalR(globalSettings.Notifications.AzureSignalRConnectionString);
}
else
{
services.AddSignalR();
}
services.AddSingleton<IUserIdProvider, SubjectUserIdProvider>();
// Mvc
@ -103,10 +110,14 @@ namespace Bit.Notifications
app.UseAuthentication();
// Add SignlarR
app.UseSignalR(routes =>
if(!string.IsNullOrWhiteSpace(globalSettings.Notifications?.AzureSignalRConnectionString))
{
routes.MapHub<NotificationsHub>("/hub");
});
app.UseAzureSignalR(routes => routes.MapHub<NotificationsHub>("/hub"));
}
else
{
app.UseSignalR(routes => routes.MapHub<NotificationsHub>("/hub"));
}
// Add MVC to the request pipeline.
app.UseMvc();