Support saved token system (#62)

This commit is contained in:
Andrew 2022-05-11 15:35:53 -04:00 committed by GitHub
parent 24437d3ae8
commit 7493206025
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 14 deletions

View file

@ -32,6 +32,7 @@ import org.geysermc.connect.storage.AbstractStorageManager;
import org.geysermc.connect.utils.Server; import org.geysermc.connect.utils.Server;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
@Getter @Getter
@ -72,6 +73,9 @@ public class GeyserConnectConfig {
@JsonProperty("debug-mode") @JsonProperty("debug-mode")
private boolean debugMode; private boolean debugMode;
@JsonProperty("saved-user-logins")
private List<String> savedUserLogins = Collections.emptyList();
} }
@Getter @Getter

View file

@ -77,6 +77,12 @@ public class GeyserProxyBootstrap implements GeyserBootstrap {
ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory()); ObjectMapper objectMapper = new ObjectMapper(new YAMLFactory());
geyserConfig = objectMapper.readValue(text, GeyserProxyConfiguration.class); geyserConfig = objectMapper.readValue(text, GeyserProxyConfiguration.class);
geyserConfig.getSavedUserLogins().clear();
for (String savedUserLogin : MasterServer.getInstance().getGeyserConnectConfig().getGeyser().getSavedUserLogins()) {
geyserConfig.getSavedUserLogins().add(savedUserLogin);
}
} catch (IOException ex) { } catch (IOException ex) {
geyserLogger.severe("Failed to read proxy_config.yml! Make sure it's up to date and/or readable+writable!", ex); geyserLogger.severe("Failed to read proxy_config.yml! Make sure it's up to date and/or readable+writable!", ex);
return; return;

View file

@ -237,6 +237,7 @@ public class Player {
session.sendPacket(transferPacket); session.sendPacket(transferPacket);
} else { } else {
GeyserProxySession geyserSession = createGeyserSession(true); GeyserProxySession geyserSession = createGeyserSession(true);
GeyserImpl geyser = geyserSession.getGeyser();
geyserSession.setDimension(DimensionUtils.THE_END); geyserSession.setDimension(DimensionUtils.THE_END);
@ -249,6 +250,13 @@ public class Player {
initializedPacket.setRuntimeEntityId(geyserSession.getPlayerEntity().getGeyserId()); initializedPacket.setRuntimeEntityId(geyserSession.getPlayerEntity().getGeyserId());
session.getPacketHandler().handle(initializedPacket); session.getPacketHandler().handle(initializedPacket);
if (geyser.getConfig().getSavedUserLogins().contains(authData.name())) {
String refreshToken = geyser.refreshTokenFor(authData.name());
if (refreshToken != null) {
geyserSession.authenticateWithRefreshToken(refreshToken);
}
}
if (geyserSession.getRemoteAuthType() != AuthType.ONLINE) { if (geyserSession.getRemoteAuthType() != AuthType.ONLINE) {
geyserSession.authenticate(geyserSession.getAuthData().name()); geyserSession.authenticate(geyserSession.getAuthData().name());
} }

View file

@ -31,6 +31,10 @@ geyser:
# If debug messages should be sent through console, has to be enabled in both places to work # If debug messages should be sent through console, has to be enabled in both places to work
debug-mode: false debug-mode: false
saved-user-logins:
- ThisExampleUsernameShouldBeLongEnoughToNeverBeAnXboxUsername
- ThisOtherExampleUsernameShouldAlsoBeLongEnough
# A global list of servers sent to all clients # A global list of servers sent to all clients
servers: servers:
- name: The Hive - name: The Hive

View file

@ -62,20 +62,9 @@ remote:
# You can ignore this when not using Floodgate. # You can ignore this when not using Floodgate.
floodgate-key-file: public-key.pem floodgate-key-file: public-key.pem
# The Xbox/Minecraft Bedrock username is the key for the Java server auth-info. saved-user-logins:
# This allows automatic configuration/login to the remote Java server. - ThisExampleUsernameShouldBeLongEnoughToNeverBeAnXboxUsername
# If you are brave enough to put your Mojang account info into a config file. - ThisOtherExampleUsernameShouldAlsoBeLongEnough
# Uncomment the lines below to enable this feature.
#userAuths:
# BedrockAccountUsername: # Your Minecraft: Bedrock Edition username
# email: javaccountemail@example.com # Your Minecraft: Java Edition email
# password: javaccountpassword123 # Your Minecraft: Java Edition password
# microsoft-account: true # Whether the account is a Mojang or Microsoft account.
#
# bluerkelp2:
# email: not_really_my_email_address_mr_minecrafter53267@gmail.com
# password: "this isn't really my password"
# microsoft-account: false
# Bedrock clients can freeze when opening up the command prompt for the first time if given a lot of commands. # Bedrock clients can freeze when opening up the command prompt for the first time if given a lot of commands.
# Disabling this will prevent command suggestions from being sent and solve freezing for Bedrock clients. # Disabling this will prevent command suggestions from being sent and solve freezing for Bedrock clients.