|
|
@@ -1,18 +1,18 @@
|
|
|
-using SharedKernel;
|
|
|
-using SharedKernel.Storage;
|
|
|
using Application.Abstractions.Authentication;
|
|
|
+using Application.Abstractions.Cache;
|
|
|
+using Application.Abstractions.Chat;
|
|
|
+using Application.Abstractions.Crypto;
|
|
|
using Application.Abstractions.Data;
|
|
|
using Application.Abstractions.Identity;
|
|
|
using Application.Abstractions.Messaging.Email;
|
|
|
-using Application.Abstractions.Cache;
|
|
|
-using Application.Abstractions.Crypto;
|
|
|
using Infrastructure.Authentication;
|
|
|
+using Infrastructure.Cache;
|
|
|
+using Infrastructure.Chat;
|
|
|
+using Infrastructure.Crypto;
|
|
|
using Infrastructure.Messaging.Email;
|
|
|
using Infrastructure.Persistence;
|
|
|
using Infrastructure.Persistence.Identity;
|
|
|
using Infrastructure.Storage;
|
|
|
-using Infrastructure.Cache;
|
|
|
-using Infrastructure.Crypto;
|
|
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
|
using Microsoft.AspNetCore.DataProtection;
|
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
@@ -21,8 +21,10 @@ using Microsoft.EntityFrameworkCore;
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using Microsoft.IdentityModel.Tokens;
|
|
|
-using System.Text;
|
|
|
+using SharedKernel;
|
|
|
+using SharedKernel.Storage;
|
|
|
using StackExchange.Redis;
|
|
|
+using System.Text;
|
|
|
|
|
|
namespace Infrastructure
|
|
|
{
|
|
|
@@ -93,6 +95,7 @@ namespace Infrastructure
|
|
|
client.DefaultRequestHeaders.Add("Accept", "application/json");
|
|
|
client.Timeout = TimeSpan.FromSeconds(10);
|
|
|
});
|
|
|
+ services.AddSingleton<IChatMessageStore, RedisChatMessageStore>();
|
|
|
|
|
|
return services;
|
|
|
}
|
|
|
@@ -151,6 +154,22 @@ namespace Infrastructure
|
|
|
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(settings.JWT.SecretKey)),
|
|
|
ClockSkew = TimeSpan.Zero
|
|
|
};
|
|
|
+
|
|
|
+ options.Events = new JwtBearerEvents
|
|
|
+ {
|
|
|
+ OnMessageReceived = context =>
|
|
|
+ {
|
|
|
+ var accessToken = context.Request.Query["access_token"];
|
|
|
+ var path = context.HttpContext.Request.Path;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(accessToken) && path.StartsWithSegments("/hubs"))
|
|
|
+ {
|
|
|
+ context.Token = accessToken;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Task.CompletedTask;
|
|
|
+ }
|
|
|
+ };
|
|
|
});
|
|
|
|
|
|
services.AddAuthorization();
|