mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] Поддержка 2FA и необычных способах авторизации
This commit is contained in:
parent
ede1749f58
commit
e081bf5a76
3 changed files with 33 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
package pro.gravit.launchserver.auth.provider;
|
||||
|
||||
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
||||
import pro.gravit.launcher.request.auth.AuthRequest;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.auth.AuthException;
|
||||
|
@ -12,6 +13,13 @@ public abstract class AuthProvider implements AutoCloseable {
|
|||
private static boolean registredProv = false;
|
||||
protected transient LaunchServer srv = null;
|
||||
|
||||
public GetAvailabilityAuthRequestEvent.AuthAvailability.AuthType getFirstAuthType() {
|
||||
return GetAvailabilityAuthRequestEvent.AuthAvailability.AuthType.PASSWORD;
|
||||
}
|
||||
public GetAvailabilityAuthRequestEvent.AuthAvailability.AuthType getSecondAuthType() {
|
||||
return GetAvailabilityAuthRequestEvent.AuthAvailability.AuthType.NONE;
|
||||
}
|
||||
|
||||
public static AuthProviderResult authError(String message) throws AuthException {
|
||||
throw new AuthException(message);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ public String getType() {
|
|||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>();
|
||||
for (AuthProviderPair pair : server.config.auth) {
|
||||
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName));
|
||||
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName, pair.provider.getFirstAuthType(), pair.provider.getSecondAuthType()));
|
||||
}
|
||||
sendResult(new GetAvailabilityAuthRequestEvent(list));
|
||||
}
|
||||
|
|
|
@ -11,10 +11,33 @@ public static class AuthAvailability {
|
|||
public final String name;
|
||||
@LauncherNetworkAPI
|
||||
public final String displayName;
|
||||
@LauncherNetworkAPI
|
||||
public final AuthType firstType;
|
||||
@LauncherNetworkAPI
|
||||
public final AuthType secondType;
|
||||
|
||||
public AuthAvailability(String name, String displayName) {
|
||||
public AuthAvailability(String name, String displayName, AuthType firstType, AuthType secondType) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.firstType = firstType;
|
||||
this.secondType = secondType;
|
||||
}
|
||||
|
||||
|
||||
public enum AuthType
|
||||
{
|
||||
@LauncherNetworkAPI
|
||||
PASSWORD,
|
||||
@LauncherNetworkAPI
|
||||
KEY,
|
||||
@LauncherNetworkAPI
|
||||
TOTP,
|
||||
@LauncherNetworkAPI
|
||||
OAUTH,
|
||||
@LauncherNetworkAPI
|
||||
NONE,
|
||||
@LauncherNetworkAPI
|
||||
OTHER
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue