From 5c39b1d4d2991b965f4032d4601b99e4b247f237 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 24 Nov 2019 19:55:33 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD?= =?UTF-8?q?=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=B2=20Auth=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B7=D0=B0=D1=89=D0=B8=D1=82=D1=8B=20=D0=BE?= =?UTF-8?q?=D1=82=20=D0=B4=D1=83=D1=80=D0=B0=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launchserver/auth/provider/AuthProvider.java | 2 +- .../socket/response/auth/AuthResponse.java | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java index 07b02ae6..03cd0462 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java @@ -43,7 +43,7 @@ public static void registerProviders() { */ public abstract AuthProviderResult auth(String login, AuthRequest.AuthPasswordInterface password, String ip) throws Exception; - public void preAuth(String login, AuthRequest.AuthPasswordInterface password, String customText, String ip) { + public void preAuth(String login, AuthRequest.AuthPasswordInterface password, String ip) { } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java index 18c8bb2b..f067795d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/AuthResponse.java @@ -3,6 +3,7 @@ import io.netty.channel.ChannelHandlerContext; import pro.gravit.launcher.events.request.AuthRequestEvent; import pro.gravit.launcher.hwid.HWID; +import pro.gravit.launcher.hwid.NoHWID; import pro.gravit.launcher.profiles.ClientProfile; import pro.gravit.launcher.request.auth.AuthRequest; import pro.gravit.launcher.request.auth.password.AuthECPassword; @@ -32,7 +33,6 @@ public class AuthResponse extends SimpleResponse { public final transient static Random random = new SecureRandom(); public String login; public String client; - public String customText; public boolean getSession; public AuthRequest.AuthPasswordInterface password; @@ -66,13 +66,19 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti throw new AuthException("Password decryption error"); } } + if(hwid == null) hwid = new NoHWID(); AuthProviderPair pair; if (auth_id.isEmpty()) pair = server.config.getAuthProviderPair(); else pair = server.config.getAuthProviderPair(auth_id); - AuthContext context = new AuthContext(clientData, login, customText, client, hwid, ip, authType); + if(pair == null) + { + sendError("auth_id incorrect"); + return; + } + AuthContext context = new AuthContext(clientData, login, client, hwid, ip, authType); AuthProvider provider = pair.provider; server.authHookManager.preHook.hook(context, clientData); - provider.preAuth(login, password, customText, ip); + provider.preAuth(login, password, ip); AuthProviderResult aresult = provider.auth(login, password, ip); if (!VerifyHelper.isValidUsername(aresult.username)) { AuthProvider.authError(String.format("Illegal result: '%s'", aresult.username)); @@ -128,10 +134,9 @@ public void execute(ChannelHandlerContext ctx, Client clientData) throws Excepti } public static class AuthContext { - public AuthContext(Client client, String login, String customText, String profileName, HWID hwid, String ip, ConnectTypes authType) { + public AuthContext(Client client, String login, String profileName, HWID hwid, String ip, ConnectTypes authType) { this.client = client; this.login = login; - this.customText = customText; this.profileName = profileName; this.hwid = hwid; this.ip = ip; @@ -143,7 +148,6 @@ public AuthContext(Client client, String login, String customText, String profil public int password_length; //Use AuthProvider for get password public final String profileName; public final HWID hwid; - public final String customText; public final String ip; public final ConnectTypes authType; public final Client client;