[FIX] Bug fixes

This commit is contained in:
Gravita 2021-09-25 18:46:07 +07:00
parent 7a78cbb878
commit dfd565d44f
5 changed files with 22 additions and 19 deletions

View file

@ -47,13 +47,13 @@ public void invoke(String... args) {
logger.info("OAuth {} | session {}", client.useOAuth, client.sessionObject == null ? "null" : client.sessionObject); logger.info("OAuth {} | session {}", client.useOAuth, client.sessionObject == null ? "null" : client.sessionObject);
logger.info("Data: checkSign {} | auth_id {}", client.checkSign ? "true" : "false", logger.info("Data: checkSign {} | auth_id {}", client.checkSign ? "true" : "false",
client.auth_id); client.auth_id);
}
if (client.trustLevel != null) { if (client.trustLevel != null) {
logger.info("trustLevel | key {} | pubkey {}", client.trustLevel.keyChecked ? "checked" : "unchecked", client.trustLevel.publicKey == null ? "null" : new String(Base64.getEncoder().encode(client.trustLevel.publicKey))); logger.info("trustLevel | key {} | pubkey {}", client.trustLevel.keyChecked ? "checked" : "unchecked", client.trustLevel.publicKey == null ? "null" : new String(Base64.getEncoder().encode(client.trustLevel.publicKey)));
} }
if (client.permissions != null) { if (client.permissions != null) {
logger.info("Permissions: {}", client.permissions.toString()); logger.info("Permissions: {}", client.permissions.toString());
} }
}
})); }));
} }
} }

View file

@ -1,6 +1,5 @@
package pro.gravit.launchserver.manangers; package pro.gravit.launchserver.manangers;
import io.jsonwebtoken.Claims;
import io.jsonwebtoken.JwtParser; import io.jsonwebtoken.JwtParser;
import io.jsonwebtoken.Jwts; import io.jsonwebtoken.Jwts;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
@ -70,11 +69,16 @@ public CheckServerTokenInfo parseCheckServerToken(String token) {
} }
} }
public class CheckServerVerifier implements RestoreResponse.ExtendedTokenProvider { public static class CheckServerVerifier implements RestoreResponse.ExtendedTokenProvider {
private final LaunchServer server;
public CheckServerVerifier(LaunchServer server) {
this.server = server;
}
@Override @Override
public boolean accept(Client client, AuthProviderPair pair, String extendedToken) { public boolean accept(Client client, AuthProviderPair pair, String extendedToken) {
var info = parseCheckServerToken(extendedToken); var info = server.authManager.parseCheckServerToken(extendedToken);
if(info == null) { if(info == null) {
return false; return false;
} }

View file

@ -10,6 +10,7 @@
import pro.gravit.launchserver.auth.core.User; import pro.gravit.launchserver.auth.core.User;
import pro.gravit.launchserver.auth.core.UserSession; import pro.gravit.launchserver.auth.core.UserSession;
import pro.gravit.launchserver.auth.protect.AdvancedProtectHandler; import pro.gravit.launchserver.auth.protect.AdvancedProtectHandler;
import pro.gravit.launchserver.manangers.AuthManager;
import pro.gravit.launchserver.socket.Client; import pro.gravit.launchserver.socket.Client;
import pro.gravit.launchserver.socket.response.SimpleResponse; import pro.gravit.launchserver.socket.response.SimpleResponse;
import pro.gravit.launchserver.socket.response.update.LauncherResponse; import pro.gravit.launchserver.socket.response.update.LauncherResponse;
@ -32,6 +33,7 @@ public static void registerProviders(LaunchServer server) {
providers.put(LauncherRequestEvent.LAUNCHER_EXTENDED_TOKEN_NAME, new LauncherResponse.LauncherTokenVerifier(server)); providers.put(LauncherRequestEvent.LAUNCHER_EXTENDED_TOKEN_NAME, new LauncherResponse.LauncherTokenVerifier(server));
providers.put("publicKey", new AdvancedProtectHandler.PublicKeyTokenVerifier(server)); providers.put("publicKey", new AdvancedProtectHandler.PublicKeyTokenVerifier(server));
providers.put("hardware", new AdvancedProtectHandler.HardwareInfoTokenVerifier(server)); providers.put("hardware", new AdvancedProtectHandler.HardwareInfoTokenVerifier(server));
providers.put("checkServer", new AuthManager.CheckServerVerifier(server));
registeredProviders = true; registeredProviders = true;
} }
} }

View file

@ -92,9 +92,12 @@ public void addRole(String role) {
public void addAction(String action) { public void addAction(String action) {
if (actions == null) { if (actions == null) {
actions = new ArrayList<>(); actions = new ArrayList<>(1);
} }
actions.add(action); actions.add(action);
if(available == null) {
available = new ArrayList<>(1);
}
available.add(Pattern.compile(action)); available.add(Pattern.compile(action));
} }
@ -154,17 +157,11 @@ public final void setFlag(long mask, boolean value) {
@Override @Override
public String toString() { public String toString() {
if (roles != null || actions != null) {
return "ClientPermissions{" + return "ClientPermissions{" +
"roles=" + String.join(", ", roles == null ? Collections.emptyList() : roles) + "roles=" + String.join(", ", roles == null ? Collections.emptyList() : roles) +
", actions=" + String.join(", ", actions == null ? Collections.emptyList() : actions) + ", actions=" + String.join(", ", actions == null ? Collections.emptyList() : actions) +
'}'; '}';
} }
return "ClientPermissions{" +
"permissions=" + permissions +
", flags=" + flags +
'}';
}
@Deprecated @Deprecated
public enum PermissionConsts { public enum PermissionConsts {

View file

@ -156,7 +156,7 @@ public void run(String... args) throws Throwable {
{ {
LogHelper.debug("WebSocket connect closed. Try reconnect"); LogHelper.debug("WebSocket connect closed. Try reconnect");
try { try {
restore(); Request.reconnect();
getProfiles(); getProfiles();
} catch (Exception e) { } catch (Exception e) {
LogHelper.error(e); LogHelper.error(e);