mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE][EXPERIMENTAL] Add ClientServer and AuthService to ServerWrapper, extended check server, remove deprecated interfaces
This commit is contained in:
parent
43626bf1f4
commit
d2f34ced28
21 changed files with 151 additions and 80 deletions
|
@ -108,7 +108,7 @@ public UserSession getUserSessionByOAuthAccessToken(String accessToken) throws O
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new SQLUserSession(user);
|
return createSession(user);
|
||||||
} catch (ExpiredJwtException e) {
|
} catch (ExpiredJwtException e) {
|
||||||
throw new OAuthAccessTokenExpired();
|
throw new OAuthAccessTokenExpired();
|
||||||
} catch (JwtException e) {
|
} catch (JwtException e) {
|
||||||
|
@ -133,13 +133,13 @@ public AuthManager.AuthReport refreshAccessToken(String refreshToken, AuthRespon
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(user, LocalDateTime.now(Clock.systemUTC()).plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey);
|
var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(user, LocalDateTime.now(Clock.systemUTC()).plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey);
|
||||||
return new AuthManager.AuthReport(null, accessToken, refreshToken, SECONDS.toMillis(expireSeconds), new SQLUserSession(user));
|
return new AuthManager.AuthReport(null, accessToken, refreshToken, SECONDS.toMillis(expireSeconds), createSession(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext context, AuthRequest.AuthPasswordInterface password, boolean minecraftAccess) throws IOException {
|
public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext context, AuthRequest.AuthPasswordInterface password, boolean minecraftAccess) throws IOException {
|
||||||
SQLUser SQLUser = (SQLUser) getUserByLogin(login);
|
SQLUser user = (SQLUser) getUserByLogin(login);
|
||||||
if (SQLUser == null) {
|
if (user == null) {
|
||||||
throw AuthException.userNotFound();
|
throw AuthException.userNotFound();
|
||||||
}
|
}
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
|
@ -147,16 +147,16 @@ public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext c
|
||||||
if (plainPassword == null) {
|
if (plainPassword == null) {
|
||||||
throw AuthException.wrongPassword();
|
throw AuthException.wrongPassword();
|
||||||
}
|
}
|
||||||
if (!passwordVerifier.check(SQLUser.password, plainPassword.password)) {
|
if (!passwordVerifier.check(user.password, plainPassword.password)) {
|
||||||
throw AuthException.wrongPassword();
|
throw AuthException.wrongPassword();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SQLUserSession session = new SQLUserSession(SQLUser);
|
SQLUserSession session = createSession(user);
|
||||||
var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(SQLUser, LocalDateTime.now(Clock.systemUTC()).plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey);
|
var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(user, LocalDateTime.now(Clock.systemUTC()).plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey);
|
||||||
var refreshToken = SQLUser.username.concat(".").concat(LegacySessionHelper.makeRefreshTokenFromPassword(SQLUser.username, SQLUser.password, server.keyAgreementManager.legacySalt));
|
var refreshToken = user.username.concat(".").concat(LegacySessionHelper.makeRefreshTokenFromPassword(user.username, user.password, server.keyAgreementManager.legacySalt));
|
||||||
if (minecraftAccess) {
|
if (minecraftAccess) {
|
||||||
String minecraftAccessToken = SecurityHelper.randomStringToken();
|
String minecraftAccessToken = SecurityHelper.randomStringToken();
|
||||||
updateAuth(SQLUser, minecraftAccessToken);
|
updateAuth(user, minecraftAccessToken);
|
||||||
return AuthManager.AuthReport.ofOAuthWithMinecraft(minecraftAccessToken, accessToken, refreshToken, SECONDS.toMillis(expireSeconds), session);
|
return AuthManager.AuthReport.ofOAuthWithMinecraft(minecraftAccessToken, accessToken, refreshToken, SECONDS.toMillis(expireSeconds), session);
|
||||||
} else {
|
} else {
|
||||||
return AuthManager.AuthReport.ofOAuth(accessToken, refreshToken, SECONDS.toMillis(expireSeconds), session);
|
return AuthManager.AuthReport.ofOAuth(accessToken, refreshToken, SECONDS.toMillis(expireSeconds), session);
|
||||||
|
@ -299,6 +299,10 @@ private List<String> queryPermissions(String sql, String value) throws SQLExcept
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected SQLUserSession createSession(SQLUser user) {
|
||||||
|
return new SQLUserSession(user);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEnabledPermissions() {
|
public boolean isEnabledPermissions() {
|
||||||
return permissionsPermissionColumn != null;
|
return permissionsPermissionColumn != null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportGetAllUsers;
|
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportGetAllUsers;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
|
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportRegistration;
|
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportRegistration;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportHardware;
|
|
||||||
import pro.gravit.launchserver.manangers.AuthManager;
|
import pro.gravit.launchserver.manangers.AuthManager;
|
||||||
import pro.gravit.launchserver.socket.Client;
|
import pro.gravit.launchserver.socket.Client;
|
||||||
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
|
import pro.gravit.launchserver.socket.response.auth.AuthResponse;
|
||||||
|
@ -176,28 +175,6 @@ public void invoke(String... args) throws Exception {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
map.put("getuserhardware", new SubCommand("[username]", "get hardware by username") {
|
|
||||||
@Override
|
|
||||||
public void invoke(String... args) throws Exception {
|
|
||||||
verifyArgs(args, 1);
|
|
||||||
User user = getUserByUUID(UUID.fromString(args[0]));
|
|
||||||
if (user == null) {
|
|
||||||
logger.info("User {} not found", args[0]);
|
|
||||||
}
|
|
||||||
UserSupportHardware hardware = instance.fetchUserHardware(user);
|
|
||||||
if (hardware == null) {
|
|
||||||
logger.error("Method fetchUserHardware return null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
UserHardware userHardware = hardware.getHardware();
|
|
||||||
if (userHardware == null) {
|
|
||||||
logger.info("User {} not contains hardware info", args[0]);
|
|
||||||
} else {
|
|
||||||
logger.info("UserHardware: {}", userHardware);
|
|
||||||
logger.info("HardwareInfo(JSON): {}", Launcher.gsonManager.gson.toJson(userHardware.getHardwareInfo()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
map.put("findmulti", new SubCommand("[hardware id]", "get all users in one hardware id") {
|
map.put("findmulti", new SubCommand("[hardware id]", "get all users in one hardware id") {
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String... args) throws Exception {
|
public void invoke(String... args) throws Exception {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import pro.gravit.launchserver.auth.SQLSourceConfig;
|
import pro.gravit.launchserver.auth.SQLSourceConfig;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
|
import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
|
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportHardware;
|
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportHardware;
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
@ -260,6 +260,34 @@ public void unbanHardware(UserHardware hardware) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected SQLUserSession createSession(SQLUser user) {
|
||||||
|
return new MySQLUserSession(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MySQLUserSession extends SQLUserSession implements UserSessionSupportHardware {
|
||||||
|
private transient MySQLUser mySQLUser;
|
||||||
|
protected transient MySQLUserHardware hardware;
|
||||||
|
|
||||||
|
public MySQLUserSession(SQLUser user) {
|
||||||
|
super(user);
|
||||||
|
mySQLUser = (MySQLUser) user;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getHardwareId() {
|
||||||
|
return mySQLUser.hwidId == 0 ? null : String.valueOf(mySQLUser.hwidId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UserHardware getHardware() {
|
||||||
|
if(hardware == null) {
|
||||||
|
hardware = (MySQLUserHardware) getHardwareInfoById(String.valueOf(mySQLUser.hwidId));
|
||||||
|
}
|
||||||
|
return hardware;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class MySQLUserHardware implements UserHardware {
|
public static class MySQLUserHardware implements UserHardware {
|
||||||
private final HardwareReportRequest.HardwareInfo hardwareInfo;
|
private final HardwareReportRequest.HardwareInfo hardwareInfo;
|
||||||
private final long id;
|
private final long id;
|
||||||
|
@ -304,23 +332,14 @@ public String toString() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MySQLUser extends SQLUser implements UserSupportHardware {
|
public class MySQLUser extends SQLUser {
|
||||||
protected long hwidId;
|
protected long hwidId;
|
||||||
protected transient MySQLUserHardware hardware;
|
|
||||||
|
|
||||||
public MySQLUser(UUID uuid, String username, String accessToken, String serverId, String password, ClientPermissions permissions, long hwidId) {
|
public MySQLUser(UUID uuid, String username, String accessToken, String serverId, String password, ClientPermissions permissions, long hwidId) {
|
||||||
super(uuid, username, accessToken, serverId, password, permissions);
|
super(uuid, username, accessToken, serverId, password, permissions);
|
||||||
this.hwidId = hwidId;
|
this.hwidId = hwidId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserHardware getHardware() {
|
|
||||||
if (hardware != null) return hardware;
|
|
||||||
MySQLUserHardware result = (MySQLUserHardware) getHardwareInfoById(String.valueOf(hwidId));
|
|
||||||
hardware = result;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "MySQLUser{" +
|
return "MySQLUser{" +
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Feature(GetAssetUploadUrlRequestEvent.FEATURE_NAME)
|
@Feature(GetAssetUploadUrlRequestEvent.FEATURE_NAME)
|
||||||
public interface AuthSupportAssetUpload {
|
public interface AuthSupportAssetUpload extends AuthSupport {
|
||||||
String getAssetUploadUrl(String name, User user);
|
String getAssetUploadUrl(String name, User user);
|
||||||
|
|
||||||
default AuthRequestEvent.OAuthRequestEvent getAssetUploadToken(String name, User user) {
|
default AuthRequestEvent.OAuthRequestEvent getAssetUploadToken(String name, User user) {
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package pro.gravit.launchserver.auth.core.interfaces.provider;
|
||||||
|
|
||||||
|
import pro.gravit.launchserver.auth.core.User;
|
||||||
|
import pro.gravit.launchserver.auth.core.UserSession;
|
||||||
|
import pro.gravit.launchserver.socket.Client;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface AuthSupportExtendedCheckServer {
|
||||||
|
UserSession extendedCheckServer(Client client, String username, String serverID) throws IOException;
|
||||||
|
}
|
|
@ -4,7 +4,6 @@
|
||||||
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.core.interfaces.UserHardware;
|
import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportHardware;
|
|
||||||
import pro.gravit.launchserver.helper.DamerauHelper;
|
import pro.gravit.launchserver.helper.DamerauHelper;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -28,10 +27,6 @@ public interface AuthSupportHardware extends AuthSupport {
|
||||||
|
|
||||||
void unbanHardware(UserHardware hardware);
|
void unbanHardware(UserHardware hardware);
|
||||||
|
|
||||||
default UserSupportHardware fetchUserHardware(User user) {
|
|
||||||
return (UserSupportHardware) user;
|
|
||||||
}
|
|
||||||
|
|
||||||
default void normalizeHardwareInfo(HardwareReportRequest.HardwareInfo hardwareInfo) {
|
default void normalizeHardwareInfo(HardwareReportRequest.HardwareInfo hardwareInfo) {
|
||||||
if (hardwareInfo.baseboardSerialNumber != null)
|
if (hardwareInfo.baseboardSerialNumber != null)
|
||||||
hardwareInfo.baseboardSerialNumber = hardwareInfo.baseboardSerialNumber.trim();
|
hardwareInfo.baseboardSerialNumber = hardwareInfo.baseboardSerialNumber.trim();
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
package pro.gravit.launchserver.auth.core.interfaces.provider;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public interface AuthSupportRemoteClientAccess {
|
|
||||||
String getClientApiUrl();
|
|
||||||
|
|
||||||
List<String> getClientApiFeatures();
|
|
||||||
}
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package pro.gravit.launchserver.auth.core.interfaces.session;
|
||||||
|
|
||||||
|
import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
|
||||||
|
|
||||||
|
public interface UserSessionSupportHardware {
|
||||||
|
String getHardwareId();
|
||||||
|
UserHardware getHardware();
|
||||||
|
}
|
|
@ -0,0 +1,7 @@
|
||||||
|
package pro.gravit.launchserver.auth.core.interfaces.session;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface UserSessionSupportProperties {
|
||||||
|
Map<String, String> getProperties();
|
||||||
|
}
|
|
@ -1,7 +0,0 @@
|
||||||
package pro.gravit.launchserver.auth.core.interfaces.user;
|
|
||||||
|
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
|
|
||||||
|
|
||||||
public interface UserSupportHardware {
|
|
||||||
UserHardware getHardware();
|
|
||||||
}
|
|
|
@ -16,6 +16,7 @@
|
||||||
import pro.gravit.launchserver.auth.core.AuthCoreProvider;
|
import pro.gravit.launchserver.auth.core.AuthCoreProvider;
|
||||||
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.core.interfaces.provider.AuthSupportExtendedCheckServer;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportKeys;
|
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportKeys;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportProperties;
|
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportProperties;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportTextures;
|
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportTextures;
|
||||||
|
@ -161,9 +162,16 @@ public UserSessionSupportKeys.ClientProfileKeys createClientProfileKeys(UUID pla
|
||||||
|
|
||||||
public CheckServerReport checkServer(Client client, String username, String serverID) throws IOException {
|
public CheckServerReport checkServer(Client client, String username, String serverID) throws IOException {
|
||||||
if (client.auth == null) return null;
|
if (client.auth == null) return null;
|
||||||
User user = client.auth.core.checkServer(client, username, serverID);
|
var supportExtended = client.auth.core.isSupport(AuthSupportExtendedCheckServer.class);
|
||||||
|
if(supportExtended != null) {
|
||||||
|
var session = supportExtended.extendedCheckServer(client, username, serverID);
|
||||||
|
if(session == null) return null;
|
||||||
|
return CheckServerReport.ofUserSession(session, getPlayerProfile(client.auth, session.getUser()));
|
||||||
|
} else {
|
||||||
|
var user = client.auth.core.checkServer(client, username, serverID);
|
||||||
if (user == null) return null;
|
if (user == null) return null;
|
||||||
else return CheckServerReport.ofUser(user, getPlayerProfile(client.auth, user));
|
return CheckServerReport.ofUser(user, getPlayerProfile(client.auth, user));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) throws IOException {
|
public boolean joinServer(Client client, String username, UUID uuid, String accessToken, String serverID) throws IOException {
|
||||||
|
@ -322,20 +330,27 @@ public boolean accept(Client client, AuthProviderPair pair, String extendedToken
|
||||||
public static class CheckServerReport {
|
public static class CheckServerReport {
|
||||||
public UUID uuid;
|
public UUID uuid;
|
||||||
public User user;
|
public User user;
|
||||||
|
public UserSession session;
|
||||||
public PlayerProfile playerProfile;
|
public PlayerProfile playerProfile;
|
||||||
|
|
||||||
public CheckServerReport(UUID uuid, User user, PlayerProfile playerProfile) {
|
public CheckServerReport(UUID uuid, User user, UserSession session, PlayerProfile playerProfile) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
|
this.session = session;
|
||||||
this.playerProfile = playerProfile;
|
this.playerProfile = playerProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckServerReport ofUser(User user, PlayerProfile playerProfile) {
|
public static CheckServerReport ofUser(User user, PlayerProfile playerProfile) {
|
||||||
return new CheckServerReport(user.getUUID(), user, playerProfile);
|
return new CheckServerReport(user.getUUID(), user, null, playerProfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CheckServerReport ofUserSession(UserSession session, PlayerProfile playerProfile) {
|
||||||
|
var user = session.getUser();
|
||||||
|
return new CheckServerReport(user.getUUID(), user, session, playerProfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CheckServerReport ofUUID(UUID uuid, PlayerProfile playerProfile) {
|
public static CheckServerReport ofUUID(UUID uuid, PlayerProfile playerProfile) {
|
||||||
return new CheckServerReport(uuid, null, playerProfile);
|
return new CheckServerReport(uuid, null, null, playerProfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import pro.gravit.launcher.events.request.CheckServerRequestEvent;
|
import pro.gravit.launcher.events.request.CheckServerRequestEvent;
|
||||||
import pro.gravit.launchserver.auth.AuthException;
|
import pro.gravit.launchserver.auth.AuthException;
|
||||||
|
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportHardware;
|
||||||
|
import pro.gravit.launchserver.auth.core.interfaces.session.UserSessionSupportProperties;
|
||||||
import pro.gravit.launchserver.manangers.AuthManager;
|
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;
|
||||||
|
@ -14,7 +16,9 @@ public class CheckServerResponse extends SimpleResponse {
|
||||||
private transient final Logger logger = LogManager.getLogger();
|
private transient final Logger logger = LogManager.getLogger();
|
||||||
public String serverID;
|
public String serverID;
|
||||||
public String username;
|
public String username;
|
||||||
public String client;
|
public String serverName;
|
||||||
|
public boolean needHardware;
|
||||||
|
public boolean needProperties;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
|
@ -37,6 +41,15 @@ public void execute(ChannelHandlerContext ctx, Client pClient) {
|
||||||
}
|
}
|
||||||
result.playerProfile = report.playerProfile;
|
result.playerProfile = report.playerProfile;
|
||||||
result.uuid = report.uuid;
|
result.uuid = report.uuid;
|
||||||
|
if(report.session != null) {
|
||||||
|
result.sessionId = report.session.getID();
|
||||||
|
if(needProperties && report.session instanceof UserSessionSupportProperties supportProperties) {
|
||||||
|
result.sessionProperties = supportProperties.getProperties();
|
||||||
|
}
|
||||||
|
if(needHardware && report.session instanceof UserSessionSupportHardware supportHardware) {
|
||||||
|
result.hardwareId = supportHardware.getHardwareId();
|
||||||
|
}
|
||||||
|
}
|
||||||
server.authHookManager.postCheckServerHook.hook(report, pClient);
|
server.authHookManager.postCheckServerHook.hook(report, pClient);
|
||||||
logger.debug("checkServer: {} uuid: {} serverID: {}", result.playerProfile == null ? null : result.playerProfile.username, result.uuid, serverID);
|
logger.debug("checkServer: {} uuid: {} serverID: {}", result.playerProfile == null ? null : result.playerProfile.username, result.uuid, serverID);
|
||||||
} catch (AuthException | HookException e) {
|
} catch (AuthException | HookException e) {
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
||||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportRemoteClientAccess;
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import pro.gravit.launcher.ClientPermissions;
|
import pro.gravit.launcher.ClientPermissions;
|
||||||
import pro.gravit.launcher.profiles.ClientProfile;
|
import pro.gravit.launcher.profiles.ClientProfile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AuthService {
|
public class AuthService {
|
||||||
|
@ -14,4 +15,12 @@ public class AuthService {
|
||||||
public static boolean hasPermission(String permission) {
|
public static boolean hasPermission(String permission) {
|
||||||
return permissions.hasPerm(permission);
|
return permissions.hasPerm(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasRole(String role) {
|
||||||
|
return permissions.hasRole(role);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<String> getRoles() {
|
||||||
|
return permissions.getRoles();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,5 @@
|
||||||
package pro.gravit.launcher.api;
|
package pro.gravit.launcher.api;
|
||||||
|
|
||||||
import pro.gravit.launcher.utils.ApiBridgeService;
|
|
||||||
import pro.gravit.utils.helper.IOHelper;
|
import pro.gravit.utils.helper.IOHelper;
|
||||||
import pro.gravit.utils.helper.JVMHelper;
|
import pro.gravit.utils.helper.JVMHelper;
|
||||||
import pro.gravit.utils.launch.ClassLoaderControl;
|
import pro.gravit.utils.launch.ClassLoaderControl;
|
|
@ -1,7 +1,9 @@
|
||||||
package pro.gravit.launcher.api;
|
package pro.gravit.launcher.api;
|
||||||
|
|
||||||
|
import java.security.interfaces.ECPublicKey;
|
||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
|
||||||
public class KeyService {
|
public class KeyService {
|
||||||
public static RSAPublicKey serverRsaPublicKey;
|
public static RSAPublicKey serverRsaPublicKey;
|
||||||
|
public static ECPublicKey serverEcPublicKey;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
import pro.gravit.launcher.events.RequestEvent;
|
import pro.gravit.launcher.events.RequestEvent;
|
||||||
import pro.gravit.launcher.profiles.PlayerProfile;
|
import pro.gravit.launcher.profiles.PlayerProfile;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,6 +15,12 @@ public class CheckServerRequestEvent extends RequestEvent {
|
||||||
public UUID uuid;
|
public UUID uuid;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
public PlayerProfile playerProfile;
|
public PlayerProfile playerProfile;
|
||||||
|
@LauncherNetworkAPI
|
||||||
|
public String sessionId;
|
||||||
|
@LauncherNetworkAPI
|
||||||
|
public String hardwareId;
|
||||||
|
@LauncherNetworkAPI
|
||||||
|
public Map<String, String> sessionProperties;
|
||||||
|
|
||||||
public CheckServerRequestEvent(PlayerProfile playerProfile) {
|
public CheckServerRequestEvent(PlayerProfile playerProfile) {
|
||||||
this.playerProfile = playerProfile;
|
this.playerProfile = playerProfile;
|
||||||
|
|
|
@ -11,6 +11,12 @@ public final class CheckServerRequest extends Request<CheckServerRequestEvent> i
|
||||||
public final String username;
|
public final String username;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
public final String serverID;
|
public final String serverID;
|
||||||
|
@LauncherNetworkAPI
|
||||||
|
public String serverName;
|
||||||
|
@LauncherNetworkAPI
|
||||||
|
public boolean needHardware;
|
||||||
|
@LauncherNetworkAPI
|
||||||
|
public boolean needProperties;
|
||||||
|
|
||||||
|
|
||||||
public CheckServerRequest(String username, String serverID) {
|
public CheckServerRequest(String username, String serverID) {
|
||||||
|
@ -18,6 +24,14 @@ public CheckServerRequest(String username, String serverID) {
|
||||||
this.serverID = VerifyHelper.verifyServerID(serverID);
|
this.serverID = VerifyHelper.verifyServerID(serverID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CheckServerRequest(String username, String serverID, String serverName, boolean needHardware, boolean needProperties) {
|
||||||
|
this.username = username;
|
||||||
|
this.serverID = serverID;
|
||||||
|
this.serverName = serverName;
|
||||||
|
this.needHardware = needHardware;
|
||||||
|
this.needProperties = needProperties;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return "checkServer";
|
return "checkServer";
|
||||||
|
|
|
@ -176,6 +176,7 @@ private static void realMain(String[] args) throws Throwable {
|
||||||
AuthService.username = params.playerProfile.username;
|
AuthService.username = params.playerProfile.username;
|
||||||
AuthService.uuid = params.playerProfile.uuid;
|
AuthService.uuid = params.playerProfile.uuid;
|
||||||
KeyService.serverRsaPublicKey = Launcher.getConfig().rsaPublicKey;
|
KeyService.serverRsaPublicKey = Launcher.getConfig().rsaPublicKey;
|
||||||
|
KeyService.serverEcPublicKey = Launcher.getConfig().ecdsaPublicKey;
|
||||||
modulesManager.invokeEvent(new ClientProcessReadyEvent(params));
|
modulesManager.invokeEvent(new ClientProcessReadyEvent(params));
|
||||||
LogHelper.debug("Starting JVM and client WatchService");
|
LogHelper.debug("Starting JVM and client WatchService");
|
||||||
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
|
FileNameMatcher assetMatcher = profile.getAssetUpdateMatcher();
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
import pro.gravit.launcher.ClientPermissions;
|
import pro.gravit.launcher.ClientPermissions;
|
||||||
import pro.gravit.launcher.Launcher;
|
import pro.gravit.launcher.Launcher;
|
||||||
import pro.gravit.launcher.LauncherConfig;
|
import pro.gravit.launcher.LauncherConfig;
|
||||||
|
import pro.gravit.launcher.api.AuthService;
|
||||||
|
import pro.gravit.launcher.api.ClientService;
|
||||||
import pro.gravit.launcher.api.KeyService;
|
import pro.gravit.launcher.api.KeyService;
|
||||||
import pro.gravit.launcher.config.JsonConfigurable;
|
import pro.gravit.launcher.config.JsonConfigurable;
|
||||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||||
|
@ -39,11 +41,7 @@ public class ServerWrapper extends JsonConfigurable<ServerWrapper.Config> {
|
||||||
public static ServerWrapper wrapper;
|
public static ServerWrapper wrapper;
|
||||||
public static ClassLoaderControl classLoaderControl;
|
public static ClassLoaderControl classLoaderControl;
|
||||||
public Config config;
|
public Config config;
|
||||||
public PublicURLClassLoader ucp;
|
|
||||||
public ClassLoader loader;
|
|
||||||
public ClientPermissions permissions;
|
|
||||||
public ClientProfile profile;
|
public ClientProfile profile;
|
||||||
public PlayerProfile playerProfile;
|
|
||||||
public ClientProfile.ServerProfile serverProfile;
|
public ClientProfile.ServerProfile serverProfile;
|
||||||
|
|
||||||
public ServerWrapper(Type type, Path configPath) {
|
public ServerWrapper(Type type, Path configPath) {
|
||||||
|
@ -69,7 +67,7 @@ public void restore() throws Exception {
|
||||||
if(config.extendedTokens != null) {
|
if(config.extendedTokens != null) {
|
||||||
Request.addAllExtendedToken(config.extendedTokens);
|
Request.addAllExtendedToken(config.extendedTokens);
|
||||||
}
|
}
|
||||||
Request.restore();
|
Request.RequestRestoreReport report = Request.restore(config.oauth != null, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getProfiles() throws Exception {
|
public void getProfiles() throws Exception {
|
||||||
|
@ -144,6 +142,9 @@ public void run(String... args) throws Throwable {
|
||||||
if(config.encodedServerRsaPublicKey != null) {
|
if(config.encodedServerRsaPublicKey != null) {
|
||||||
KeyService.serverRsaPublicKey = SecurityHelper.toPublicRSAKey(config.encodedServerRsaPublicKey);
|
KeyService.serverRsaPublicKey = SecurityHelper.toPublicRSAKey(config.encodedServerRsaPublicKey);
|
||||||
}
|
}
|
||||||
|
if(config.encodedServerEcPublicKey != null) {
|
||||||
|
KeyService.serverEcPublicKey = SecurityHelper.toPublicECDSAKey(config.encodedServerEcPublicKey);
|
||||||
|
}
|
||||||
String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass;
|
String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass;
|
||||||
if (classname.length() == 0) {
|
if (classname.length() == 0) {
|
||||||
LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.json or first commandline argument");
|
LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.json or first commandline argument");
|
||||||
|
@ -192,6 +193,12 @@ public void run(String... args) throws Throwable {
|
||||||
options.enableHacks = config.enableHacks;
|
options.enableHacks = config.enableHacks;
|
||||||
options.moduleConf = config.moduleConf;
|
options.moduleConf = config.moduleConf;
|
||||||
classLoaderControl = launch.init(config.classpath.stream().map(Paths::get).collect(Collectors.toCollection(ArrayList::new)), config.nativesDir, options);
|
classLoaderControl = launch.init(config.classpath.stream().map(Paths::get).collect(Collectors.toCollection(ArrayList::new)), config.nativesDir, options);
|
||||||
|
if(ServerAgent.isAgentStarted()) {
|
||||||
|
ClientService.instrumentation = ServerAgent.inst;
|
||||||
|
}
|
||||||
|
ClientService.classLoaderControl = classLoaderControl;
|
||||||
|
ClientService.baseURLs = classLoaderControl.getURLs();
|
||||||
|
ClientService.nativePath = config.nativesDir;
|
||||||
LogHelper.info("Start Minecraft Server");
|
LogHelper.info("Start Minecraft Server");
|
||||||
LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName());
|
LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName());
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
id 'org.openjfx.javafxplugin' version '0.0.10' apply false
|
id 'org.openjfx.javafxplugin' version '0.0.10' apply false
|
||||||
}
|
}
|
||||||
group = 'pro.gravit.launcher'
|
group = 'pro.gravit.launcher'
|
||||||
version = '5.5.2'
|
version = '5.5.3-SNAPSHOT'
|
||||||
|
|
||||||
apply from: 'props.gradle'
|
apply from: 'props.gradle'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue