forked from Eauldane/SnowcloakClient
replay changes for cleaning up remote configuration and no snap services
This commit is contained in:
@@ -19,7 +19,6 @@ public class HubFactory : MediatorSubscriberBase
|
||||
{
|
||||
private readonly ILoggerProvider _loggingProvider;
|
||||
private readonly ServerConfigurationManager _serverConfigurationManager;
|
||||
private readonly RemoteConfigurationService _remoteConfig;
|
||||
private readonly TokenProvider _tokenProvider;
|
||||
private HubConnection? _instance;
|
||||
private string _cachedConfigFor = string.Empty;
|
||||
@@ -27,11 +26,10 @@ public class HubFactory : MediatorSubscriberBase
|
||||
private bool _isDisposed = false;
|
||||
|
||||
public HubFactory(ILogger<HubFactory> logger, MareMediator mediator,
|
||||
ServerConfigurationManager serverConfigurationManager, RemoteConfigurationService remoteConfig,
|
||||
ServerConfigurationManager serverConfigurationManager,
|
||||
TokenProvider tokenProvider, ILoggerProvider pluginLog) : base(logger, mediator)
|
||||
{
|
||||
_serverConfigurationManager = serverConfigurationManager;
|
||||
_remoteConfig = remoteConfig;
|
||||
_tokenProvider = tokenProvider;
|
||||
_loggingProvider = pluginLog;
|
||||
}
|
||||
@@ -87,16 +85,6 @@ public class HubFactory : MediatorSubscriberBase
|
||||
};
|
||||
}
|
||||
|
||||
if (_serverConfigurationManager.CurrentApiUrl.Equals(ApiController.SnowcloakServiceUri, StringComparison.Ordinal))
|
||||
{
|
||||
var mainServerConfig = await _remoteConfig.GetConfigAsync<HubConnectionConfig>("mainServer").ConfigureAwait(false) ?? new();
|
||||
defaultConfig = mainServerConfig;
|
||||
if (string.IsNullOrEmpty(mainServerConfig.ApiUrl))
|
||||
defaultConfig.ApiUrl = ApiController.SnowcloakServiceApiUri;
|
||||
if (string.IsNullOrEmpty(mainServerConfig.HubUrl))
|
||||
defaultConfig.HubUrl = ApiController.SnowcloakServiceHubUri;
|
||||
}
|
||||
|
||||
string jsonResponse;
|
||||
|
||||
if (stapledWellKnown != null)
|
||||
|
@@ -20,16 +20,14 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly ILogger<TokenProvider> _logger;
|
||||
private readonly ServerConfigurationManager _serverManager;
|
||||
private readonly RemoteConfigurationService _remoteConfig;
|
||||
private readonly ConcurrentDictionary<JwtIdentifier, string> _tokenCache = new();
|
||||
private readonly ConcurrentDictionary<string, string?> _wellKnownCache = new(StringComparer.Ordinal);
|
||||
|
||||
public TokenProvider(ILogger<TokenProvider> logger, ServerConfigurationManager serverManager, RemoteConfigurationService remoteConfig,
|
||||
public TokenProvider(ILogger<TokenProvider> logger, ServerConfigurationManager serverManager,
|
||||
DalamudUtilService dalamudUtil, MareMediator mareMediator)
|
||||
{
|
||||
_logger = logger;
|
||||
_serverManager = serverManager;
|
||||
_remoteConfig = remoteConfig;
|
||||
_dalamudUtil = dalamudUtil;
|
||||
_httpClient = new(
|
||||
new HttpClientHandler
|
||||
@@ -70,23 +68,11 @@ public sealed class TokenProvider : IDisposable, IMediatorSubscriber
|
||||
Uri tokenUri;
|
||||
HttpResponseMessage result;
|
||||
|
||||
var authApiUrl = _serverManager.CurrentApiUrl;
|
||||
|
||||
// Override the API URL used for auth from remote config, if one is available
|
||||
if (authApiUrl.Equals(ApiController.SnowcloakServiceUri, StringComparison.Ordinal))
|
||||
{
|
||||
var config = await _remoteConfig.GetConfigAsync<HubConnectionConfig>("mainServer").ConfigureAwait(false) ?? new();
|
||||
if (!string.IsNullOrEmpty(config.ApiUrl))
|
||||
authApiUrl = config.ApiUrl;
|
||||
else
|
||||
authApiUrl = ApiController.SnowcloakServiceApiUri;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_logger.LogDebug("GetNewToken: Requesting");
|
||||
|
||||
tokenUri = MareAuth.AuthV2FullPath(new Uri(authApiUrl
|
||||
tokenUri = MareAuth.AuthV2FullPath(new Uri(_serverManager.CurrentApiUrl
|
||||
.Replace("wss://", "https://", StringComparison.OrdinalIgnoreCase)
|
||||
.Replace("ws://", "http://", StringComparison.OrdinalIgnoreCase)));
|
||||
var secretKey = _serverManager.GetSecretKey(out _)!;
|
||||
|
Reference in New Issue
Block a user