mirror of
https://github.com/exzork/GCAuth.git
synced 2024-11-24 00:23:58 +00:00
Update to 2.4.1 to support dev 1.2.3
This commit is contained in:
parent
de6438e063
commit
d85d5c088e
@ -10,15 +10,15 @@ sourceCompatibility = 17
|
|||||||
targetCompatibility = 17
|
targetCompatibility = 17
|
||||||
|
|
||||||
group 'me.exzork.gcauth'
|
group 'me.exzork.gcauth'
|
||||||
version '2.4.0'
|
version '2.4.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation files('lib/grasscutter-1.1.2-dev.jar')
|
implementation files('lib/grasscutter-1.2.3-dev.jar')
|
||||||
implementation 'org.springframework.security:spring-security-crypto:5.6.3'
|
implementation 'org.springframework.security:spring-security-crypto:5.7.1'
|
||||||
implementation 'commons-logging:commons-logging:1.2'
|
implementation 'commons-logging:commons-logging:1.2'
|
||||||
implementation 'com.auth0:java-jwt:3.19.2'
|
implementation 'com.auth0:java-jwt:3.19.2'
|
||||||
implementation 'javax.servlet:javax.servlet-api:4.0.1'
|
implementation 'javax.servlet:javax.servlet-api:4.0.1'
|
||||||
|
@ -1,2 +1 @@
|
|||||||
rootProject.name = 'GCAuth'
|
rootProject.name = 'GCAuth'
|
||||||
|
|
||||||
|
@ -5,9 +5,7 @@ import com.google.gson.GsonBuilder;
|
|||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.auth.DefaultAuthentication;
|
import emu.grasscutter.auth.DefaultAuthentication;
|
||||||
import emu.grasscutter.plugin.Plugin;
|
import emu.grasscutter.plugin.Plugin;
|
||||||
import static emu.grasscutter.Configuration.ACCOUNT;
|
|
||||||
|
|
||||||
import emu.grasscutter.plugin.PluginManager;
|
|
||||||
import me.exzork.gcauth.handler.*;
|
import me.exzork.gcauth.handler.*;
|
||||||
import me.exzork.gcauth.utils.Authentication;
|
import me.exzork.gcauth.utils.Authentication;
|
||||||
|
|
||||||
@ -17,6 +15,8 @@ import java.io.FileWriter;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
|
||||||
|
import static emu.grasscutter.config.Configuration.ACCOUNT;
|
||||||
|
|
||||||
|
|
||||||
public class GCAuth extends Plugin {
|
public class GCAuth extends Plugin {
|
||||||
private static Config config;
|
private static Config config;
|
||||||
|
@ -8,7 +8,7 @@ import emu.grasscutter.server.http.objects.LoginResultJson;
|
|||||||
import me.exzork.gcauth.utils.Authentication;
|
import me.exzork.gcauth.utils.Authentication;
|
||||||
|
|
||||||
public class GCAuthAuthenticationHandler implements AuthenticationSystem {
|
public class GCAuthAuthenticationHandler implements AuthenticationSystem {
|
||||||
private final Authenticator<LoginResultJson> gcAuthAuthenticator = new GCAuthenticators.GCAuthAuthenticator();
|
private final Authenticator<LoginResultJson> gcAuthAuthenticator = new GCAuthenticators.GCAuthAuthenticator();;
|
||||||
private final Authenticator<LoginResultJson> tokenAuthenticator = new DefaultAuthenticators.TokenAuthenticator();
|
private final Authenticator<LoginResultJson> tokenAuthenticator = new DefaultAuthenticators.TokenAuthenticator();
|
||||||
private final Authenticator<ComboTokenResJson> sessionKeyAuthenticator = new DefaultAuthenticators.SessionKeyAuthenticator();
|
private final Authenticator<ComboTokenResJson> sessionKeyAuthenticator = new DefaultAuthenticators.SessionKeyAuthenticator();
|
||||||
private final GCAuthExternalAuthenticator externalAuthenticator = new GCAuthExternalAuthenticator();
|
private final GCAuthExternalAuthenticator externalAuthenticator = new GCAuthExternalAuthenticator();
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
package me.exzork.gcauth.handler;
|
package me.exzork.gcauth.handler;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.mchange.v1.util.ArrayUtils;
|
|
||||||
import emu.grasscutter.Grasscutter;
|
|
||||||
import emu.grasscutter.auth.AuthenticationSystem;
|
import emu.grasscutter.auth.AuthenticationSystem;
|
||||||
import emu.grasscutter.auth.ExternalAuthenticator;
|
import emu.grasscutter.auth.ExternalAuthenticator;
|
||||||
import emu.grasscutter.database.DatabaseHelper;
|
import emu.grasscutter.database.DatabaseHelper;
|
||||||
import emu.grasscutter.game.Account;
|
import emu.grasscutter.game.Account;
|
||||||
import express.http.Response;
|
import express.http.Response;
|
||||||
import io.javalin.http.Context;
|
|
||||||
import io.javalin.http.util.RateLimit;
|
import io.javalin.http.util.RateLimit;
|
||||||
import me.exzork.gcauth.GCAuth;
|
import me.exzork.gcauth.GCAuth;
|
||||||
import me.exzork.gcauth.json.AuthResponseJson;
|
import me.exzork.gcauth.json.AuthResponseJson;
|
||||||
@ -18,12 +15,11 @@ import me.exzork.gcauth.json.RegisterAccount;
|
|||||||
import me.exzork.gcauth.utils.Authentication;
|
import me.exzork.gcauth.utils.Authentication;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
public class GCAuthExternalAuthenticator implements ExternalAuthenticator {
|
public class GCAuthExternalAuthenticator implements ExternalAuthenticator {
|
||||||
private String[] endPoints = GCAuth.getInstance().getConfig().rateLimit.endPoints;
|
private final String[] endPoints = GCAuth.getInstance().getConfig().rateLimit.endPoints;
|
||||||
private int maxRequests = GCAuth.getInstance().getConfig().rateLimit.maxRequests;
|
private final int maxRequests = GCAuth.getInstance().getConfig().rateLimit.maxRequests;
|
||||||
private String timeUnit = GCAuth.getInstance().getConfig().rateLimit.timeUnit;
|
private final String timeUnit = GCAuth.getInstance().getConfig().rateLimit.timeUnit;
|
||||||
@Override
|
@Override
|
||||||
public void handleLogin(AuthenticationSystem.AuthenticationRequest authenticationRequest) {
|
public void handleLogin(AuthenticationSystem.AuthenticationRequest authenticationRequest) {
|
||||||
AuthResponseJson authResponse = new AuthResponseJson();
|
AuthResponseJson authResponse = new AuthResponseJson();
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package me.exzork.gcauth.handler;
|
package me.exzork.gcauth.handler;
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
|
||||||
import emu.grasscutter.auth.AuthenticationSystem;
|
import emu.grasscutter.auth.AuthenticationSystem;
|
||||||
import emu.grasscutter.auth.Authenticator;
|
import emu.grasscutter.auth.Authenticator;
|
||||||
import emu.grasscutter.game.Account;
|
import emu.grasscutter.game.Account;
|
||||||
@ -11,7 +10,6 @@ import me.exzork.gcauth.utils.Authentication;
|
|||||||
public class GCAuthenticators {
|
public class GCAuthenticators {
|
||||||
|
|
||||||
public static class GCAuthAuthenticator implements Authenticator<LoginResultJson> {
|
public static class GCAuthAuthenticator implements Authenticator<LoginResultJson> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginResultJson authenticate(AuthenticationSystem.AuthenticationRequest authenticationRequest) {
|
public LoginResultJson authenticate(AuthenticationSystem.AuthenticationRequest authenticationRequest) {
|
||||||
var response = new LoginResultJson();
|
var response = new LoginResultJson();
|
||||||
|
@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
public final class Authentication {
|
public final class Authentication {
|
||||||
public static final HashMap<String, String> otps = new HashMap<>();
|
public static final HashMap<String, String> otps = new HashMap<>();
|
||||||
private static Algorithm key = Algorithm.HMAC256(generateRandomNumber(32));
|
private static final Algorithm key = Algorithm.HMAC256(generateRandomNumber(32));
|
||||||
public static Algorithm getKey() {
|
public static Algorithm getKey() {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
@ -119,7 +119,6 @@ public final class Authentication {
|
|||||||
public static TimeUnit getTimeUnit(String timeUnit) {
|
public static TimeUnit getTimeUnit(String timeUnit) {
|
||||||
return switch (timeUnit.toLowerCase()) {
|
return switch (timeUnit.toLowerCase()) {
|
||||||
case "seconds" -> TimeUnit.SECONDS;
|
case "seconds" -> TimeUnit.SECONDS;
|
||||||
case "minutes" -> TimeUnit.MINUTES;
|
|
||||||
case "hours" -> TimeUnit.HOURS;
|
case "hours" -> TimeUnit.HOURS;
|
||||||
case "days" -> TimeUnit.DAYS;
|
case "days" -> TimeUnit.DAYS;
|
||||||
default -> TimeUnit.MINUTES;
|
default -> TimeUnit.MINUTES;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "GCAuth",
|
"name": "GCAuth",
|
||||||
"description": "GCAuth is a plugin that allows you to implement authentication for your server.",
|
"description": "GCAuth is a plugin that allows you to implement authentication for your server.",
|
||||||
"version": "2.2.0",
|
"version": "2.4.1",
|
||||||
"author": ["ExZork"],
|
"author": ["ExZork"],
|
||||||
"mainClass": "me.exzork.gcauth.GCAuth"
|
"mainClass": "me.exzork.gcauth.GCAuth"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user