mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-04-16 05:01:44 +03:00
commit
935ecfbeec
2 changed files with 10 additions and 3 deletions
|
@ -553,7 +553,7 @@ private void generateConfigIfNotExists() throws IOException {
|
||||||
newConfig.authProvider = new AuthProvider[]{new RejectAuthProvider("Настройте authProvider")};
|
newConfig.authProvider = new AuthProvider[]{new RejectAuthProvider("Настройте authProvider")};
|
||||||
newConfig.textureProvider = new RequestTextureProvider("http://example.com/skins/%username%.png","http://example.com/cloaks/%username%.png");
|
newConfig.textureProvider = new RequestTextureProvider("http://example.com/skins/%username%.png","http://example.com/cloaks/%username%.png");
|
||||||
newConfig.permissionsHandler = new JsonFilePermissionsHandler();
|
newConfig.permissionsHandler = new JsonFilePermissionsHandler();
|
||||||
newConfig.port = 7420;
|
newConfig.port = 7240;
|
||||||
newConfig.bindAddress = "0.0.0.0";
|
newConfig.bindAddress = "0.0.0.0";
|
||||||
newConfig.authRejectString = "Превышен лимит авторизаций";
|
newConfig.authRejectString = "Превышен лимит авторизаций";
|
||||||
newConfig.binaryName = "Launcher";
|
newConfig.binaryName = "Launcher";
|
||||||
|
|
|
@ -12,15 +12,22 @@
|
||||||
|
|
||||||
public final class RequestAuthProvider extends AuthProvider {
|
public final class RequestAuthProvider extends AuthProvider {
|
||||||
private String url;
|
private String url;
|
||||||
private Pattern response;
|
private transient Pattern pattern;
|
||||||
|
private String response;
|
||||||
private boolean usePermission;
|
private boolean usePermission;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
pattern = Pattern.compile(response);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AuthProviderResult auth(String login, String password, String ip) throws IOException {
|
public AuthProviderResult auth(String login, String password, String ip) throws IOException {
|
||||||
String currentResponse = IOHelper.request(new URL(getFormattedURL(login, password, ip)));
|
String currentResponse = IOHelper.request(new URL(getFormattedURL(login, password, ip)));
|
||||||
|
|
||||||
// Match username
|
// Match username
|
||||||
Matcher matcher = response.matcher(currentResponse);
|
Matcher matcher = pattern.matcher(currentResponse);
|
||||||
return matcher.matches() && matcher.groupCount() >= 1 ?
|
return matcher.matches() && matcher.groupCount() >= 1 ?
|
||||||
new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.getLong(matcher.group("permission"))) : new ClientPermissions()) :
|
new AuthProviderResult(matcher.group("username"), SecurityHelper.randomStringToken(), usePermission ? new ClientPermissions(Long.getLong(matcher.group("permission"))) : new ClientPermissions()) :
|
||||||
authError(currentResponse);
|
authError(currentResponse);
|
||||||
|
|
Loading…
Reference in a new issue