diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/ClientPermissions.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/ClientPermissions.java new file mode 100644 index 00000000..974daf9b --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/ClientPermissions.java @@ -0,0 +1,12 @@ +package ru.gravit.launchserver.auth; + +public class ClientPermissions { + public static final ClientPermissions DEFAULT = new ClientPermissions(); + public boolean canAdmin; + public boolean canServer; + + public ClientPermissions() { + canAdmin = false; + canServer = false; + } +} diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProviderResult.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProviderResult.java index 444046cb..c8ab2d60 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProviderResult.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/provider/AuthProviderResult.java @@ -1,11 +1,21 @@ package ru.gravit.launchserver.auth.provider; +import ru.gravit.launchserver.auth.ClientPermissions; + + public class AuthProviderResult { public final String username; public final String accessToken; + public final ClientPermissions permissions; public AuthProviderResult(String username, String accessToken) { this.username = username; this.accessToken = accessToken; + permissions = ClientPermissions.DEFAULT; + } + public AuthProviderResult(String username, String accessToken,ClientPermissions permissions) { + this.username = username; + this.accessToken = accessToken; + this.permissions = permissions; } } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java index 52a8b2c8..37e6a74a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/response/auth/AuthResponse.java @@ -96,6 +96,7 @@ public void reply() throws Exception { } debug("Auth: '%s' -> '%s', '%s'", login, result.username, result.accessToken); clientData.isAuth = true; + clientData.permissions = result.permissions; // Authenticate on server (and get UUID) UUID uuid; try { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/Client.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/Client.java index f49919c9..de41fa88 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/Client.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/Client.java @@ -1,6 +1,7 @@ package ru.gravit.launchserver.socket; import ru.gravit.launcher.profiles.ClientProfile; +import ru.gravit.launchserver.auth.ClientPermissions; public class Client { public long session; @@ -9,12 +10,14 @@ public class Client { public Type type; public ClientProfile profile; public boolean isAuth; + public ClientPermissions permissions; public Client(long session) { this.session = session; timestamp = System.currentTimeMillis(); type = Type.USER; isAuth = false; + permissions = ClientPermissions.DEFAULT; } //Данные ваторизации public void up() { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java index 9469acba..76ea0089 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/socket/websocket/json/auth/AuthResponse.java @@ -65,6 +65,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client } LaunchServer.server.config.hwidHandler.check(hwid, result.username); clientData.isAuth = true; + clientData.permissions = result.permissions; service.sendObject(ctx,new WebSocketService.SuccessResult("auth")); } catch (AuthException | HWIDException e) {