Skip to content

Commit

Permalink
Attempt to authenticate via mppass first even when name verification …
Browse files Browse the repository at this point in the history
…is disabled
  • Loading branch information
UnknownShadow200 committed Jun 23, 2022
1 parent 454c8c8 commit 6dba848
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 7 additions & 2 deletions MCGalaxy/Server/Authentication/AuthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ public class AuthService
public AuthServiceConfig Config;

public virtual bool Authenticate(Player p, string mppass) {
bool valid = Authenticator.Current.VerifyLogin(p, mppass, this);
if (!valid) return false;
if (!VerifyLogin(p, mppass)) return false;
AuthServiceConfig cfg = Config;

p.verifiedName = true;
Expand All @@ -51,6 +50,12 @@ public virtual bool Authenticate(Player p, string mppass) {
return true;
}

/// <summary> Whether the given player is allowed to login with the given mppass </summary>
protected virtual bool VerifyLogin(Player p, string mppass) {
string calculated = Server.CalcMppass(p.truename, Beat.Salt);
return mppass.CaselessEq(calculated);
}


static string lastUrls;
/// <summary> Reloads list of authentication services from server config </summary>
Expand Down
12 changes: 2 additions & 10 deletions MCGalaxy/Server/Authentication/Authenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,12 @@ public abstract class Authenticator

/// <summary> Checks if the given player is allowed to login with the given mppass </summary>
public virtual bool VerifyLogin(Player p, string mppass) {
if (!Server.Config.VerifyNames) return true;

foreach (AuthService auth in AuthService.Services)
{
if (auth.Authenticate(p, mppass)) return true;
}
return IPUtil.IsPrivate(p.IP);
}

/// <summary> Checks if the given player is allowed to login with the
/// given mppass to the given authentication service </summary>
public virtual bool VerifyLogin(Player p, string mppass, AuthService service) {
string calculated = Server.CalcMppass(p.truename, service.Beat.Salt);
return mppass.CaselessEq(calculated);

return !Server.Config.VerifyNames || IPUtil.IsPrivate(p.IP);
}

/// <summary> Informs the given player that they must first
Expand Down

0 comments on commit 6dba848

Please sign in to comment.