mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-19 14:33:04 +03:00
maybe its can change something
This commit is contained in:
parent
7fbd668501
commit
749a96a5b9
17 changed files with 238 additions and 200 deletions
|
@ -9,6 +9,11 @@ public AuthProviderResult auth(String login, String password, String ip) {
|
|||
return new AuthProviderResult(login, SecurityHelper.randomStringToken()); // Same as login
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthProviderResult oauth(int i) throws Exception {
|
||||
return new AuthProviderResult(String.valueOf(i), SecurityHelper.randomStringToken()); // Same as login
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// Do nothing
|
||||
|
|
|
@ -28,6 +28,8 @@ public static void registerProviders() {
|
|||
|
||||
public abstract AuthProviderResult auth(String login, String password, String ip) throws Exception;
|
||||
|
||||
public abstract AuthProviderResult oauth(int i) throws Exception;
|
||||
|
||||
public void preAuth(String login, String password, String customText, String ip) {
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,11 @@ else if (result.error != null)
|
|||
return authError("Authentication server response is malformed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthProviderResult oauth(int i) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// pass
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
public final class MySQLAuthProvider extends AuthProvider {
|
||||
private MySQLSourceConfig mySQLHolder;
|
||||
private String query;
|
||||
private String oauthQuery;
|
||||
private String message;
|
||||
private String[] queryParams;
|
||||
private boolean usePermission;
|
||||
|
@ -44,6 +45,21 @@ public AuthProviderResult auth(String login, String password, String ip) throws
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthProviderResult oauth(int i) throws Exception {
|
||||
try (Connection c = mySQLHolder.getConnection()) {
|
||||
PreparedStatement s = c.prepareStatement(oauthQuery);
|
||||
String[] replaceParams = {"%i%", String.valueOf(i)};
|
||||
s.setString(1, oauthQuery.replace("?", String.valueOf(i)));
|
||||
// Execute SQL query
|
||||
s.setQueryTimeout(MySQLSourceConfig.TIMEOUT);
|
||||
try (ResultSet set = s.executeQuery()) {
|
||||
return set.next() ? new AuthProviderResult(set.getString(1),
|
||||
SecurityHelper.randomStringToken(),
|
||||
LaunchServer.server.config.permissionsHandler.getPermissions(set.getString(1))) : authError(message);
|
||||
}
|
||||
} }
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
mySQLHolder.close();
|
||||
|
|
|
@ -13,6 +13,11 @@ public AuthProviderResult auth(String login, String password, String ip) throws
|
|||
return getProvider().auth(login, password, ip);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthProviderResult oauth(int i) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
AuthProvider provider = this.provider;
|
||||
|
|
|
@ -30,6 +30,11 @@ public AuthProviderResult auth(String login, String password, String ip) throws
|
|||
return authError(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthProviderResult oauth(int i) throws Exception {
|
||||
return authError(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// Do nothing
|
||||
|
|
|
@ -36,6 +36,11 @@ public AuthProviderResult auth(String login, String password, String ip) throws
|
|||
authError(currentResponse);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuthProviderResult oauth(int i) throws Exception {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
// Do nothing
|
||||
|
|
|
@ -86,10 +86,10 @@ public static void registerCommands(ru.gravit.utils.command.CommandHandler handl
|
|||
service.registerCommand("component", new ComponentCommand(server));
|
||||
service.registerCommand("givePermission", new GivePermissionsCommand(server));
|
||||
service.registerCommand("getPermissions", new GetPermissionsCommand(server));
|
||||
service.registerCommand("cache", new OAuthCacheHandler(server));
|
||||
service.registerCommand("token", new OAuthTokenGet(server));
|
||||
Category serviceCategory = new Category(service, "service", "Managing LaunchServer Components");
|
||||
handler.registerCategory(serviceCategory);
|
||||
|
||||
service.registerCommand("cache", new OAuthCacheHandler(server));
|
||||
service.registerCommand("token", new OAuthTokenGet(server));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,9 +23,10 @@ public String getUsageDescription() {
|
|||
|
||||
@Override
|
||||
public void invoke(String... args) {
|
||||
LogHelper.subInfo("Length of Cache " + OAuthManager.stageAreaLength());
|
||||
for(int i=0; i < OAuthManager.stageAreaLength(); i++ ){
|
||||
LogHelper.subInfo("IP is: " + LaunchServer.server.cacheHandler.stageArea[i].IP());
|
||||
LogHelper.subInfo("Length of Cache " + OAuthManager.getCacheLength());
|
||||
for(OAuthManager.Entry e: OAuthManager.getStageArea() ){
|
||||
if(e.isInit())
|
||||
LogHelper.subInfo("IP is: " + e.getIP());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,23 +39,24 @@ public String getUsageDescription() {
|
|||
@Override
|
||||
public void invoke(String... args) {
|
||||
String code = args[0];
|
||||
UserAuthResponse authResponse = mToken(code, vk);
|
||||
LogHelper.subInfo(authResponse.getAccessToken());
|
||||
}
|
||||
|
||||
public static UserAuthResponse mToken(String code, VkApiClient vk) {
|
||||
UserAuthResponse authResponse = null;
|
||||
try {
|
||||
authResponse = mToken(code, vk);
|
||||
LogHelper.subInfo(authResponse.getAccessToken());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static UserAuthResponse mToken(String code, VkApiClient vk) throws ClientException, ApiException {
|
||||
UserAuthResponse authResponse;
|
||||
authResponse = vk.oAuth().
|
||||
userAuthorizationCodeFlow(LaunchServer.server.config.OAuthAppID,
|
||||
userAuthorizationCodeFlow(
|
||||
LaunchServer.server.config.OAuthAppID,
|
||||
LaunchServer.server.config.OAuthAppSecret,
|
||||
LaunchServer.server.config.getOAuthBackURL(),
|
||||
code).execute();
|
||||
} catch (ApiException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return authResponse;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package ru.gravit.launchserver.manangers;
|
||||
|
||||
import com.vk.api.sdk.actions.OAuth;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import ru.gravit.launcher.NeedGarbageCollection;
|
||||
import ru.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
@ -16,136 +17,138 @@ public class OAuthManager implements NeedGarbageCollection {
|
|||
|
||||
@Override
|
||||
public void garbageCollection() {
|
||||
for(int i=0; i < 5; i++ )
|
||||
for(Entry e: LaunchServer.server.cacheHandler.stageArea)
|
||||
{
|
||||
LaunchServer.server.cacheHandler.stageArea[i].destroy.run();
|
||||
int finalI = i;
|
||||
LaunchServer.server.cacheHandler.stageArea[i].destroy = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!LaunchServer.server.cacheHandler.stageArea[finalI].init)
|
||||
return;
|
||||
LogHelper.debug("cache purged, IP: " + LaunchServer.server.cacheHandler.stageArea[finalI].IP());
|
||||
LaunchServer.server.cacheHandler.stageArea[finalI].init = false;
|
||||
LaunchServer.server.cacheHandler.stageArea[finalI].mTimer = null;
|
||||
LaunchServer.server.cacheHandler.stageArea[finalI].client = null;
|
||||
LaunchServer.server.cacheHandler.stageArea[finalI].ctx = null;
|
||||
}
|
||||
};
|
||||
e.destroy();
|
||||
}
|
||||
LogHelper.subInfo("OAuthCache purged");
|
||||
}
|
||||
|
||||
public Entry[] stageArea;
|
||||
|
||||
public OAuthManager(){
|
||||
if(stageArea == null) {
|
||||
stageArea = newEntryArray();
|
||||
}
|
||||
}
|
||||
|
||||
public static class Entry{
|
||||
|
||||
public void setEntry(Client client, ChannelHandlerContext ctx){
|
||||
if(client != null && ctx != null) {
|
||||
public void setter(ChannelHandlerContext ctx, Client client){
|
||||
this.init = true;
|
||||
this.client = client;
|
||||
this.ctx = ctx;
|
||||
this.mTimer = new Timer();
|
||||
this.mTimer.schedule(destroy, 300000L);
|
||||
LogHelper.subDebug("New Entry with IP " + IP());
|
||||
}
|
||||
}
|
||||
|
||||
public void Entry(){
|
||||
this.init = false;
|
||||
this.mTimer = null;
|
||||
this.client = null;
|
||||
this.ctx = null;
|
||||
}
|
||||
|
||||
private boolean init = false;
|
||||
|
||||
private Client client = null;
|
||||
|
||||
private ChannelHandlerContext ctx = null;
|
||||
|
||||
private Timer mTimer = null;
|
||||
|
||||
public String IP(){
|
||||
return IOHelper.getIP(getCtx().channel().remoteAddress());
|
||||
}
|
||||
|
||||
private TimerTask destroy = new TimerTask() {
|
||||
this.client = client;
|
||||
new Timer().schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(!init)
|
||||
return;
|
||||
LogHelper.debug("cache purged, IP: " + IP());
|
||||
init = false;
|
||||
mTimer = null;
|
||||
client = null;
|
||||
ctx = null;
|
||||
destroy();
|
||||
}
|
||||
}, 300000L);
|
||||
}
|
||||
|
||||
public void setter(AuthRequestEvent authRequestEvent){
|
||||
this.authRequestEvent = authRequestEvent;
|
||||
}
|
||||
|
||||
public Entry(){
|
||||
this.init = false;
|
||||
this.ctx = null;
|
||||
this.client = null;
|
||||
this.authRequestEvent = null;
|
||||
new Timer().cancel();
|
||||
}
|
||||
|
||||
private boolean init;
|
||||
|
||||
private ChannelHandlerContext ctx;
|
||||
|
||||
private Client client;
|
||||
|
||||
private AuthRequestEvent authRequestEvent;
|
||||
|
||||
public void destroy(){
|
||||
this.init = false;
|
||||
this.ctx = null;
|
||||
this.client = null;
|
||||
this.authRequestEvent = null;
|
||||
new Timer().cancel();
|
||||
}
|
||||
};
|
||||
|
||||
public boolean isInit() {
|
||||
return init;
|
||||
}
|
||||
|
||||
public Client getClient() {
|
||||
return client;
|
||||
}
|
||||
|
||||
public ChannelHandlerContext getCtx() {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public Client getClient() {
|
||||
return client;
|
||||
}
|
||||
public static int stageAreaLength(){
|
||||
|
||||
public String getIP(){
|
||||
if(isInit())
|
||||
return IOHelper.getIP(getCtx().channel().remoteAddress());
|
||||
else
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Entry[] stageArea;
|
||||
|
||||
public static Entry[] getStageArea(){
|
||||
return LaunchServer.server.cacheHandler.stageArea;
|
||||
}
|
||||
|
||||
public static Integer getCacheLength(){
|
||||
int i = 0;
|
||||
for(int e=0; e < 5; e++ )
|
||||
{
|
||||
i += LaunchServer.server.cacheHandler.stageArea[e].isInit() ? 1 : 0;
|
||||
}
|
||||
for(Entry e : LaunchServer.server.cacheHandler.stageArea)
|
||||
i = e.isInit() ? 1 : 0;
|
||||
return i;
|
||||
}
|
||||
|
||||
public static void stretchCache(Client client, ChannelHandlerContext ctx){
|
||||
getUnused().setEntry(client, ctx);
|
||||
public OAuthManager(){
|
||||
stageArea = new Entry[]{
|
||||
new Entry(), new Entry(), new Entry(), new Entry(), new Entry()
|
||||
};
|
||||
}
|
||||
|
||||
public static Entry getUnused(){
|
||||
for(int i=0; i < 5; i++ )
|
||||
public static void stretchCache(ChannelHandlerContext ctx, Client client){
|
||||
try {
|
||||
Entry e = getUnused();
|
||||
e.setter(ctx, client);
|
||||
LogHelper.subDebug("New Entry IP: " + e.getIP());
|
||||
} catch (OAuthException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void stretchCache(String IP, AuthRequestEvent authRequestEvent){
|
||||
for(Entry e: LaunchServer.server.cacheHandler.stageArea)
|
||||
{
|
||||
if(!LaunchServer.server.cacheHandler.stageArea[i].isInit())
|
||||
return LaunchServer.server.cacheHandler.stageArea[i];
|
||||
if(e.getIP().equals(IP))
|
||||
e.setter(authRequestEvent);
|
||||
}
|
||||
try {
|
||||
throw new OAuthException("Not found");
|
||||
} catch (OAuthException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public static void stretchCache(ChannelHandlerContext ctx, AuthRequestEvent authRequestEvent){
|
||||
for(Entry e: LaunchServer.server.cacheHandler.stageArea)
|
||||
{
|
||||
if(e.getIP().equals(IOHelper.getIP(ctx.channel().remoteAddress())))
|
||||
e.setter(authRequestEvent);
|
||||
}
|
||||
try {
|
||||
throw new OAuthException("Not found");
|
||||
} catch (OAuthException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Entry getUnused() throws OAuthException {
|
||||
for(Entry e: LaunchServer.server.cacheHandler.stageArea)
|
||||
{
|
||||
if(e.isInit())
|
||||
continue;
|
||||
return e;
|
||||
}
|
||||
|
||||
throw new OAuthException("OAuth Overloaded");
|
||||
} catch (OAuthException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Entry getEntry(String IP){
|
||||
for(int i = 0; i < 5; i++ )
|
||||
{
|
||||
if(LaunchServer.server.cacheHandler.stageArea[i].isInit())
|
||||
if(LaunchServer.server.cacheHandler.stageArea[i].IP().equals(IP))
|
||||
return LaunchServer.server.cacheHandler.stageArea[i];
|
||||
}
|
||||
try {
|
||||
throw new OAuthException("Not found in cache");
|
||||
}catch (OAuthException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Entry[] newEntryArray(){
|
||||
return new Entry[]{new Entry(), new Entry(), new Entry(), new Entry(), new Entry()};
|
||||
}
|
||||
|
||||
public static final class OAuthException extends IOException {
|
||||
|
@ -159,6 +162,4 @@ public String toString() {
|
|||
return getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -161,8 +161,7 @@ public void registerClient(Channel channel) {
|
|||
|
||||
public void registerResponses() {
|
||||
registerResponse("auth", AuthResponse.class);
|
||||
registerResponse("oauth", OAuthResponse.class);
|
||||
registerResponse("OAuthURL", OAuthConfirmResponse.class);
|
||||
registerResponse("OAuthURL", OAuthResponse.class);
|
||||
registerResponse("checkServer", CheckServerResponse.class);
|
||||
registerResponse("joinServer", JoinServerResponse.class);
|
||||
registerResponse("profiles", ProfilesResponse.class);
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
package ru.gravit.launchserver.websocket.json.auth;
|
||||
|
||||
import com.vk.api.sdk.client.TransportClient;
|
||||
import com.vk.api.sdk.client.VkApiClient;
|
||||
import com.vk.api.sdk.exceptions.ApiException;
|
||||
import com.vk.api.sdk.exceptions.ClientException;
|
||||
import com.vk.api.sdk.httpclient.HttpTransportClient;
|
||||
import com.vk.api.sdk.objects.UserAuthResponse;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
|
||||
import ru.gravit.launcher.events.request.OAuthConfirmRequestEvent;
|
||||
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
|
||||
import ru.gravit.launchserver.command.handler.OAuthTokenGet;
|
||||
import ru.gravit.launchserver.manangers.OAuthManager;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.launchserver.websocket.json.SimpleResponse;
|
||||
import ru.gravit.utils.HookException;
|
||||
|
||||
|
||||
public class OAuthConfirmResponse extends SimpleResponse {
|
||||
|
||||
TransportClient transportClient = new HttpTransportClient();
|
||||
VkApiClient vk = new VkApiClient(transportClient);
|
||||
|
||||
public String code;
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client clientData) throws Exception {
|
||||
try {
|
||||
if(code == null) {
|
||||
try {
|
||||
throw new OAuthManager.OAuthException("Empty code");
|
||||
}catch (OAuthManager.OAuthException e) {
|
||||
sendError(e.getMessage());
|
||||
}
|
||||
}
|
||||
//LogHelper.debug("code get");
|
||||
|
||||
OAuthTokenGet.mToken(code, vk);
|
||||
int ID = authResponse.getUserId();
|
||||
|
||||
OAuthConfirmRequestEvent result = new OAuthConfirmRequestEvent();
|
||||
result.str = "Continue in Launcher";
|
||||
sendResultAndClose(result);
|
||||
|
||||
} catch (HookException e) {
|
||||
sendError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "OAuthURL";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,42 +1,83 @@
|
|||
package ru.gravit.launchserver.websocket.json.auth;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.vk.api.sdk.client.TransportClient;
|
||||
import com.vk.api.sdk.client.VkApiClient;
|
||||
import com.vk.api.sdk.client.actors.UserActor;
|
||||
import com.vk.api.sdk.httpclient.HttpTransportClient;
|
||||
import com.vk.api.sdk.objects.UserAuthResponse;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import ru.gravit.launcher.OshiHWID;
|
||||
import ru.gravit.launcher.events.request.OAuthRequestEvent;
|
||||
|
||||
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
|
||||
import ru.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import ru.gravit.launcher.events.request.LogEvent;
|
||||
|
||||
import ru.gravit.launcher.profiles.PlayerProfile;
|
||||
import ru.gravit.launcher.request.ResultInterface;
|
||||
import ru.gravit.launcher.serialize.HInput;
|
||||
import ru.gravit.launchserver.LaunchServer;
|
||||
import ru.gravit.launchserver.auth.AuthProviderPair;
|
||||
import ru.gravit.launchserver.auth.provider.AuthProviderResult;
|
||||
import ru.gravit.launchserver.command.handler.OAuthTokenGet;
|
||||
import ru.gravit.launchserver.manangers.OAuthManager;
|
||||
import ru.gravit.launchserver.socket.Client;
|
||||
import ru.gravit.launchserver.websocket.json.SimpleResponse;
|
||||
import ru.gravit.utils.HookException;
|
||||
import ru.gravit.launchserver.websocket.json.profile.ProfileByUUIDResponse;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
import ru.gravit.utils.helper.LogHelper;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class OAuthResponse extends SimpleResponse {
|
||||
|
||||
public OshiHWID hwid;
|
||||
TransportClient transportClient = new HttpTransportClient();
|
||||
VkApiClient vk = new VkApiClient(transportClient);
|
||||
|
||||
|
||||
public String code;
|
||||
|
||||
@Override
|
||||
public void execute(ChannelHandlerContext ctx, Client clientData) throws Exception {
|
||||
public void execute(ChannelHandlerContext ctx, Client clientData) {
|
||||
try {
|
||||
OAuthManager.stretchCache(clientData, ctx);
|
||||
OAuthRequestEvent result = new OAuthRequestEvent();
|
||||
result.URL = getAcsessURL();
|
||||
sendResult(result);
|
||||
} catch (HookException e) {
|
||||
if(code == null) {
|
||||
try {
|
||||
throw new OAuthManager.OAuthException("Empty code");
|
||||
}catch (OAuthManager.OAuthException e) {
|
||||
sendError(e.getMessage());
|
||||
}
|
||||
}
|
||||
public URL getAcsessURL() throws MalformedURLException {
|
||||
|
||||
String url = "http://oauth.vk.com/authorize?client_id=" + LaunchServer.server.config.OAuthAppID + "&display=page&scope=offline&response_type=code&v=5.69&redirect_uri=" + LaunchServer.server.config.getOAuthBackURL();
|
||||
return new URL(url);
|
||||
UserAuthResponse authResponse = OAuthTokenGet.mToken(code, vk);
|
||||
|
||||
UserActor actor = new UserActor(authResponse.getUserId(), authResponse.getAccessToken());
|
||||
sendResultAndClose(new LogEvent("Continue in Launcher"));
|
||||
AuthProviderResult ar;
|
||||
AuthProviderPair ap;
|
||||
if(LaunchServer.server.config.getAuthProviderPair("MySQLAuthProvider") != null) {
|
||||
ar = LaunchServer.server.config.getAuthProviderPair("MySQLAuthProvider").provider.oauth(actor.getId());
|
||||
ap = LaunchServer.server.config.getAuthProviderPair("MySQLAuthProvider");
|
||||
}else {
|
||||
ar = LaunchServer.server.config.getAuthProviderPair().provider.oauth(actor.getId());
|
||||
ap = LaunchServer.server.config.getAuthProviderPair();
|
||||
}
|
||||
LogHelper.subDebug("found account " + ar.username);
|
||||
|
||||
UUID uuid = ap.handler.auth(ar);
|
||||
PlayerProfile playerProfile = ProfileByUUIDResponse.getProfile(LaunchServer.server, uuid, ar.username, "client", clientData.auth.textureProvider);
|
||||
AuthRequestEvent a = new AuthRequestEvent(playerProfile, ar.accessToken, ar.permissions);
|
||||
OAuthManager.stretchCache(ctx, a);
|
||||
|
||||
} catch (Exception e) {
|
||||
sendError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "oauth";
|
||||
return "OAuthURL";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,9 @@ var config = {
|
|||
// Menu config
|
||||
discord: new java.net.URL("https://discord.gg/aJK6nMN"),
|
||||
|
||||
OAuthAppID: 0,
|
||||
OAuthBackURL: "https://%address%/OAuth.html",
|
||||
|
||||
// Settings defaults
|
||||
settingsMagic: 0xC0DE5, // Magic, don't touch
|
||||
autoEnterDefault: false, // Should autoEnter be enabled by default?
|
||||
|
|
|
@ -307,15 +307,23 @@ function doAuth(login, rsaPassword, auth_type) {
|
|||
})
|
||||
});
|
||||
}
|
||||
|
||||
function doOAuth() {
|
||||
processing.resetOverlay();
|
||||
overlay.show(processing.overlay, function (event) {
|
||||
FunctionalBridge.getHWID.join();
|
||||
makeOAuthRequest(function (result) {
|
||||
openURL(new java.net.URL(result.URL));
|
||||
overlay.hide(600000, function () {
|
||||
openURL(getOAuthURL());
|
||||
overlay.hide(300000, function () {
|
||||
setCurrentScene(loginScene);
|
||||
});
|
||||
makeOAuthRequest(function (result) {
|
||||
FunctionalBridge.setAuthParams(result);
|
||||
loginData = { pp: result.playerProfile , accessToken: result.accessToken, permissions: result.permissions,
|
||||
auth_type: "OAuth"};
|
||||
|
||||
overlay.hide(0, function () {
|
||||
setCurrentScene(menuScene);
|
||||
});
|
||||
return result;
|
||||
})
|
||||
});
|
||||
|
|
|
@ -121,18 +121,18 @@ function makeAuthRequest(login, rsaPassword, auth_type, callback) {
|
|||
task.updateMessage("Авторизация на сервере");
|
||||
startTask(task);
|
||||
}
|
||||
|
||||
function getOAuthURL() {
|
||||
return new java.net.URL("http://oauth.vk.com/authorize?client_id="+ config.OAuthAppID +
|
||||
"&display=page&scope=offline&response_type=code&v=5.69&redirect_uri=" + config.OAuthBackURL)
|
||||
}
|
||||
|
||||
function makeOAuthRequest(callback) {
|
||||
var task = newRequestTask(new OAuthRequest(FunctionalBridge.getHWID()));
|
||||
processing.setTaskProperties(task, callback, null, true);
|
||||
task.updateMessage("Ожидание авторизация на сервере");
|
||||
startTask(task);
|
||||
}
|
||||
function makeOAuthRequest(callback) {
|
||||
var task = newRequestTask(new OAuthRequest(FunctionalBridge.getHWID()));
|
||||
processing.setTaskProperties(task, callback, null, true);
|
||||
startTask(task);
|
||||
}
|
||||
|
||||
|
||||
function launchClient(assetHDir, clientHDir, profile, params, callback) {
|
||||
var task = newTask(function() ClientLauncher.launch(assetHDir, clientHDir,
|
||||
|
|
Loading…
Reference in a new issue