mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FEATURE] Новые типы пароля для поддержки 2FA
This commit is contained in:
parent
1362d71788
commit
886c085572
8 changed files with 55 additions and 32 deletions
|
@ -36,8 +36,16 @@ public final class ServerPinger {
|
||||||
private Instant cacheTime = null;
|
private Instant cacheTime = null;
|
||||||
|
|
||||||
public ServerPinger(ClientProfile profile) {
|
public ServerPinger(ClientProfile profile) {
|
||||||
this.address = Objects.requireNonNull(profile.getServerSocketAddress(), "address");
|
this(profile.getDefaultServerProfile(), profile.getVersion());
|
||||||
this.version = Objects.requireNonNull(profile.getVersion(), "version");
|
}
|
||||||
|
public ServerPinger(ClientProfile.ServerProfile profile, ClientProfile.Version version)
|
||||||
|
{
|
||||||
|
if(profile == null)
|
||||||
|
{
|
||||||
|
throw new NullPointerException("ServerProfile null");
|
||||||
|
}
|
||||||
|
this.address = profile.toSocketAddress();
|
||||||
|
this.version = Objects.requireNonNull(version, "version");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String readUTF16String(HInput input) throws IOException {
|
private static String readUTF16String(HInput input) throws IOException {
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AuthRequestEvent extends RequestEvent {
|
public class AuthRequestEvent extends RequestEvent {
|
||||||
|
public static final String TWO_FACTOR_NEED_ERROR_MESSAGE = "auth.require2fa";
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
public ClientPermissions permissions;
|
public ClientPermissions permissions;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
package pro.gravit.launcher.hwid;
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public interface HWID {
|
|
||||||
|
|
||||||
int getLevel(); //Уровень доверия, насколько уникальные значения
|
|
||||||
|
|
||||||
int getAntiLevel(); //Уровень лживости, насколько фальшивые значения
|
|
||||||
|
|
||||||
int compare(HWID hwid);
|
|
||||||
|
|
||||||
boolean isNull();
|
|
||||||
|
|
||||||
void normalize();
|
|
||||||
}
|
|
|
@ -78,6 +78,10 @@ public static class ServerProfile
|
||||||
public String serverAddress;
|
public String serverAddress;
|
||||||
public int serverPort;
|
public int serverPort;
|
||||||
public boolean isDefault = true;
|
public boolean isDefault = true;
|
||||||
|
public InetSocketAddress toSocketAddress()
|
||||||
|
{
|
||||||
|
return InetSocketAddress.createUnresolved(serverAddress, serverPort);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private List<ServerProfile> servers = new ArrayList<>(1);
|
private List<ServerProfile> servers = new ArrayList<>(1);
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
|
|
||||||
import pro.gravit.launcher.LauncherNetworkAPI;
|
import pro.gravit.launcher.LauncherNetworkAPI;
|
||||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||||
import pro.gravit.launcher.hwid.HWID;
|
|
||||||
import pro.gravit.launcher.request.Request;
|
import pro.gravit.launcher.request.Request;
|
||||||
import pro.gravit.launcher.request.auth.password.AuthECPassword;
|
import pro.gravit.launcher.request.auth.password.*;
|
||||||
import pro.gravit.launcher.request.auth.password.AuthPlainPassword;
|
|
||||||
import pro.gravit.launcher.request.websockets.WebSocketRequest;
|
import pro.gravit.launcher.request.websockets.WebSocketRequest;
|
||||||
import pro.gravit.utils.ProviderMap;
|
import pro.gravit.utils.ProviderMap;
|
||||||
import pro.gravit.utils.helper.VerifyHelper;
|
import pro.gravit.utils.helper.VerifyHelper;
|
||||||
|
@ -23,8 +21,6 @@ public final class AuthRequest extends Request<AuthRequestEvent> implements WebS
|
||||||
private final boolean getSession;
|
private final boolean getSession;
|
||||||
@LauncherNetworkAPI
|
@LauncherNetworkAPI
|
||||||
private final ConnectTypes authType;
|
private final ConnectTypes authType;
|
||||||
@LauncherNetworkAPI
|
|
||||||
public boolean initProxy;
|
|
||||||
|
|
||||||
public AuthRequest(String login, byte[] password) {
|
public AuthRequest(String login, byte[] password) {
|
||||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
||||||
|
@ -43,15 +39,6 @@ public AuthRequest(String login, byte[] password, String auth_id) {
|
||||||
authType = ConnectTypes.CLIENT;
|
authType = ConnectTypes.CLIENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public AuthRequest(String login, byte[] password, HWID hwid, String auth_id) {
|
|
||||||
this.login = VerifyHelper.verify(login, VerifyHelper.NOT_EMPTY, "Login can't be empty");
|
|
||||||
this.password = new AuthECPassword(password.clone());
|
|
||||||
this.auth_id = auth_id;
|
|
||||||
getSession = true;
|
|
||||||
authType = ConnectTypes.CLIENT;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthRequest(String login, byte[] encryptedPassword, String auth_id, ConnectTypes authType) {
|
public AuthRequest(String login, byte[] encryptedPassword, String auth_id, ConnectTypes authType) {
|
||||||
this.login = login;
|
this.login = login;
|
||||||
this.password = new AuthECPassword(encryptedPassword.clone());
|
this.password = new AuthECPassword(encryptedPassword.clone());
|
||||||
|
@ -72,6 +59,9 @@ public static void registerProviders() {
|
||||||
if (!registerProviders) {
|
if (!registerProviders) {
|
||||||
providers.register("plain", AuthPlainPassword.class);
|
providers.register("plain", AuthPlainPassword.class);
|
||||||
providers.register("rsa", AuthECPassword.class);
|
providers.register("rsa", AuthECPassword.class);
|
||||||
|
providers.register("2fa", Auth2FAPassword.class);
|
||||||
|
providers.register("signature", AuthSignaturePassword.class);
|
||||||
|
providers.register("totp", AuthTOTPPassword.class);
|
||||||
registerProviders = true;
|
registerProviders = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package pro.gravit.launcher.request.auth.password;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||||
|
|
||||||
|
public class Auth2FAPassword implements AuthRequest.AuthPasswordInterface {
|
||||||
|
public AuthRequest.AuthPasswordInterface firstPassword;
|
||||||
|
public AuthRequest.AuthPasswordInterface secondPassword;
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return firstPassword != null && firstPassword.check() && secondPassword != null && secondPassword.check();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package pro.gravit.launcher.request.auth.password;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||||
|
|
||||||
|
public class AuthSignaturePassword implements AuthRequest.AuthPasswordInterface {
|
||||||
|
public byte[] signature;
|
||||||
|
public byte[] publicKey;
|
||||||
|
public byte[] salt;
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
package pro.gravit.launcher.request.auth.password;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||||
|
|
||||||
|
public class AuthTOTPPassword implements AuthRequest.AuthPasswordInterface {
|
||||||
|
public String totp;
|
||||||
|
@Override
|
||||||
|
public boolean check() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue