[FEATURE] NoProtectHandler - disable joinServer protection

This commit is contained in:
Gravita 2023-10-31 00:20:57 +07:00
parent f22aa36926
commit 80862e6116
3 changed files with 10 additions and 1 deletions

View file

@ -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;
}
}

View file

@ -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) {

View file

@ -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;
}