From 4975802f5fcea2ef9cfa06df8b9a0939961ff935 Mon Sep 17 00:00:00 2001 From: mohammed jasem alaajel <34905970+ham1255@users.noreply.github.com> Date: Tue, 15 Jun 2021 02:28:50 +0400 Subject: [PATCH] Removing all Auth related stuff diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java index 25f1ac2..ec6f74a 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/FastLoginBungee.java @@ -29,7 +29,6 @@ import com.github.games647.fastlogin.bungee.listener.ConnectListener; import com.github.games647.fastlogin.bungee.listener.PluginMessageListener; import com.github.games647.fastlogin.core.AsyncScheduler; import com.github.games647.fastlogin.core.CommonUtil; -import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.github.games647.fastlogin.core.message.ChangePremiumMessage; import com.github.games647.fastlogin.core.message.ChannelMessage; import com.github.games647.fastlogin.core.message.NamespaceKey; @@ -42,8 +41,6 @@ import com.google.common.io.ByteStreams; import com.google.common.util.concurrent.ThreadFactoryBuilder; import java.nio.file.Path; -import java.util.Arrays; -import java.util.List; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ThreadFactory; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java index db8f269..07df30a 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/listener/ConnectListener.java @@ -32,7 +32,6 @@ import com.github.games647.fastlogin.bungee.hook.floodgate.FloodgateHook; import com.github.games647.fastlogin.bungee.hook.floodgate.FloodgateV1Hook; import com.github.games647.fastlogin.bungee.hook.floodgate.FloodgateV2Hook; import com.github.games647.fastlogin.bungee.task.AsyncPremiumCheck; -import com.github.games647.fastlogin.bungee.task.ForceLoginTask; import com.github.games647.fastlogin.core.RateLimiter; import com.github.games647.fastlogin.core.StoredProfile; import com.github.games647.fastlogin.core.shared.LoginSession; @@ -249,8 +248,12 @@ public class ConnectListener implements Listener { // delay sending force command, because Paper will process the login event asynchronously // In this case it means that the force command (plugin message) is already received and processed while // player is still in the login phase and reported to be offline. - Runnable loginTask = new ForceLoginTask(plugin.getCore(), player, server, session); - plugin.getScheduler().runAsync(loginTask); + + // LimeLogin start + //Disabled... + //Runnable loginTask = new ForceLoginTask(plugin.getCore(), player, server, session); + //plugin.getScheduler().runAsync(loginTask); + // LimeLogin end } @EventHandler diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java index 410b1e4..0136f09 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java @@ -49,8 +49,9 @@ public class AsyncPremiumCheck extends JoinManagement>>>>>> 654e137 (related to main) this.plugin = plugin; this.preLoginEvent = preLoginEvent; this.connection = connection; diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/ForceLoginTask.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/ForceLoginTask.java deleted file mode 100644 index 0a7f862..0000000 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/task/ForceLoginTask.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * The MIT License (MIT) - * - * Copyright (c) 2015-2021 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.github.games647.fastlogin.bungee.task; - -import com.github.games647.fastlogin.bungee.BungeeLoginSession; -import com.github.games647.fastlogin.bungee.FastLoginBungee; -import com.github.games647.fastlogin.bungee.event.BungeeFastLoginAutoLoginEvent; -import com.github.games647.fastlogin.core.StoredProfile; -import com.github.games647.fastlogin.core.message.ChannelMessage; -import com.github.games647.fastlogin.core.message.LoginActionMessage; -import com.github.games647.fastlogin.core.message.LoginActionMessage.Type; -import com.github.games647.fastlogin.core.shared.FastLoginCore; -import com.github.games647.fastlogin.core.shared.ForceLoginManagement; -import com.github.games647.fastlogin.core.shared.LoginSession; -import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent; - -import java.util.UUID; - -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.connection.Server; - -public class ForceLoginTask - extends ForceLoginManagement { - - private final Server server; - - public ForceLoginTask(FastLoginCore core, - ProxiedPlayer player, Server server, BungeeLoginSession session) { - super(core, player, session); - - this.server = server; - } - - @Override - public void run() { - if (session == null) { - return; - } - - super.run(); - - if (!isOnlineMode()) { - session.setAlreadySaved(true); - } - } - - @Override - public boolean forceLogin(ProxiedPlayer player) { - if (session.isAlreadyLogged()) { - return true; - } - - session.setAlreadyLogged(true); - return super.forceLogin(player); - } - - @Override - public FastLoginAutoLoginEvent callFastLoginAutoLoginEvent(LoginSession session, StoredProfile profile) { - return core.getPlugin().getProxy().getPluginManager() - .callEvent(new BungeeFastLoginAutoLoginEvent(session, profile)); - } - - @Override - public boolean forceRegister(ProxiedPlayer player) { - return session.isAlreadyLogged() || super.forceRegister(player); - } - - @Override - public void onForceActionSuccess(LoginSession session) { - //sub channel name - Type type = Type.LOGIN; - if (session.needsRegistration()) { - type = Type.REGISTER; - } - - UUID proxyId = UUID.fromString(ProxyServer.getInstance().getConfig().getUuid()); - ChannelMessage loginMessage = new LoginActionMessage(type, player.getName(), proxyId); - - core.getPlugin().sendPluginMessage(server, loginMessage); - } - - @Override - public String getName(ProxiedPlayer player) { - return player.getName(); - } - - @Override - public boolean isOnline(ProxiedPlayer player) { - return player.isConnected(); - } - - @Override - public boolean isOnlineMode() { - return player.getPendingConnection().isOnlineMode(); - } -} diff --git a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java b/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java deleted file mode 100644 index 1a614ba..0000000 --- a/core/src/main/java/com/github/games647/fastlogin/core/hooks/AuthPlugin.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * The MIT License (MIT) - * - * Copyright (c) 2015-2021 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.github.games647.fastlogin.core.hooks; - -/** - * Represents a supporting authentication plugin in BungeeCord and Bukkit/Spigot/... servers - * - * @param

either {@link org.bukkit.entity.Player} for Bukkit or {@link net.md_5.bungee.api.connection.ProxiedPlayer} - * for BungeeCord - */ -public interface AuthPlugin

{ - - String ALREADY_AUTHENTICATED = "Player {} is already authenticated. Cancelling force login."; - - /** - * Login the premium (paid account) player after the player joined successfully the server. - * - * This operation will be performed async while the player successfully - * joined the server. - * - * @param player the player that needs to be logged in - * @return if the operation was successful - */ - boolean forceLogin(P player); - - /** - * Forces a register in order to protect the paid account. - * - * This operation will be performed async while the player successfully - * joined the server. - * - * After a successful registration the player should be logged - * in too. - * - * The method will be called only for premium accounts. - * So it's recommended to set additionally premium property - * if possible. - * - * Background: If we don't register an account, cracked players - * could steal the unregistered account from the paid - * player account - * - * @param player the premium account - * @param password a strong random generated password - * @return if the operation was successful - */ - boolean forceRegister(P player, String password); - - /** - * Checks whether an account exists for this player name. - * - * This check should check if a cracked player account exists - * so we can be sure the premium player doesn't steal the account - * of that player. - * - * This operation will be performed async while the player is - * connecting. - * - * @param playerName player name - * @return if the player has an account - * @throws Exception if an error occurred - */ - boolean isRegistered(String playerName) throws Exception; -} diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java index ec3f924..90c9add 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/FastLoginCore.java @@ -30,7 +30,6 @@ import com.github.games647.craftapi.resolver.http.RotatingProxySelector; import com.github.games647.fastlogin.core.AuthStorage; import com.github.games647.fastlogin.core.CommonUtil; import com.github.games647.fastlogin.core.RateLimiter; -import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.github.games647.fastlogin.core.hooks.DefaultPasswordGenerator; import com.github.games647.fastlogin.core.hooks.PasswordGenerator; import com.google.common.net.HostAndPort; @@ -85,8 +84,9 @@ public class FastLoginCore

> { private AuthStorage storage; private RateLimiter rateLimiter; private PasswordGenerator

passwordGenerator = new DefaultPasswordGenerator<>(); - private AuthPlugin

authPlugin; - + // LimeLogin start + //private AuthPlugin

authPlugin; + // LimeLogin end <<<<<<< HEAD ======= >>>>>>> 654e137 (related to main) public FastLoginCore(T plugin) { this.plugin = plugin; } @@ -251,17 +251,25 @@ public class FastLoginCore

> { return pendingConfirms; } + // LimeLogin start + /* public AuthPlugin

getAuthPluginHook() { return authPlugin; } + */ + // LimeLogin end <<<<<<< HEAD ======= >>>>>>> 654e137 (related to main) public RateLimiter getRateLimiter() { return rateLimiter; } + // LimeLogin start + /* public void setAuthPluginHook(AuthPlugin

authPlugin) { this.authPlugin = authPlugin; } + */ + // LimeLogin end public void saveDefaultFile(String fileName) { Path dataFolder = plugin.getPluginFolder(); diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java deleted file mode 100644 index b417e64..0000000 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/ForceLoginManagement.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * The MIT License (MIT) - * - * Copyright (c) 2015-2021 - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package com.github.games647.fastlogin.core.shared; - -import com.github.games647.fastlogin.core.AuthStorage; -import com.github.games647.fastlogin.core.StoredProfile; -import com.github.games647.fastlogin.core.hooks.AuthPlugin; -import com.github.games647.fastlogin.core.shared.event.FastLoginAutoLoginEvent; - -public abstract class ForceLoginManagement

> - implements Runnable { - - protected final FastLoginCore core; - protected final P player; - protected final L session; - - public ForceLoginManagement(FastLoginCore core, P player, L session) { - this.core = core; - this.player = player; - this.session = session; - } - - @Override - public void run() { - if (!isOnline(player)) { - core.getPlugin().getLog().info("Player {} disconnected", player); - return; - } - - if (session == null) { - core.getPlugin().getLog().info("No valid session found for {}", player); - return; - } - - AuthStorage storage = core.getStorage(); - StoredProfile playerProfile = session.getProfile(); - try { - if (isOnlineMode()) { - //premium player - AuthPlugin

authPlugin = core.getAuthPluginHook(); - if (authPlugin == null) { - //maybe only bungeecord plugin - onForceActionSuccess(session); - } else { - boolean success = true; - String playerName = getName(player); - if (core.getConfig().get("autoLogin", true)) { - if (session.needsRegistration() - || (core.getConfig().get("auto-register-unknown", false) - && !authPlugin.isRegistered(playerName))) { - success = forceRegister(player); - } else if (!callFastLoginAutoLoginEvent(session, playerProfile).isCancelled()) { - success = forceLogin(player); - } - } - - if (success) { - //update only on success to prevent corrupt data - if (playerProfile != null) { - playerProfile.setId(session.getUuid()); - playerProfile.setPremium(true); - storage.save(playerProfile); - } - - onForceActionSuccess(session); - } - } - } else if (playerProfile != null) { - //cracked player - playerProfile.setId(null); - playerProfile.setPremium(false); - // LimeLogin start - - //Govindas comment - don't save cracked player profiles, I found it to be useless - //storage.save(playerProfile); - //end of Govindas comment - - // LimeLogin end - } - } catch (Exception ex) { - core.getPlugin().getLog().warn("ERROR ON FORCE LOGIN of {}", getName(player), ex); - } - } - - public boolean forceRegister(P player) { - core.getPlugin().getLog().info("Register player {}", getName(player)); - - String generatedPassword = core.getPasswordGenerator().getRandomPassword(player); - boolean success = core.getAuthPluginHook().forceRegister(player, generatedPassword); - - String message = core.getMessage("auto-register"); - if (success && message != null) { - message = message.replace("%password", generatedPassword); - core.getPlugin().sendMessage(player, message); - } - - return success; - } - - public boolean forceLogin(P player) { - core.getPlugin().getLog().info("Logging player {} in", getName(player)); - - boolean success = core.getAuthPluginHook().forceLogin(player); - if (success) { - core.sendLocaleMessage("auto-login", player); - } - - return success; - } - - public abstract FastLoginAutoLoginEvent callFastLoginAutoLoginEvent(LoginSession session, StoredProfile profile); - - public abstract void onForceActionSuccess(LoginSession session); - - public abstract String getName(P player); - - public abstract boolean isOnline(P player); - - public abstract boolean isOnlineMode(); -} diff --git a/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java index 5490673..dabe324 100644 --- a/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java +++ b/core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java @@ -28,7 +28,6 @@ package com.github.games647.fastlogin.core.shared; import com.github.games647.craftapi.model.Profile; import com.github.games647.craftapi.resolver.RateLimitException; import com.github.games647.fastlogin.core.StoredProfile; -import com.github.games647.fastlogin.core.hooks.AuthPlugin; import com.github.games647.fastlogin.core.hooks.FloodgateHook; import com.github.games647.fastlogin.core.shared.event.FastLoginPreLoginEvent; @@ -43,14 +42,18 @@ import net.md_5.bungee.config.Configuration; public abstract class JoinManagement

{ protected final FastLoginCore core; - protected final AuthPlugin

authHook; + // LimeLogin start + //protected final AuthPlugin

authHook; + // LimeLogin end private final FloodgateHook floodgateHook; - public JoinManagement(FastLoginCore core, AuthPlugin

authHook) { + // LimeLogin start + public JoinManagement(FastLoginCore core) { this.core = core; - this.authHook = authHook; this.floodgateHook = new FloodgateHook<>(core); } <<<<<<< HEAD ======= >>>>>>> 654e137 (related to main) + // LimeLogin end + public void onLogin(String username, S source) { core.getPlugin().getLog().info("Handling player {}", username); @@ -130,7 +133,7 @@ public abstract class JoinManagement

{ //end of Govindas comment <<<<<<< HEAD // LimeLogin end ======= // LimeLogin end >>>>>>> 654e137 (related to main) - if (core.getConfig().get("autoRegister", false) && (authHook == null)) { + if (core.getConfig().get("autoRegister", false)) { // LimeLogin start requestPremiumLogin(source, profile, username, false); //Comment: always use false to fix an error XD // LimeLogin end <<<<<<< HEAD ======= >>>>>>> 654e137 (related to main) -- 2.32.0.windows.1