diff --git a/MareSynchronosServer/MareSynchronosAuthService/Controllers/AuthControllerBase.cs b/MareSynchronosServer/MareSynchronosAuthService/Controllers/AuthControllerBase.cs index cbb1f30..5b4e4ad 100644 --- a/MareSynchronosServer/MareSynchronosAuthService/Controllers/AuthControllerBase.cs +++ b/MareSynchronosServer/MareSynchronosAuthService/Controllers/AuthControllerBase.cs @@ -8,7 +8,7 @@ using MareSynchronosShared.Utils.Configuration; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.IdentityModel.Tokens; -using StackExchange.Redis.Extensions.Core.Abstractions; +using StackExchange.Redis; using System.Globalization; using System.IdentityModel.Tokens.Jwt; using System.Security.Claims; @@ -23,14 +23,14 @@ public abstract class AuthControllerBase : Controller protected readonly IConfigurationService Configuration; protected readonly IDbContextFactory MareDbContextFactory; protected readonly SecretKeyAuthenticatorService SecretKeyAuthenticatorService; - private readonly IRedisDatabase _redis; + private readonly IDatabase _redis; private readonly GeoIPService _geoIPProvider; protected AuthControllerBase(ILogger logger, IHttpContextAccessor accessor, IDbContextFactory mareDbContextFactory, SecretKeyAuthenticatorService secretKeyAuthenticatorService, IConfigurationService configuration, - IRedisDatabase redisDb, GeoIPService geoIPProvider) + IDatabase redisDb, GeoIPService geoIPProvider) { Logger = logger; HttpAccessor = accessor; @@ -72,7 +72,7 @@ public abstract class AuthControllerBase : Controller return Unauthorized("Your Mare account is banned from using the service."); } - var existingIdent = await _redis.GetAsync("UID:" + authResult.Uid); + var existingIdent = await _redis.StringGetAsync("UID:" + authResult.Uid); if (!string.IsNullOrEmpty(existingIdent)) { Logger.LogWarning("Authenticate:DUPLICATE:{id}:{ident}", authResult.Uid, charaIdent); diff --git a/MareSynchronosServer/MareSynchronosAuthService/Controllers/JwtController.cs b/MareSynchronosServer/MareSynchronosAuthService/Controllers/JwtController.cs index 5c4ec8d..447635e 100644 --- a/MareSynchronosServer/MareSynchronosAuthService/Controllers/JwtController.cs +++ b/MareSynchronosServer/MareSynchronosAuthService/Controllers/JwtController.cs @@ -8,7 +8,7 @@ using MareSynchronosShared.Utils.Configuration; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; -using StackExchange.Redis.Extensions.Core.Abstractions; +using StackExchange.Redis; namespace MareSynchronosAuthService.Controllers; @@ -19,7 +19,7 @@ public class JwtController : AuthControllerBase IHttpContextAccessor accessor, IDbContextFactory mareDbContextFactory, SecretKeyAuthenticatorService secretKeyAuthenticatorService, IConfigurationService configuration, - IRedisDatabase redisDb, GeoIPService geoIPProvider) + IDatabase redisDb, GeoIPService geoIPProvider) : base(logger, accessor, mareDbContextFactory, secretKeyAuthenticatorService, configuration, redisDb, geoIPProvider) { diff --git a/MareSynchronosServer/MareSynchronosAuthService/Controllers/OAuthController.cs b/MareSynchronosServer/MareSynchronosAuthService/Controllers/OAuthController.cs index 335d558..1ca4912 100644 --- a/MareSynchronosServer/MareSynchronosAuthService/Controllers/OAuthController.cs +++ b/MareSynchronosServer/MareSynchronosAuthService/Controllers/OAuthController.cs @@ -9,7 +9,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using StackExchange.Redis; -using StackExchange.Redis.Extensions.Core.Abstractions; using System.Collections.Concurrent; using System.Globalization; using System.IdentityModel.Tokens.Jwt; @@ -30,7 +29,7 @@ public class OAuthController : AuthControllerBase IHttpContextAccessor accessor, IDbContextFactory mareDbContext, SecretKeyAuthenticatorService secretKeyAuthenticatorService, IConfigurationService configuration, - IRedisDatabase redisDb, GeoIPService geoIPProvider) + IDatabase redisDb, GeoIPService geoIPProvider) : base(logger, accessor, mareDbContext, secretKeyAuthenticatorService, configuration, redisDb, geoIPProvider) { diff --git a/MareSynchronosServer/MareSynchronosAuthService/Startup.cs b/MareSynchronosServer/MareSynchronosAuthService/Startup.cs index 51a7a29..7abc210 100644 --- a/MareSynchronosServer/MareSynchronosAuthService/Startup.cs +++ b/MareSynchronosServer/MareSynchronosAuthService/Startup.cs @@ -17,6 +17,7 @@ using MareSynchronosShared.Data; using Microsoft.EntityFrameworkCore; using Prometheus; using MareSynchronosShared.Utils.Configuration; +using StackExchange.Redis.Extensions.Core.Abstractions; namespace MareSynchronosAuthService; @@ -179,8 +180,10 @@ public class Startup var endpoint = options.EndPoints[0]; string address = ""; int port = 0; + if (endpoint is DnsEndPoint dnsEndPoint) { address = dnsEndPoint.Host; port = dnsEndPoint.Port; } if (endpoint is IPEndPoint ipEndPoint) { address = ipEndPoint.Address.ToString(); port = ipEndPoint.Port; } + /* var redisConfiguration = new RedisConfiguration() { AbortOnConnectFail = true, @@ -203,11 +206,13 @@ public class Startup MaxValueLength = 1024, PoolSize = mareConfig.GetValue(nameof(ServerConfiguration.RedisPool), 50), SyncTimeout = options.SyncTimeout, - }; + };*/ + + var muxer = ConnectionMultiplexer.Connect(options); + var db = muxer.GetDatabase(); + services.AddSingleton(db); _logger.LogInformation("Setting up Redis to connect to {host}:{port}", address, port); - - services.AddStackExchangeRedisExtensions(redisConfiguration); } private void ConfigureConfigServices(IServiceCollection services) {