Skip to content
This repository was archived by the owner on Jun 28, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 25 additions & 8 deletions SS14.Launcher/Api/AuthApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,29 @@ namespace SS14.Launcher.Api;

public sealed class AuthApi
{
private readonly DataManager _cfg;
private readonly HttpClient _httpClient;

public AuthApi(HttpClient http)
public AuthApi(DataManager cfg,
HttpClient http)
{
_cfg = cfg;
_httpClient = http;
}

private UrlFallbackSet GetAuthUrl()
{
// TODO: testing purposes, do this better later
var authUrl = _cfg.GetCVar(CVars.CustomAuthUrl);
return new UrlFallbackSet([authUrl, authUrl]);
}

public async Task<AuthenticateResult> AuthenticateAsync(AuthenticateRequest request)
{
try
{
var authUrl = ConfigConstants.AuthUrl + "api/auth/authenticate";
var baseAuthUrl = GetAuthUrl();
var authUrl = baseAuthUrl + "api/auth/authenticate";

using var resp = await _httpClient.PostAsJsonAsync(authUrl, request);

Expand Down Expand Up @@ -80,7 +91,8 @@ public async Task<RegisterResult> RegisterAsync(string username, string email, s
{
var request = new RegisterRequest(username, email, password);

var authUrl = ConfigConstants.AuthUrl + "api/auth/register";
var baseAuthUrl = GetAuthUrl();
var authUrl = baseAuthUrl + "api/auth/register";

using var resp = await _httpClient.PostAsJsonAsync(authUrl, request);

Expand Down Expand Up @@ -122,7 +134,8 @@ public async Task<RegisterResult> RegisterAsync(string username, string email, s
{
var request = new ResetPasswordRequest(email);

var authUrl = ConfigConstants.AuthUrl + "api/auth/resetPassword";
var baseAuthUrl = GetAuthUrl();
var authUrl = baseAuthUrl + "api/auth/resetPassword";

using var resp = await _httpClient.PostAsJsonAsync(authUrl, request);

Expand All @@ -149,7 +162,8 @@ public async Task<RegisterResult> RegisterAsync(string username, string email, s
{
var request = new ResendConfirmationRequest(email);

var authUrl = ConfigConstants.AuthUrl + "api/auth/resendConfirmation";
var baseAuthUrl = GetAuthUrl();
var authUrl = baseAuthUrl + "api/auth/resendConfirmation";

using var resp = await _httpClient.PostAsJsonAsync(authUrl, request);

Expand Down Expand Up @@ -181,7 +195,8 @@ public async Task<RegisterResult> RegisterAsync(string username, string email, s
{
var request = new RefreshRequest(token);

var authUrl = ConfigConstants.AuthUrl + "api/auth/refresh";
var baseAuthUrl = GetAuthUrl();
var authUrl = baseAuthUrl + "api/auth/refresh";

using var resp = await _httpClient.PostAsJsonAsync(authUrl, request);

Expand Down Expand Up @@ -224,7 +239,8 @@ public async Task LogoutTokenAsync(string token)
{
var request = new LogoutRequest(token);

var authUrl = ConfigConstants.AuthUrl + "api/auth/logout";
var baseAuthUrl = GetAuthUrl();
var authUrl = baseAuthUrl + "api/auth/logout";

using var resp = await _httpClient.PostAsJsonAsync(authUrl, request);

Expand Down Expand Up @@ -256,7 +272,8 @@ public async Task<bool> CheckTokenAsync(string token)
{
try
{
var authUrl = ConfigConstants.AuthUrl + "api/auth/ping";
var baseAuthUrl = GetAuthUrl();
var authUrl = baseAuthUrl + "api/auth/ping";

using var resp = await authUrl.SendAsync(_httpClient, url =>
{
Expand Down
6 changes: 6 additions & 0 deletions SS14.Launcher/Assets/Locale/en-US/text.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ login-login-button-resend = Resend email confirmation
login-login-button-register = Don't have an account? Register!
login-login-busy-logging-in = Logging in…
login-login-error-title = Unable to log in
login-login-auth-disclaimer = Current auth server: {$auth-server}

## Strings for the "register confirmation" view on login

Expand Down Expand Up @@ -365,6 +366,11 @@ tab-options-disable-signing = Disable Engine Signature Checks
tab-options-disable-signing-desc = { "[" }DEV ONLY] Disables verification of engine signatures. DO NOT ENABLE UNLESS YOU KNOW EXACTLY WHAT YOU'RE DOING.
tab-options-hub-settings = Hub Settings
tab-options-hub-settings-desc = Change what hub server or servers you would like to use to fetch the server list.
tab-options-auth-url = https://auth.playss14.com/
tab-options-auth-url-button = Set Auth URL
tab-options-set-wizden = Set to WizDen Auth
tab-options-set-funky = Set to Funky Auth
tab-options-auth-url-desc = Change what auth server you're using.
tab-options-desc-incompatible = This option is incompatible with your platform and has been disabled.

## For the language selection menu.
Expand Down
4 changes: 3 additions & 1 deletion SS14.Launcher/Models/Connector.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -345,11 +346,12 @@ private async Task LaunchClientWrap(
if (info != null && info.AuthInformation.Mode != AuthMode.Disabled && _loginManager.ActiveAccount != null)
{
var account = _loginManager.ActiveAccount;
var customAuthUrl = _cfg.GetCVar(CVars.CustomAuthUrl);

cVars.Add(("ROBUST_AUTH_TOKEN", account.LoginInfo.Token.Token));
cVars.Add(("ROBUST_AUTH_USERID", account.LoginInfo.UserId.ToString()));
cVars.Add(("ROBUST_AUTH_PUBKEY", info.AuthInformation.PublicKey));
cVars.Add(("ROBUST_AUTH_SERVER", ConfigConstants.AuthUrl.GetMostSuccessfulUrl()));
cVars.Add(("ROBUST_AUTH_SERVER", customAuthUrl));
}

try
Expand Down
2 changes: 2 additions & 0 deletions SS14.Launcher/Models/Data/CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public static readonly CVarDef<bool> HasDismissedRosettaWarning
/// </summary>
public static readonly CVarDef<bool> OverrideAssets = CVarDef.Create("OverrideAssets", true);

public static readonly CVarDef<string> CustomAuthUrl = CVarDef.Create("CustomAuthUrl", "https://auth.playss14.com/");

/// <summary>
/// Stores the minimum player count value used by the "minimum player count" filter.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion SS14.Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private static AppBuilder BuildAvaloniaApp(DataManager cfg)
Locator.CurrentMutable.RegisterConstant(http);

var loc = new LocalizationManager(cfg);
var authApi = new AuthApi(http);
var authApi = new AuthApi(cfg, http);
var hubApi = new HubApi(http);
var launcherInfo = new LauncherInfoManager(http);
var overrideAssets = new OverrideAssetsManager(cfg, http, launcherInfo);
Expand Down
4 changes: 4 additions & 0 deletions SS14.Launcher/ViewModels/Login/LoginViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class LoginViewModel : BaseLoginViewModel

[Reactive] public bool IsInputValid { get; private set; }
[Reactive] public bool IsPasswordVisible { get; set; }
public string AuthDisclaimer { get; private set; }

public LoginViewModel(MainWindowLoginViewModel parentVm, AuthApi authApi,
LoginManager loginMgr, DataManager dataManager) : base(parentVm)
Expand All @@ -32,6 +33,9 @@ public LoginViewModel(MainWindowLoginViewModel parentVm, AuthApi authApi,

this.WhenAnyValue(x => x.EditingUsername, x => x.EditingPassword)
.Subscribe(s => { IsInputValid = !string.IsNullOrEmpty(s.Item1) && !string.IsNullOrEmpty(s.Item2); });

AuthDisclaimer = _loc.GetString("login-login-auth-disclaimer",
("auth-server", _dataManager.GetCVar(CVars.CustomAuthUrl)));
}

public async void OnLogInButtonPressed()
Expand Down
42 changes: 42 additions & 0 deletions SS14.Launcher/ViewModels/MainWindowTabs/OptionsTabViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,21 @@
using SS14.Launcher.Models.ContentManagement;
using SS14.Launcher.Models.Data;
using SS14.Launcher.Models.EngineManager;
using SS14.Launcher.Models.Logins;
using SS14.Launcher.Utility;

namespace SS14.Launcher.ViewModels.MainWindowTabs;

public class OptionsTabViewModel : MainWindowTabViewModel
{
public DataManager Cfg { get; }

private readonly IEngineManager _engineManager;
private readonly ContentManager _contentManager;
private readonly LoginManager _loginManager;

public string FunkyAuthUrl = "https://tempauth.funkystation.org/";
public string WizDenAuthUrl = "https://auth.playss14.com/";

public LanguageSelectorViewModel Language { get; } = new();

Expand All @@ -23,9 +29,11 @@ public OptionsTabViewModel()
Cfg = Locator.Current.GetRequiredService<DataManager>();
_engineManager = Locator.Current.GetRequiredService<IEngineManager>();
_contentManager = Locator.Current.GetRequiredService<ContentManager>();
_loginManager = Locator.Current.GetRequiredService<LoginManager>();

DisableIncompatibleMacOS = OperatingSystem.IsMacOS();
}

public bool DisableIncompatibleMacOS { get; }

public override string Name => LocalizationManager.Instance.GetString("tab-options-title");
Expand Down Expand Up @@ -60,6 +68,40 @@ public bool OverrideAssets
}
}

private string? _pendingAuthUrl;

public string CustomAuthUrl
{
get => _pendingAuthUrl ?? Cfg.GetCVar(CVars.CustomAuthUrl);
set => _pendingAuthUrl = value;
}

public void SetAuthUrl()
{
if (_pendingAuthUrl == null || _pendingAuthUrl == Cfg.GetCVar(CVars.CustomAuthUrl))
return;

if (!_pendingAuthUrl.EndsWith('/'))
_pendingAuthUrl += '/';

// TODO: validate auth URL

Cfg.SetCVar(CVars.CustomAuthUrl, _pendingAuthUrl);

if (_loginManager.ActiveAccount != null)
Cfg.RemoveLogin(_loginManager.ActiveAccount.LoginInfo);

Cfg.CommitConfig();

_pendingAuthUrl = null;
}

public void SetAuthUrl(string url)
{
_pendingAuthUrl = url;
SetAuthUrl();
}

public void ClearEngines()
{
_engineManager.ClearAllEngines();
Expand Down
3 changes: 3 additions & 0 deletions SS14.Launcher/Views/Login/LoginView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
Command="{Binding ResendConfirmationPressed}"/>
</DockPanel>

<TextBlock HorizontalAlignment="Center"
DockPanel.Dock="Top"
Text="{Binding AuthDisclaimer}" />
<Button DockPanel.Dock="Bottom" Classes="BigButton" Margin="0 4" HorizontalAlignment="Center"
Content="{loc:Loc login-login-button-register}" Command="{Binding RegisterPressed}"
IsEnabled="{Binding !Busy}" />
Expand Down
19 changes: 19 additions & 0 deletions SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,25 @@
Text="{loc:Loc tab-options-seasonal-branding-desc}"
Margin="8" />

<StackPanel Orientation="Horizontal" Margin="0 0 8 0">
<Button Click="SetWizDenAuth" Content="{loc:Loc tab-options-set-wizden}" Margin="0 4 0 4" />
<Button Click="SetFunkyAuth" Content="{loc:Loc tab-options-set-funky}" Margin="0 4 4 4" />
</StackPanel>

<StackPanel Orientation="Horizontal" Margin="0 0 8 0">
<TextBox DockPanel.Dock="Left"
Name="AuthUrlBox"
Text="{Binding CustomAuthUrl, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
Watermark="{loc:Loc tab-options-auth-url}"
UseFloatingWatermark="False"
MinWidth="400"
Margin="4 0 4 0"/>
<Button Click="SetAuthUrl" Content="{loc:Loc tab-options-auth-url-button}" Margin="0 4 0 4" />
</StackPanel>
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap"
Text="{loc:Loc tab-options-auth-url-desc}"
Margin="8" />

<Button Click="OpenHubSettings" Content="{loc:Loc tab-options-hub-settings}" Margin="4" HorizontalAlignment="Left" />
<TextBlock VerticalAlignment="Center" TextWrapping="Wrap"
Text="{loc:Loc tab-options-hub-settings-desc}"
Expand Down
22 changes: 22 additions & 0 deletions SS14.Launcher/Views/MainWindowTabs/OptionsTabView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,26 @@ private async void OpenHubSettings(object? sender, RoutedEventArgs args)
{
await new HubSettingsDialog().ShowDialog((Window)this.GetVisualRoot()!);
}

private void UpdateUrl(string url)
{
AuthUrlBox.Text = url;
}

private void SetAuthUrl(object? sender, RoutedEventArgs e)
{
((OptionsTabViewModel)DataContext!).SetAuthUrl();
}

private void SetFunkyAuth(object? sender, RoutedEventArgs e)
{
var context = (OptionsTabViewModel)DataContext!;
context.SetAuthUrl(context.FunkyAuthUrl);
}

private void SetWizDenAuth(object? sender, RoutedEventArgs e)
{
var context = (OptionsTabViewModel)DataContext!;
context.SetAuthUrl(context.WizDenAuthUrl);
}
}
Loading