Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiAuth #24

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
move AuthServer class to a better spot
DEATHB4DEFEAT committed Jan 30, 2025
commit dfe43e62f9849ce478226f89c7c927f3e3b81a37
92 changes: 46 additions & 46 deletions SS14.Launcher/ConfigConstants.cs
Original file line number Diff line number Diff line change
@@ -32,52 +32,6 @@ public static class ConfigConstants
// Amount of time to wait to let a redialling client properly die
public const int LauncherCommandsRedialWaitTimeout = 1000;

// Yes, this is stupidly large, just collapse it if you don't want to see it
public class AuthServer(
Uri authUrl,
Uri accountSite,
bool? recommended = null,
string authAuthPath = "api/auth/authenticate",
string authRegPath = "api/auth/register",
string authPwResetPath = "api/auth/resetPassword",
string authResendPath = "api/auth/resendConfirmation",
string authPingPath = "api/auth/ping",
string authRefreshPath = "api/auth/refresh",
string authLogoutPath = "api/auth/logout",
string authAccountSitePath = "api/accountSite",
string accountManPath = "Identity/Account/Manage",
string accountRegPath = "Identity/Account/Register",
string accountResendPath = "Identity/Account/ResendEmailConfirmation")
{
public bool? Recommended { get; } = recommended;

public Uri AuthUrl { get; } = authUrl;
public string AuthAuthPath { get; } = authAuthPath;
public string AuthRegPath { get; } = authRegPath;
public string AuthPwResetPath { get; } = authPwResetPath;
public string AuthResendPath { get; } = authResendPath;
public string AuthPingPath { get; } = authPingPath;
public string AuthRefreshPath { get; } = authRefreshPath;
public string AuthLogoutPath { get; } = authLogoutPath;
public string AuthAccountSitePath { get; } = authAccountSitePath;
public string AuthAuthUrl { get; } = $"{authUrl}{authAuthPath}";
public string AuthRegUrl { get; } = $"{authUrl}{authRegPath}";
public string AuthPwResetUrl { get; } = $"{authUrl}{authPwResetPath}";
public string AuthResendUrl { get; } = $"{authUrl}{authResendPath}";
public string AuthPingUrl { get; } = $"{authUrl}{authPingPath}";
public string AuthRefreshUrl { get; } = $"{authUrl}{authRefreshPath}";
public string AuthLogoutUrl { get; } = $"{authUrl}{authLogoutPath}";
public string AuthAccountSiteUrl { get; } = $"{authUrl}{authAccountSitePath}";

public Uri AccountSite { get; } = accountSite;
public string AccountManPath { get; } = accountManPath;
public string AccountRegPath { get; } = accountRegPath;
public string AccountResendPath { get; } = accountResendPath;
public string AccountManUrl { get; } = $"{accountSite}{accountManPath}";
public string AccountRegUrl { get; } = $"{accountSite}{accountRegPath}";
public string AccountResendUrl { get; } = $"{accountSite}{accountResendPath}";
}

public const string FallbackAuthServer = "Space-Wizards";
public const string CustomAuthServer = "Custom";
public static readonly AuthServer TemplateAuthServer = new(new("https://example.com/"), new("https://example.com/"));
@@ -159,4 +113,50 @@ public class AuthServer(
public static readonly UrlFallbackSet UrlAssetsBase = LauncherDataBaseUrl + "assets/";

public const string FallbackUsername = "JoeGenero";


public class AuthServer(
Uri authUrl,
Uri accountSite,
bool? recommended = null,
string authAuthPath = "api/auth/authenticate",
string authRegPath = "api/auth/register",
string authPwResetPath = "api/auth/resetPassword",
string authResendPath = "api/auth/resendConfirmation",
string authPingPath = "api/auth/ping",
string authRefreshPath = "api/auth/refresh",
string authLogoutPath = "api/auth/logout",
string authAccountSitePath = "api/accountSite",
string accountManPath = "Identity/Account/Manage",
string accountRegPath = "Identity/Account/Register",
string accountResendPath = "Identity/Account/ResendEmailConfirmation")
{
public bool? Recommended { get; } = recommended;

public Uri AuthUrl { get; } = authUrl;
public string AuthAuthPath { get; } = authAuthPath;
public string AuthRegPath { get; } = authRegPath;
public string AuthPwResetPath { get; } = authPwResetPath;
public string AuthResendPath { get; } = authResendPath;
public string AuthPingPath { get; } = authPingPath;
public string AuthRefreshPath { get; } = authRefreshPath;
public string AuthLogoutPath { get; } = authLogoutPath;
public string AuthAccountSitePath { get; } = authAccountSitePath;
public string AuthAuthUrl { get; } = $"{authUrl}{authAuthPath}";
public string AuthRegUrl { get; } = $"{authUrl}{authRegPath}";
public string AuthPwResetUrl { get; } = $"{authUrl}{authPwResetPath}";
public string AuthResendUrl { get; } = $"{authUrl}{authResendPath}";
public string AuthPingUrl { get; } = $"{authUrl}{authPingPath}";
public string AuthRefreshUrl { get; } = $"{authUrl}{authRefreshPath}";
public string AuthLogoutUrl { get; } = $"{authUrl}{authLogoutPath}";
public string AuthAccountSiteUrl { get; } = $"{authUrl}{authAccountSitePath}";

public Uri AccountSite { get; } = accountSite;
public string AccountManPath { get; } = accountManPath;
public string AccountRegPath { get; } = accountRegPath;
public string AccountResendPath { get; } = accountResendPath;
public string AccountManUrl { get; } = $"{accountSite}{accountManPath}";
public string AccountRegUrl { get; } = $"{accountSite}{accountRegPath}";
public string AccountResendUrl { get; } = $"{accountSite}{accountResendPath}";
}
}

Unchanged files with check annotations Beta

continue;
#endif
using var writer = new StreamWriter(File.OpenWrite(desktopFile));

Check warning on line 140 in SS14.Launcher/App.xaml.cs

GitHub Actions / build

Unreachable code detected

Check warning on line 140 in SS14.Launcher/App.xaml.cs

GitHub Actions / build

Unreachable code detected
writer.WriteLine("[Desktop Entry]");
writer.WriteLine("Type=Application");
writer.WriteLine($"Name=SS14 {protocol}");
{
// await Task.Delay(1000);
if (!ConfigConstants.DoVersionCheck)
return;

Check warning on line 175 in SS14.Launcher/ViewModels/MainWindowViewModel.cs

GitHub Actions / build

Unreachable code detected
await _infoManager.LoadTask;
if (_infoManager.Model == null)
datum.Data.Links = null;
datum.Data.Description = null;
UpdateStatusFor(datum);

Check warning on line 197 in SS14.Launcher/Models/ServerStatus/ServerStatusCache.cs

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
}
}
{ ViewedInFavoritesPane = true, IsExpanded = _cfg.ExpandedServers.Contains(x.Address) })
.OnItemAdded(a =>
{
if (IsSelected) _statusCache.InitialUpdateStatus(a.CacheData);

Check warning on line 40 in SS14.Launcher/ViewModels/MainWindowTabs/HomePageViewModel.cs

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
})
.Sort(Comparer<ServerEntryViewModel>.Create((a, b) =>
{
{
foreach (var favorite in Favorites)
{
_statusCache.InitialUpdateStatus(favorite.CacheData);

Check warning on line 117 in SS14.Launcher/ViewModels/MainWindowTabs/HomePageViewModel.cs

GitHub Actions / build

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
}
_serverListCache.RequestInitialUpdate();
}