mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
Привилегии
This commit is contained in:
parent
b60bdb72fa
commit
79acc5b503
5 changed files with 27 additions and 0 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,21 @@
|
||||||
package ru.gravit.launchserver.auth.provider;
|
package ru.gravit.launchserver.auth.provider;
|
||||||
|
|
||||||
|
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||||
|
|
||||||
|
|
||||||
public class AuthProviderResult {
|
public class AuthProviderResult {
|
||||||
public final String username;
|
public final String username;
|
||||||
public final String accessToken;
|
public final String accessToken;
|
||||||
|
public final ClientPermissions permissions;
|
||||||
|
|
||||||
public AuthProviderResult(String username, String accessToken) {
|
public AuthProviderResult(String username, String accessToken) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.accessToken = accessToken;
|
this.accessToken = accessToken;
|
||||||
|
permissions = ClientPermissions.DEFAULT;
|
||||||
|
}
|
||||||
|
public AuthProviderResult(String username, String accessToken,ClientPermissions permissions) {
|
||||||
|
this.username = username;
|
||||||
|
this.accessToken = accessToken;
|
||||||
|
this.permissions = permissions;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,7 @@ public void reply() throws Exception {
|
||||||
}
|
}
|
||||||
debug("Auth: '%s' -> '%s', '%s'", login, result.username, result.accessToken);
|
debug("Auth: '%s' -> '%s', '%s'", login, result.username, result.accessToken);
|
||||||
clientData.isAuth = true;
|
clientData.isAuth = true;
|
||||||
|
clientData.permissions = result.permissions;
|
||||||
// Authenticate on server (and get UUID)
|
// Authenticate on server (and get UUID)
|
||||||
UUID uuid;
|
UUID uuid;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package ru.gravit.launchserver.socket;
|
package ru.gravit.launchserver.socket;
|
||||||
|
|
||||||
import ru.gravit.launcher.profiles.ClientProfile;
|
import ru.gravit.launcher.profiles.ClientProfile;
|
||||||
|
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||||
|
|
||||||
public class Client {
|
public class Client {
|
||||||
public long session;
|
public long session;
|
||||||
|
@ -9,12 +10,14 @@ public class Client {
|
||||||
public Type type;
|
public Type type;
|
||||||
public ClientProfile profile;
|
public ClientProfile profile;
|
||||||
public boolean isAuth;
|
public boolean isAuth;
|
||||||
|
public ClientPermissions permissions;
|
||||||
|
|
||||||
public Client(long session) {
|
public Client(long session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
timestamp = System.currentTimeMillis();
|
timestamp = System.currentTimeMillis();
|
||||||
type = Type.USER;
|
type = Type.USER;
|
||||||
isAuth = false;
|
isAuth = false;
|
||||||
|
permissions = ClientPermissions.DEFAULT;
|
||||||
}
|
}
|
||||||
//Данные ваторизации
|
//Данные ваторизации
|
||||||
public void up() {
|
public void up() {
|
||||||
|
|
|
@ -65,6 +65,7 @@ public void execute(WebSocketService service, ChannelHandlerContext ctx, Client
|
||||||
}
|
}
|
||||||
LaunchServer.server.config.hwidHandler.check(hwid, result.username);
|
LaunchServer.server.config.hwidHandler.check(hwid, result.username);
|
||||||
clientData.isAuth = true;
|
clientData.isAuth = true;
|
||||||
|
clientData.permissions = result.permissions;
|
||||||
service.sendObject(ctx,new WebSocketService.SuccessResult("auth"));
|
service.sendObject(ctx,new WebSocketService.SuccessResult("auth"));
|
||||||
} catch (AuthException | HWIDException e)
|
} catch (AuthException | HWIDException e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue