From 80862e6116d2611d40deba96fcadd510268223cc Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Tue, 31 Oct 2023 00:20:57 +0700 Subject: [PATCH] [FEATURE] NoProtectHandler - disable joinServer protection --- .../gravit/launchserver/auth/protect/NoProtectHandler.java | 5 +++++ .../pro/gravit/launchserver/auth/protect/ProtectHandler.java | 4 ++++ .../socket/response/auth/JoinServerResponse.java | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/NoProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/NoProtectHandler.java index 2cacc3bf..d278d76b 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/NoProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/NoProtectHandler.java @@ -1,5 +1,6 @@ package pro.gravit.launchserver.auth.protect; +import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.auth.AuthResponse; public class NoProtectHandler extends ProtectHandler { @@ -9,4 +10,8 @@ public boolean allowGetAccessToken(AuthResponse.AuthContext context) { return true; } + @Override + public boolean allowJoinServer(Client client) { + return true; + } } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java index ab3edf69..cf660e52 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/protect/ProtectHandler.java @@ -1,6 +1,7 @@ package pro.gravit.launchserver.auth.protect; import pro.gravit.launchserver.LaunchServer; +import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.response.auth.AuthResponse; import pro.gravit.utils.ProviderMap; @@ -19,6 +20,9 @@ public static void registerHandlers() { } public abstract boolean allowGetAccessToken(AuthResponse.AuthContext context); + public boolean allowJoinServer(Client client) { + return client.isAuth && client.type == AuthResponse.ConnectTypes.CLIENT; + } public void init(LaunchServer server) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java index 82e9d4a2..72a480a2 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/JoinServerResponse.java @@ -26,7 +26,7 @@ public String getType() { @Override public void execute(ChannelHandlerContext ctx, Client client) { - if (!client.isAuth || client.type != AuthResponse.ConnectTypes.CLIENT) { + if (!server.config.protectHandler.allowJoinServer(client)) { sendError("Permissions denied"); return; }