diff --git a/README.md b/README.md index f9a4dee5..683822d2 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,7 @@ Possible values: `Premium`, `Cracked`, `Unknown` * [BungeeAuth](https://www.spigotmc.org/resources/bungeeauth.493/) * [BungeeAuthenticator](https://www.spigotmc.org/resources/bungeecordauthenticator.87669/) +* [SodionAuth (2.0+)](https://github.com/Mohist-Community/SodionAuth) ## Network requests diff --git a/bukkit/pom.xml b/bukkit/pom.xml index c47e0a0f..97492b7c 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -272,7 +272,7 @@ com.github.Mohist-Community.SodionAuth SodionAuth-Bukkit - b74392aa34 + 2bdfdc854b com.github.Mohist-Community.SodionAuth diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java index 6ef6a297..8b9888ec 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/hook/SodionAuthHook.java @@ -35,11 +35,11 @@ import red.mohist.sodionauth.core.exception.AuthenticatedException; /** * GitHub: https://github.com/Mohist-Community/SodionAuth *

- * Project page: + * Project page: https://gitea.e-loli.com/SodionAuth/SodionAuth *

* Bukkit: Unknown *

- * Spigot: Unknown + * Spigot: https://www.spigotmc.org/resources/sodionauth.76944/ */ public class SodionAuthHook implements AuthPlugin { diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java index 22205b66..c5dcc9ca 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/task/DelayedAuthHook.java @@ -94,13 +94,13 @@ public class DelayedAuthHook implements Runnable { private AuthPlugin getAuthHook() { try { - @SuppressWarnings("unchecked") List>> hooks = Arrays.asList(AuthMeHook.class, CrazyLoginHook.class, LogItHook.class, LoginSecurityHook.class, SodionAuthHook.class, UltraAuthHook.class, xAuthHook.class); for (Class> clazz : hooks) { - String pluginName = clazz.getSimpleName().replace("Hook", ""); + String pluginName = clazz.getSimpleName(); + pluginName = pluginName.substring(0, pluginName.length() - "Hook".length()); //uses only member classes which uses AuthPlugin interface (skip interfaces) if (Bukkit.getPluginManager().isPluginEnabled(pluginName)) { //check only for enabled plugins. A single plugin could be disabled by plugin managers diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 80ff1602..df3b48cb 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -23,6 +23,7 @@ softdepend: # Auth plugins - AuthMe - LoginSecurity + - SodionAuth - xAuth - LogIt - UltraAuth diff --git a/bungee/pom.xml b/bungee/pom.xml index 74a68857..5d5d842d 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -97,6 +97,14 @@ spigotplugins-repo https://maven.gamestrike.de/mvn/ + + + jitpack.io + https://jitpack.io + + false + + @@ -138,5 +146,19 @@ 0.0.2 provided + + + com.github.Mohist-Community.SodionAuth + SodionAuth-Bungee + 2bdfdc854b + + + com.github.Mohist-Community.SodionAuth + SodionAuth-Libs + + + true + provided + 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 bfb60eba..7d68fb45 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 @@ -26,11 +26,13 @@ package com.github.games647.fastlogin.bungee; import com.github.games647.fastlogin.bungee.hook.BungeeAuthHook; -import com.github.games647.fastlogin.bungee.hook.BungeeCordAuthenticatorHook; +import com.github.games647.fastlogin.bungee.hook.BungeeCordAuthenticatorBungeeHook; +import com.github.games647.fastlogin.bungee.hook.SodionAuthHook; 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; @@ -43,6 +45,8 @@ 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; @@ -55,6 +59,8 @@ import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.PluginManager; import net.md_5.bungee.api.scheduler.GroupedThreadFactory; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; import org.slf4j.Logger; /** @@ -110,16 +116,24 @@ public class FastLoginBungee extends Plugin implements PlatformPlugin>> hooks = Arrays.asList( + BungeeAuthHook.class, BungeeCordAuthenticatorBungeeHook.class, SodionAuthHook.class); + + for (Class> clazz : hooks) { + String pluginName = clazz.getSimpleName(); + pluginName = pluginName.substring(0, pluginName.length() - "Hook".length()); + //uses only member classes which uses AuthPlugin interface (skip interfaces) + Plugin plugin = getProxy().getPluginManager().getPlugin(pluginName); + if (plugin != null) { + logger.info("Hooking into auth plugin: {}", pluginName); + core.setAuthPluginHook( + clazz.getDeclaredConstructor(FastLoginBungee.class).newInstance(this)); + break; + } + } + } catch (ReflectiveOperationException ex) { + logger.error("Couldn't load the auth hook class", ex); } } diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java index cb22a6ee..abddb172 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeAuthHook.java @@ -25,6 +25,7 @@ */ package com.github.games647.fastlogin.bungee.hook; +import com.github.games647.fastlogin.bungee.FastLoginBungee; import com.github.games647.fastlogin.core.hooks.AuthPlugin; import me.vik1395.BungeeAuth.Main; @@ -43,6 +44,9 @@ public class BungeeAuthHook implements AuthPlugin { private final RequestHandler requestHandler = new RequestHandler(); + public BungeeAuthHook(FastLoginBungee plugin) { + } + @Override public boolean forceLogin(ProxiedPlayer player) { String playerName = player.getName(); diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorHook.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorBungeeHook.java similarity index 85% rename from bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorHook.java rename to bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorBungeeHook.java index 2af0a6e6..beb56d96 100644 --- a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorHook.java +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/BungeeCordAuthenticatorBungeeHook.java @@ -27,15 +27,13 @@ package com.github.games647.fastlogin.bungee.hook; import java.sql.SQLException; +import com.github.games647.fastlogin.bungee.FastLoginBungee; import com.github.games647.fastlogin.core.hooks.AuthPlugin; -import org.slf4j.Logger; - import de.xxschrandxx.bca.bungee.BungeeCordAuthenticatorBungee; import de.xxschrandxx.bca.bungee.api.BungeeCordAuthenticatorBungeeAPI; import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Plugin; /** * GitHub: @@ -45,14 +43,14 @@ import net.md_5.bungee.api.plugin.Plugin; * * Spigot: https://www.spigotmc.org/resources/bungeecordauthenticator.87669/ */ -public class BungeeCordAuthenticatorHook implements AuthPlugin { +public class BungeeCordAuthenticatorBungeeHook implements AuthPlugin { public final BungeeCordAuthenticatorBungeeAPI api; - public BungeeCordAuthenticatorHook(Plugin plugin, Logger logger) { - BungeeCordAuthenticatorBungee bcab = (BungeeCordAuthenticatorBungee) plugin; - api = bcab.getAPI(); - logger.info("BungeeCordAuthenticatorHook | Hooked successful!"); + public BungeeCordAuthenticatorBungeeHook(FastLoginBungee plugin) { + api = ((BungeeCordAuthenticatorBungee) plugin.getProxy().getPluginManager() + .getPlugin("BungeeCordAuthenticatorBungee")).getAPI(); + plugin.getLog().info("BungeeCordAuthenticatorHook | Hooked successful!"); } @Override diff --git a/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/SodionAuthHook.java b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/SodionAuthHook.java new file mode 100644 index 00000000..f22d3619 --- /dev/null +++ b/bungee/src/main/java/com/github/games647/fastlogin/bungee/hook/SodionAuthHook.java @@ -0,0 +1,80 @@ +/* + * 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.hook; + +import com.github.games647.fastlogin.bungee.FastLoginBungee; +import com.github.games647.fastlogin.core.hooks.AuthPlugin; +import net.md_5.bungee.api.connection.ProxiedPlayer; +import red.mohist.sodionauth.bungee.implementation.BungeePlayer; +import red.mohist.sodionauth.core.SodionAuthApi; +import red.mohist.sodionauth.core.exception.AuthenticatedException; + +import java.util.concurrent.ExecutionException; + +/** + * GitHub: https://github.com/Mohist-Community/SodionAuth + *

+ * Project page: https://gitea.e-loli.com/SodionAuth/SodionAuth + *

+ * Bukkit: Unknown + *

+ * Spigot: https://www.spigotmc.org/resources/sodionauth.76944/ + */ +public class SodionAuthHook implements AuthPlugin { + + private final FastLoginBungee plugin; + + public SodionAuthHook(FastLoginBungee plugin) { + this.plugin = plugin; + } + + @Override + public boolean forceLogin(ProxiedPlayer player) { + try { + SodionAuthApi.login(new BungeePlayer(player)); + } catch (AuthenticatedException e) { + plugin.getLog().warn(ALREADY_AUTHENTICATED, player); + return false; + } + return true; + } + + @Override + public boolean forceRegister(ProxiedPlayer player, String password) { + try{ + return SodionAuthApi.register(new BungeePlayer(player), password); + } catch (UnsupportedOperationException e){ + plugin.getLog().warn("Currently SodionAuth is not accepting forceRegister, " + + "It may be caused by unsupported AuthBackend"); + return false; + } + } + + @Override + public boolean isRegistered(String playerName) { + return SodionAuthApi.isRegistered(playerName); + } +} diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml index a5fa5aa1..c52f41a1 100644 --- a/bungee/src/main/resources/bungee.yml +++ b/bungee/src/main/resources/bungee.yml @@ -12,6 +12,7 @@ softDepends: # BungeeCord auth plugins - BungeeAuth - BungeeCordAuthenticatorBungee + - SodionAuth description: | ${project.description}