Merge pull request #25 from omg-xtao/fix

Update to 2.4.1 to support dev 1.2.3
This commit is contained in:
Muhammad Eko Prasetyo 2022-07-28 01:02:41 +07:00 committed by GitHub
commit 4666a9e564
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 18 deletions

View File

@ -10,15 +10,15 @@ sourceCompatibility = 17
targetCompatibility = 17
group 'me.exzork.gcauth'
version '2.4.0'
version '2.5.0'
repositories {
mavenCentral()
}
dependencies {
implementation files('lib/grasscutter-1.1.2-dev.jar')
implementation 'org.springframework.security:spring-security-crypto:5.6.3'
implementation files('lib/grasscutter-1.2.3-dev.jar')
implementation 'org.springframework.security:spring-security-crypto:5.7.1'
implementation 'commons-logging:commons-logging:1.2'
implementation 'com.auth0:java-jwt:3.19.2'
implementation 'javax.servlet:javax.servlet-api:4.0.1'

View File

@ -1,2 +1 @@
rootProject.name = 'GCAuth'

View File

@ -5,9 +5,7 @@ import com.google.gson.GsonBuilder;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.auth.DefaultAuthentication;
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.utils.Authentication;
@ -17,6 +15,8 @@ import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import static emu.grasscutter.config.Configuration.ACCOUNT;
public class GCAuth extends Plugin {
private static Config config;

View File

@ -1,14 +1,11 @@
package me.exzork.gcauth.handler;
import com.google.gson.Gson;
import com.mchange.v1.util.ArrayUtils;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.auth.AuthenticationSystem;
import emu.grasscutter.auth.ExternalAuthenticator;
import emu.grasscutter.database.DatabaseHelper;
import emu.grasscutter.game.Account;
import express.http.Response;
import io.javalin.http.Context;
import io.javalin.http.util.RateLimit;
import me.exzork.gcauth.GCAuth;
import me.exzork.gcauth.json.AuthResponseJson;
@ -18,12 +15,11 @@ import me.exzork.gcauth.json.RegisterAccount;
import me.exzork.gcauth.utils.Authentication;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
public class GCAuthExternalAuthenticator implements ExternalAuthenticator {
private String[] endPoints = GCAuth.getInstance().getConfig().rateLimit.endPoints;
private int maxRequests = GCAuth.getInstance().getConfig().rateLimit.maxRequests;
private String timeUnit = GCAuth.getInstance().getConfig().rateLimit.timeUnit;
private final String[] endPoints = GCAuth.getInstance().getConfig().rateLimit.endPoints;
private final int maxRequests = GCAuth.getInstance().getConfig().rateLimit.maxRequests;
private final String timeUnit = GCAuth.getInstance().getConfig().rateLimit.timeUnit;
@Override
public void handleLogin(AuthenticationSystem.AuthenticationRequest authenticationRequest) {
AuthResponseJson authResponse = new AuthResponseJson();

View File

@ -1,6 +1,5 @@
package me.exzork.gcauth.handler;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.auth.AuthenticationSystem;
import emu.grasscutter.auth.Authenticator;
import emu.grasscutter.game.Account;
@ -11,7 +10,6 @@ import me.exzork.gcauth.utils.Authentication;
public class GCAuthenticators {
public static class GCAuthAuthenticator implements Authenticator<LoginResultJson> {
@Override
public LoginResultJson authenticate(AuthenticationSystem.AuthenticationRequest authenticationRequest) {
var response = new LoginResultJson();

View File

@ -17,7 +17,7 @@ import java.util.concurrent.TimeUnit;
public final class Authentication {
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() {
return key;
}
@ -119,7 +119,6 @@ public final class Authentication {
public static TimeUnit getTimeUnit(String timeUnit) {
return switch (timeUnit.toLowerCase()) {
case "seconds" -> TimeUnit.SECONDS;
case "minutes" -> TimeUnit.MINUTES;
case "hours" -> TimeUnit.HOURS;
case "days" -> TimeUnit.DAYS;
default -> TimeUnit.MINUTES;

View File

@ -1,7 +1,7 @@
{
"name": "GCAuth",
"description": "GCAuth is a plugin that allows you to implement authentication for your server.",
"version": "2.2.0",
"version": "2.5.0",
"author": ["ExZork"],
"mainClass": "me.exzork.gcauth.GCAuth"
}