diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java index 27d9c5de..b204d2ab 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/HttpAuthCoreProvider.java @@ -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 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 getClientApiFeatures() { + return apiFeatures; + } + public record HttpAuthReport(String minecraftAccessToken, String oauthAccessToken, String oauthRefreshToken, long oauthExpire, HttpUserSession session) { diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/interfaces/provider/AuthSupportRemoteClientAccess.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/interfaces/provider/AuthSupportRemoteClientAccess.java new file mode 100644 index 00000000..5b5b0b64 --- /dev/null +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/core/interfaces/provider/AuthSupportRemoteClientAccess.java @@ -0,0 +1,8 @@ +package pro.gravit.launchserver.auth.core.interfaces.provider; + +import java.util.List; + +public interface AuthSupportRemoteClientAccess { + String getClientApiUrl(); + List getClientApiFeatures(); +} diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java index 25f0007d..c89f29aa 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java @@ -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 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)); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java index 930ec3f9..3a81326c 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java @@ -45,11 +45,23 @@ public static class AuthAvailability { public String name; @LauncherNetworkAPI public String displayName; + @LauncherNetworkAPI + public String apiUrl; + @LauncherNetworkAPI + public List apiFeatures; public AuthAvailability(String name, String displayName, List details) { this.name = name; this.displayName = displayName; this.details = details; } + + public AuthAvailability(String name, String displayName, List details, String apiUrl, List apiFeatures) { + this.details = details; + this.name = name; + this.displayName = displayName; + this.apiUrl = apiUrl; + this.apiFeatures = apiFeatures; + } } }