From 79acc5b50341d90e7b33d658cfd5b72d24eb486f Mon Sep 17 00:00:00 2001 From: Gravit Date: Mon, 1 Oct 2018 17:08:16 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B8=D0=B2=D0=B8=D0=BB=D0=B5?= =?UTF-8?q?=D0=B3=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gravit/launchserver/auth/ClientPermissions.java | 12 ++++++++++++ .../auth/provider/AuthProviderResult.java | 10 ++++++++++ .../launchserver/response/auth/AuthResponse.java | 1 + .../java/ru/gravit/launchserver/socket/Client.java | 3 +++ .../socket/websocket/json/auth/AuthResponse.java | 1 + 5 files changed, 27 insertions(+) create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/auth/ClientPermissions.java 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) {