Protect unknown data too

This commit is contained in:
games647 2021-06-19 18:22:54 +02:00
parent e437321f8f
commit cc2128b612
No known key found for this signature in database
GPG Key ID: BFC68C8708713A88
3 changed files with 7 additions and 2 deletions

View File

@ -99,7 +99,9 @@ public class ListenerService implements SettingsDependent {
}
// registration not enforced, but registered players needs to be restricted if not logged in
return playerCache.getRegistrationStatus(name) == RegistrationStatus.REGISTERED;
// if there is no data fall back to safer alternative to prevent any leakage
final RegistrationStatus status = playerCache.getRegistrationStatus(name);
return status != RegistrationStatus.UNREGISTERED;
}
@Override

View File

@ -117,7 +117,8 @@ public class AsynchronousJoin implements AsynchronousProcess {
}
final boolean isAuthAvailable = database.isAuthAvailable(name);
playerCache.addRegistrationStatus(name, isAuthAvailable ? RegistrationStatus.REGISTERED : RegistrationStatus.UNREGISTERED);
RegistrationStatus status = isAuthAvailable ? RegistrationStatus.REGISTERED : RegistrationStatus.UNREGISTERED;
playerCache.addRegistrationStatus(name, status);
if (isAuthAvailable) {
protectInventory(player);

View File

@ -4,6 +4,7 @@ import ch.jalu.injector.testing.BeforeInjecting;
import ch.jalu.injector.testing.DelayedInjectionRunner;
import ch.jalu.injector.testing.InjectDelayed;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerCache.RegistrationStatus;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.settings.Settings;
@ -119,6 +120,7 @@ public class ListenerServiceTest {
String playerName = "myPlayer1";
Player player = mockPlayerWithName(playerName);
given(playerCache.isAuthenticated(playerName)).willReturn(false);
given(playerCache.getRegistrationStatus(playerName)).willReturn(RegistrationStatus.UNREGISTERED);
given(settings.getProperty(RegistrationSettings.FORCE)).willReturn(false);
EntityEvent event = mock(EntityEvent.class);
given(event.getEntity()).willReturn(player);