[FIX] UTC Timezone

This commit is contained in:
Gravita 2022-03-18 19:50:46 +07:00
parent dd3fd101f4
commit 736bf51eaa
2 changed files with 6 additions and 4 deletions

View file

@ -24,6 +24,7 @@
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.sql.*; import java.sql.*;
import java.time.Clock;
import java.time.Duration; import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Base64; import java.util.Base64;
@ -133,7 +134,7 @@ public AuthManager.AuthReport refreshAccessToken(String refreshToken, AuthRespon
if(!token.equals(realToken)) { if(!token.equals(realToken)) {
return null; return null;
} }
var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(user, LocalDateTime.now().plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey); var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(user, LocalDateTime.now(Clock.systemUTC()).plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey);
return new AuthManager.AuthReport(null, accessToken, refreshToken, expireSeconds * 1000L, new MySQLUserSession(user)); return new AuthManager.AuthReport(null, accessToken, refreshToken, expireSeconds * 1000L, new MySQLUserSession(user));
} }
@ -153,7 +154,7 @@ public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext c
} }
} }
MySQLUserSession session = new MySQLUserSession(mySQLUser); MySQLUserSession session = new MySQLUserSession(mySQLUser);
var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(mySQLUser, LocalDateTime.now().plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey); var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(mySQLUser, LocalDateTime.now(Clock.systemUTC()).plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey);
var refreshToken = LegacySessionHelper.makeRefreshTokenFromPassword(mySQLUser.username, mySQLUser.password, server.keyAgreementManager.legacySalt); var refreshToken = LegacySessionHelper.makeRefreshTokenFromPassword(mySQLUser.username, mySQLUser.password, server.keyAgreementManager.legacySalt);
if (minecraftAccess) { if (minecraftAccess) {
String minecraftAccessToken = SecurityHelper.randomStringToken(); String minecraftAccessToken = SecurityHelper.randomStringToken();

View file

@ -19,6 +19,7 @@
import java.io.IOException; import java.io.IOException;
import java.sql.*; import java.sql.*;
import java.time.Clock;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.UUID; import java.util.UUID;
@ -111,7 +112,7 @@ public AuthManager.AuthReport refreshAccessToken(String refreshToken, AuthRespon
if(!token.equals(realToken)) { if(!token.equals(realToken)) {
return null; return null;
} }
var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(user, LocalDateTime.now().plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey); var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(user, LocalDateTime.now(Clock.systemUTC()).plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey);
return new AuthManager.AuthReport(null, accessToken, refreshToken, expireSeconds * 1000L, new PostgresSQLCoreProvider.MySQLUserSession(user)); return new AuthManager.AuthReport(null, accessToken, refreshToken, expireSeconds * 1000L, new PostgresSQLCoreProvider.MySQLUserSession(user));
} }
@ -131,7 +132,7 @@ public AuthManager.AuthReport authorize(String login, AuthResponse.AuthContext c
} }
} }
MySQLUserSession session = new MySQLUserSession(postgresSQLUser); MySQLUserSession session = new MySQLUserSession(postgresSQLUser);
var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(postgresSQLUser, LocalDateTime.now().plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey); var accessToken = LegacySessionHelper.makeAccessJwtTokenFromString(postgresSQLUser, LocalDateTime.now(Clock.systemUTC()).plusSeconds(expireSeconds), server.keyAgreementManager.ecdsaPrivateKey);
var refreshToken = LegacySessionHelper.makeRefreshTokenFromPassword(postgresSQLUser.username, postgresSQLUser.password, server.keyAgreementManager.legacySalt); var refreshToken = LegacySessionHelper.makeRefreshTokenFromPassword(postgresSQLUser.username, postgresSQLUser.password, server.keyAgreementManager.legacySalt);
if (minecraftAccess) { if (minecraftAccess) {
String minecraftAccessToken = SecurityHelper.randomStringToken(); String minecraftAccessToken = SecurityHelper.randomStringToken();