diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java index 2426fd50..6859b40f 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/AuthProviderPair.java @@ -14,11 +14,11 @@ public final class AuthProviderPair { public boolean isDefault = true; + public AuthCoreProvider core; + public AuthSocialProvider social; public AuthProvider provider; public AuthHandler handler; public TextureProvider textureProvider; - public AuthCoreProvider core; - public AuthSocialProvider social; public Map links; public transient String name; public transient Set features; @@ -30,9 +30,28 @@ public AuthProviderPair(AuthProvider provider, AuthHandler handler, TextureProvi this.textureProvider = textureProvider; } + public AuthProviderPair(AuthCoreProvider core, TextureProvider textureProvider) { + this.core = core; + this.textureProvider = textureProvider; + } + + public AuthProviderPair(AuthCoreProvider core, AuthSocialProvider social) { + this.core = core; + this.social = social; + } + + public AuthProviderPair(AuthCoreProvider core, AuthSocialProvider social, TextureProvider textureProvider) { + this.core = core; + this.social = social; + this.textureProvider = textureProvider; + } + public final T isSupport(Class clazz) { if (core == null) return null; - return core.isSupport(clazz); + T result = null; + if (social != null) result = social.isSupport(clazz); + if (result == null) result = core.isSupport(clazz); + return result; } public final void init(LaunchServer srv, String name) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AuthSocialProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AuthSocialProvider.java index b5470744..63a59955 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AuthSocialProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/AuthSocialProvider.java @@ -50,6 +50,12 @@ public static SocialResult ofUser(User user) { public abstract SocialResult preAuth(AuthResponse.AuthContext context, AuthRequest.AuthPasswordInterface password) throws AuthException; + @SuppressWarnings("unchecked") + public T isSupport(Class clazz) { + if (clazz.isAssignableFrom(getClass())) return (T) this; + return null; + } + @Override public abstract void close() throws IOException; } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java index ce54d1b2..82c998e9 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/CertificateAutogenTask.java @@ -75,7 +75,7 @@ public Path process(Path inputFile) throws IOException { .getCertificate(bcCertificate); ArrayList chain = new ArrayList<>(); chain.add(certificate); - signedDataGenerator = SignHelper.createSignedDataGenerator(server.privateKey, certificate, chain, "SHA256WITHECDSA"); + signedDataGenerator = SignHelper.createSignedDataGenerator(server.keyAgreementManager.ecdsaPrivateKey, certificate, chain, "SHA256WITHECDSA"); } catch (OperatorCreationException | CMSException | CertificateException e) { logger.error(e); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java index 95ca98af..7cb46ffe 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -8,10 +8,9 @@ import pro.gravit.launcher.LauncherConfig; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.auth.AuthProviderPair; -import pro.gravit.launchserver.auth.handler.MemoryAuthHandler; +import pro.gravit.launchserver.auth.core.RejectAuthCoreProvider; import pro.gravit.launchserver.auth.protect.ProtectHandler; import pro.gravit.launchserver.auth.protect.StdProtectHandler; -import pro.gravit.launchserver.auth.provider.RejectAuthProvider; import pro.gravit.launchserver.auth.session.MemorySessionStorage; import pro.gravit.launchserver.auth.session.SessionStorage; import pro.gravit.launchserver.auth.texture.RequestTextureProvider; @@ -70,8 +69,7 @@ public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) { newConfig.env = LauncherConfig.LauncherEnvironment.STD; newConfig.startScript = JVMHelper.OS_TYPE.equals(JVMHelper.OS.MUSTDIE) ? "." + File.separator + "start.bat" : "." + File.separator + "start.sh"; newConfig.auth = new HashMap<>(); - AuthProviderPair a = new AuthProviderPair(new RejectAuthProvider("Настройте authProvider"), - new MemoryAuthHandler(), + AuthProviderPair a = new AuthProviderPair(new RejectAuthCoreProvider(), new RequestTextureProvider("http://example.com/skins/%username%.png", "http://example.com/cloaks/%username%.png") ); a.displayName = "Default"; diff --git a/Launcher/src/main/java/pro/gravit/launcher/debug/DebugMain.java b/Launcher/src/main/java/pro/gravit/launcher/debug/DebugMain.java index 257e5711..2f5c88f8 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/debug/DebugMain.java +++ b/Launcher/src/main/java/pro/gravit/launcher/debug/DebugMain.java @@ -21,6 +21,7 @@ public class DebugMain { public static final AtomicBoolean IS_DEBUG = new AtomicBoolean(false); public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api"); public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft"); + public static String unlockKey = System.getProperty("launcherdebug.unlockkey", "0000"); public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(","); public static String[] moduleFiles = System.getProperty("launcherdebug.modulefiles", "").split(","); public static LauncherConfig.LauncherEnvironment environment = LauncherConfig.LauncherEnvironment.valueOf(System.getProperty("launcherdebug.env", "STD")); @@ -32,6 +33,7 @@ public static void main(String[] args) throws Throwable { LogHelper.info("Launcher start in DEBUG mode (Only for developers)"); LogHelper.debug("Initialization LauncherConfig"); LauncherConfig config = new LauncherConfig(webSocketURL, new HashMap<>(), projectName, environment, new DebugLauncherTrustManager(DebugLauncherTrustManager.TrustDebugMode.TRUST_ALL)); + config.oemUnlockKey = unlockKey; Launcher.setConfig(config); Launcher.applyLauncherEnv(environment); LauncherEngine.modulesManager = new ClientModuleManager(); diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java index a69a4afd..237c5c1c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/AuthRequest.java @@ -99,5 +99,9 @@ public enum ConnectTypes { public interface AuthPasswordInterface { boolean check(); + + default boolean isAllowSave() { + return false; + } } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/GetAvailabilityAuthRequest.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/GetAvailabilityAuthRequest.java index 60646fb4..15092d2a 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/GetAvailabilityAuthRequest.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/GetAvailabilityAuthRequest.java @@ -2,6 +2,7 @@ import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent; import pro.gravit.launcher.request.Request; +import pro.gravit.launcher.request.auth.details.AuthLoginOnlyDetails; import pro.gravit.launcher.request.auth.details.AuthPasswordDetails; import pro.gravit.launcher.request.auth.details.AuthTotpDetails; import pro.gravit.launcher.request.auth.details.AuthWebViewDetails; @@ -18,6 +19,7 @@ public static void registerProviders() { providers.register("password", AuthPasswordDetails.class); providers.register("webview", AuthWebViewDetails.class); providers.register("totp", AuthTotpDetails.class); + providers.register("loginonly", AuthLoginOnlyDetails.class); registeredProviders = true; } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/details/AuthLoginOnlyDetails.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/details/AuthLoginOnlyDetails.java new file mode 100644 index 00000000..01b049b4 --- /dev/null +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/details/AuthLoginOnlyDetails.java @@ -0,0 +1,10 @@ +package pro.gravit.launcher.request.auth.details; + +import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent; + +public class AuthLoginOnlyDetails implements GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails { + @Override + public String getType() { + return "loginonly"; + } +} diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/details/AuthPasswordDetails.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/details/AuthPasswordDetails.java index 985ce451..1f1022fb 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/details/AuthPasswordDetails.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/details/AuthPasswordDetails.java @@ -7,4 +7,6 @@ public class AuthPasswordDetails implements GetAvailabilityAuthRequestEvent.Auth public String getType() { return "password"; } + + } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/password/Auth2FAPassword.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/password/Auth2FAPassword.java index 19996d53..d6b7baa5 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/password/Auth2FAPassword.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/password/Auth2FAPassword.java @@ -10,4 +10,9 @@ public class Auth2FAPassword implements AuthRequest.AuthPasswordInterface { public boolean check() { return firstPassword != null && firstPassword.check() && secondPassword != null && secondPassword.check(); } + + @Override + public boolean isAllowSave() { + return firstPassword.isAllowSave() && secondPassword.isAllowSave(); + } } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/password/AuthMultiPassword.java b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/password/AuthMultiPassword.java index 3276ceb1..ddc9871c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/password/AuthMultiPassword.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/request/auth/password/AuthMultiPassword.java @@ -11,4 +11,9 @@ public class AuthMultiPassword implements AuthRequest.AuthPasswordInterface { public boolean check() { return list != null && list.stream().allMatch(l -> l != null && l.check()); } + + @Override + public boolean isAllowSave() { + return list != null && list.stream().allMatch(l -> l != null && l.isAllowSave()); + } } diff --git a/modules b/modules index ca22fda4..8b616fff 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit ca22fda40f690015edf7650f4365b8efa8e96ec8 +Subproject commit 8b616fff0946652ebba6d6dd432b73b8075421a5