mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-22 08:31:07 +03:00
[FEATURE] Support auth features in API
This commit is contained in:
parent
e12f2ef897
commit
aff254a875
6 changed files with 19 additions and 26 deletions
|
@ -38,6 +38,10 @@ public static Set<String> getFeatures(Class<?> clazz) {
|
|||
return list;
|
||||
}
|
||||
|
||||
public Set<String> getFeatures() {
|
||||
return features;
|
||||
}
|
||||
|
||||
public static void getFeatures(Class<?> clazz, Set<String> list) {
|
||||
Features features = clazz.getAnnotation(Features.class);
|
||||
if (features != null) {
|
||||
|
@ -73,13 +77,14 @@ public final void init(LaunchServer srv, String name) {
|
|||
this.name = name;
|
||||
if (links != null) link(srv);
|
||||
core.init(srv);
|
||||
features = new HashSet<>();
|
||||
getFeatures(core.getClass(), features);
|
||||
if(mixes != null) {
|
||||
for(var m : mixes.values()) {
|
||||
m.init(srv, core);
|
||||
getFeatures(m.getClass(), features);
|
||||
}
|
||||
}
|
||||
features = new HashSet<>();
|
||||
getFeatures(core.getClass(), features);
|
||||
}
|
||||
|
||||
public final void link(LaunchServer srv) {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package pro.gravit.launchserver.auth.core.interfaces.provider;
|
||||
|
||||
import pro.gravit.launcher.events.request.AuthRequestEvent;
|
||||
import pro.gravit.launcher.events.request.GetAssetUploadInfoRequestEvent;
|
||||
import pro.gravit.launchserver.auth.Feature;
|
||||
import pro.gravit.launchserver.auth.core.User;
|
||||
|
||||
@Feature("assetupload")
|
||||
@Feature(GetAssetUploadInfoRequestEvent.FEATURE_NAME)
|
||||
public interface AuthSupportAssetUpload {
|
||||
String getAssetUploadUrl(String name, User user);
|
||||
|
||||
|
|
|
@ -20,14 +20,8 @@ public String getType() {
|
|||
public void execute(ChannelHandlerContext ctx, Client client) {
|
||||
List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>();
|
||||
for (AuthProviderPair pair : server.config.auth.values()) {
|
||||
var rca = pair.isSupport(AuthSupportRemoteClientAccess.class);
|
||||
if (rca != null) {
|
||||
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName,
|
||||
pair.visible, pair.core.getDetails(client), rca.getClientApiUrl(), rca.getClientApiFeatures()));
|
||||
} else {
|
||||
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName,
|
||||
pair.visible, pair.core.getDetails(client)));
|
||||
}
|
||||
list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.core.getDetails(client), pair.name, pair.displayName,
|
||||
pair.visible, pair.getFeatures()));
|
||||
}
|
||||
sendResult(new GetAvailabilityAuthRequestEvent(list));
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import pro.gravit.launcher.events.RequestEvent;
|
||||
|
||||
public class GetAssetUploadInfoRequestEvent extends RequestEvent {
|
||||
public static final String FEATURE_NAME = "assetupload";
|
||||
public String url;
|
||||
public AuthRequestEvent.OAuthRequestEvent token;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import pro.gravit.utils.TypeSerializeInterface;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class GetAvailabilityAuthRequestEvent extends RequestEvent {
|
||||
@LauncherNetworkAPI
|
||||
|
@ -49,24 +50,14 @@ public static class AuthAvailability {
|
|||
@LauncherNetworkAPI
|
||||
public boolean visible;
|
||||
@LauncherNetworkAPI
|
||||
public String apiUrl;
|
||||
@LauncherNetworkAPI
|
||||
public List<String> apiFeatures;
|
||||
public Set<String> features;
|
||||
|
||||
public AuthAvailability(String name, String displayName, boolean visible, List<AuthAvailabilityDetails> details) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.visible = visible;
|
||||
this.details = details;
|
||||
}
|
||||
|
||||
public AuthAvailability(String name, String displayName, boolean visible, List<AuthAvailabilityDetails> details, String apiUrl, List<String> apiFeatures) {
|
||||
this.visible = visible;
|
||||
public AuthAvailability(List<AuthAvailabilityDetails> details, String name, String displayName, boolean visible, Set<String> features) {
|
||||
this.details = details;
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.apiUrl = apiUrl;
|
||||
this.apiFeatures = apiFeatures;
|
||||
this.visible = visible;
|
||||
this.features = features;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientLauncherMethods {
|
||||
|
@ -123,7 +124,7 @@ public static void applyBasicOfflineProcessors(OfflineRequestService service) {
|
|||
service.registerRequestProcessor(GetAvailabilityAuthRequest.class, (r) -> {
|
||||
List<GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails> details = new ArrayList<>();
|
||||
details.add(new AuthLoginOnlyDetails());
|
||||
GetAvailabilityAuthRequestEvent.AuthAvailability authAvailability = new GetAvailabilityAuthRequestEvent.AuthAvailability("offline", "Offline Mode", true, details);
|
||||
GetAvailabilityAuthRequestEvent.AuthAvailability authAvailability = new GetAvailabilityAuthRequestEvent.AuthAvailability(details, "offline", "Offline Mode", true, new HashSet<>());
|
||||
List<GetAvailabilityAuthRequestEvent.AuthAvailability> list = new ArrayList<>(1);
|
||||
list.add(authAvailability);
|
||||
return new GetAvailabilityAuthRequestEvent(list);
|
||||
|
|
Loading…
Reference in a new issue