OAuth Request

This commit is contained in:
JoshOOOWAH 2019-05-24 22:44:34 +05:00
parent f06516577b
commit 4d9684cc03
4 changed files with 67 additions and 1 deletions

View file

@ -82,6 +82,10 @@ public static final class Config {
public String binaryName; public String binaryName;
public int OAuthAppID;
public String OAuthAppSecret;
public boolean copyBinaries = true; public boolean copyBinaries = true;
public LauncherConfig.LauncherEnvironment env; public LauncherConfig.LauncherEnvironment env;
@ -149,6 +153,8 @@ public String getLegacyBindAddress() {
return legacyBindAddress; return legacyBindAddress;
} }
public String getOAuthBackURL() { return netty.OAuthBackURL; }
public void setProjectName(String projectName) { public void setProjectName(String projectName) {
this.projectName = projectName; this.projectName = projectName;
} }
@ -281,6 +287,7 @@ public class NettyConfig {
public String launcherURL; public String launcherURL;
public String downloadURL; public String downloadURL;
public String launcherEXEURL; public String launcherEXEURL;
public String OAuthBackURL;
public String address; public String address;
public Map<String, NettyUpdatesBind> bindings = new HashMap<>(); public Map<String, NettyUpdatesBind> bindings = new HashMap<>();
public NettyPerformanceConfig performance; public NettyPerformanceConfig performance;
@ -586,6 +593,9 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
Arrays.stream(config.mirrors).forEach(mirrorManager::addMirror); Arrays.stream(config.mirrors).forEach(mirrorManager::addMirror);
if(config.OAuthAppSecret == null){
LogHelper.warning("OAuthAppSecret is not defied");
}
// init modules // init modules
modulesManager.initModules(); modulesManager.initModules();
if (config.components != null) { if (config.components != null) {
@ -720,6 +730,8 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
newConfig.legacyBindAddress = "0.0.0.0"; newConfig.legacyBindAddress = "0.0.0.0";
newConfig.binaryName = "Launcher"; newConfig.binaryName = "Launcher";
newConfig.whitelistRejectString = "Вас нет в белом списке"; newConfig.whitelistRejectString = "Вас нет в белом списке";
newConfig.OAuthAppID = 0;
newConfig.OAuthAppSecret = null;
newConfig.netty = new NettyConfig(); newConfig.netty = new NettyConfig();
newConfig.netty.fileServerEnabled = true; newConfig.netty.fileServerEnabled = true;
@ -773,6 +785,7 @@ private void generateConfigIfNotExists(boolean testEnv) throws IOException {
newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/"; newConfig.netty.downloadURL = "http://" + address + ":9274/%dirname%/";
newConfig.netty.launcherURL = "http://" + address + ":9274/Launcher.jar"; newConfig.netty.launcherURL = "http://" + address + ":9274/Launcher.jar";
newConfig.netty.launcherEXEURL = "http://" + address + ":9274/Launcher.exe"; newConfig.netty.launcherEXEURL = "http://" + address + ":9274/Launcher.exe";
newConfig.netty.OAuthBackURL = "https://" + address + "/OAuth.html";
newConfig.netty.sendExceptionEnabled = true; newConfig.netty.sendExceptionEnabled = true;
// Write LaunchServer config // Write LaunchServer config

View file

@ -0,0 +1,30 @@
package ru.gravit.launcher.events.request;
import ru.gravit.launcher.LauncherNetworkAPI;
import ru.gravit.launcher.events.RequestEvent;
import ru.gravit.utils.event.EventInterface;
import java.net.URL;
import java.util.UUID;
public class OAuthRequestEvent extends RequestEvent implements EventInterface {
private static final UUID uuid = UUID.fromString("77e1bfd7-adf9-4f5d-87d6-a7dd068deb74");
@LauncherNetworkAPI
public java.net.URL URL;
@Override
public UUID getUUID() {
return uuid;
}
@Override
public String getType() {
return "oauth";
}
public OAuthRequestEvent(){
}
}

View file

@ -0,0 +1,22 @@
package ru.gravit.launcher.request.auth;
import ru.gravit.launcher.HWID;
import ru.gravit.launcher.LauncherAPI;
import ru.gravit.launcher.events.request.AuthRequestEvent;
import ru.gravit.launcher.request.Request;
import ru.gravit.launcher.request.websockets.RequestInterface;
public final class OAuthRequest extends Request<AuthRequestEvent> implements RequestInterface {
private HWID hwid;
@LauncherAPI
public OAuthRequest(HWID hwid)
{
this.hwid = hwid;
}
@Override
public String getType() {
return "oauth";
}
}

View file

@ -101,6 +101,7 @@ public void registerResult(String key, Class<? extends ResultInterface> clazz) {
public void registerResults() { public void registerResults() {
registerResult("auth", AuthRequestEvent.class); registerResult("auth", AuthRequestEvent.class);
registerResult("oauth", OAuthRequestEvent.class);
registerResult("checkServer", CheckServerRequestEvent.class); registerResult("checkServer", CheckServerRequestEvent.class);
registerResult("joinServer", JoinServerRequestEvent.class); registerResult("joinServer", JoinServerRequestEvent.class);
registerResult("launcher", LauncherRequestEvent.class); registerResult("launcher", LauncherRequestEvent.class);