feat: add config options to restrict signup on certain platforms

This commit is contained in:
Zaprit 2024-10-12 16:42:57 +01:00
commit 746bce730e
2 changed files with 22 additions and 0 deletions

View file

@ -130,6 +130,23 @@ public class LoginController : ControllerBase
Logger.Warn($"Unknown user tried to connect username={username}", LogArea.Login);
return this.Forbid();
}
// Block RPCN signups if forbidden in config
if (npTicket.Platform == Platform.RPCS3 && !ServerConfiguration.Instance.Authentication.AllowRPCNSignup)
{
Logger.Warn(
$"New user tried to sign up via RPCN, and that is forbidden in the config, username={username}, remoteIpAddress={remoteIpAddress}",
LogArea.Login);
}
// Block PSN signups if forbidden in config
if (npTicket.Platform == Platform.RPCS3 && !ServerConfiguration.Instance.Authentication.AllowPSNSignup)
{
Logger.Warn(
$"New user tried to sign up via PSN, and that is forbidden in the config, username={username}, remoteIpAddress={remoteIpAddress}",
LogArea.Login);
}
// create account for user if they don't exist
user = await this.database.CreateUser(username, "$");
user.Password = null;

View file

@ -5,4 +5,9 @@ public class AuthenticationConfiguration
public bool RegistrationEnabled { get; set; } = true;
public bool AutomaticAccountCreation { get; set; } = true;
public bool VerifyTickets { get; set; } = true;
public bool AllowRPCNSignup { get; set; } = true;
public bool AllowPSNSignup { get; set; } = true;
}