Привилегии

This commit is contained in:
Gravit 2018-10-01 17:08:16 +07:00
parent b60bdb72fa
commit 79acc5b503
5 changed files with 27 additions and 0 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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 {

View file

@ -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() {

View file

@ -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)
{