mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 16:41:46 +03:00
[FEATURE] AuthSupportRemoteClientAccess
This commit is contained in:
parent
36d97e7f8b
commit
6fb9174681
4 changed files with 43 additions and 3 deletions
|
@ -13,6 +13,7 @@
|
|||
import pro.gravit.launchserver.auth.AuthException;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.UserHardware;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportHardware;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportRemoteClientAccess;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportHardware;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportProperties;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.user.UserSupportTextures;
|
||||
|
@ -25,7 +26,7 @@
|
|||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class HttpAuthCoreProvider extends AuthCoreProvider implements AuthSupportHardware {
|
||||
public class HttpAuthCoreProvider extends AuthCoreProvider implements AuthSupportHardware, AuthSupportRemoteClientAccess {
|
||||
private transient final Logger logger = LogManager.getLogger();
|
||||
private transient HttpRequester requester;
|
||||
public String bearerToken;
|
||||
|
@ -49,6 +50,8 @@ public class HttpAuthCoreProvider extends AuthCoreProvider implements AuthSuppor
|
|||
public String getUsersByHardwareInfoUrl;
|
||||
public String banHardwareUrl;
|
||||
public String unbanHardwareUrl;
|
||||
public String apiUrl;
|
||||
public List<String> apiFeatures;
|
||||
|
||||
@Override
|
||||
public User getUserByUsername(String username) {
|
||||
|
@ -267,6 +270,16 @@ public void unbanHardware(UserHardware hardware) {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClientApiUrl() {
|
||||
return apiUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getClientApiFeatures() {
|
||||
return apiFeatures;
|
||||
}
|
||||
|
||||
public record HttpAuthReport(String minecraftAccessToken, String oauthAccessToken,
|
||||
String oauthRefreshToken, long oauthExpire,
|
||||
HttpUserSession session) {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package pro.gravit.launchserver.auth.core.interfaces.provider;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AuthSupportRemoteClientAccess {
|
||||
String getClientApiUrl();
|
||||
List<String> getClientApiFeatures();
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
import io.netty.channel.ChannelHandlerContext;
|
||||
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||
import pro.gravit.launchserver.auth.core.interfaces.provider.AuthSupportRemoteClientAccess;
|
||||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.response.SimpleResponse;
|
||||
|
||||
|
@ -19,8 +20,14 @@ public String getType() {
|
|||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>();
|
||||
for (AuthProviderPair pair : server.config.auth.values()) {
|
||||
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName,
|
||||
pair.core.getDetails(client)));
|
||||
var rca = pair.isSupport(AuthSupportRemoteClientAccess.class);
|
||||
if(rca != null) {
|
||||
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName,
|
||||
pair.core.getDetails(client), rca.getClientApiUrl(), rca.getClientApiFeatures()));
|
||||
} else {
|
||||
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName,
|
||||
pair.core.getDetails(client)));
|
||||
}
|
||||
}
|
||||
sendResult(new GetAvailabilityAuthRequestEvent(list));
|
||||
}
|
||||
|
|
|
@ -45,11 +45,23 @@ public static class AuthAvailability {
|
|||
public String name;
|
||||
@LauncherNetworkAPI
|
||||
public String displayName;
|
||||
@LauncherNetworkAPI
|
||||
public String apiUrl;
|
||||
@LauncherNetworkAPI
|
||||
public List<String> apiFeatures;
|
||||
|
||||
public AuthAvailability(String name, String displayName, List<AuthAvailabilityDetails> details) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public AuthAvailability(String name, String displayName, List<AuthAvailabilityDetails> details, String apiUrl, List<String> apiFeatures) {
|
||||
this.details = details;
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.apiUrl = apiUrl;
|
||||
this.apiFeatures = apiFeatures;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue