Skip to content

Commit 3f27e57

Browse files
authored
Store iat in AuthData for later retrieval (#5884)
1 parent 82fb2e4 commit 3f27e57

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

core/src/main/java/org/geysermc/geyser/session/auth/AuthData.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,13 @@
2727

2828
import java.util.UUID;
2929

30-
public record AuthData(String name, UUID uuid, String xuid) {
30+
/**
31+
* A class holding some basic information of the connected user.
32+
*
33+
* @param name The gamertag of the user
34+
* @param uuid Also known as identity
35+
* @param xuid The xuid of the user
36+
* @param issuedAt The unix time (in seconds) that the JWT was issued
37+
*/
38+
public record AuthData(String name, UUID uuid, String xuid, long issuedAt) {
3139
}

core/src/main/java/org/geysermc/geyser/util/LoginEncryptionUtils.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,13 @@ private static void encryptConnectionWithCert(GeyserSession session, AuthPayload
7676
return;
7777
}
7878

79+
// Should always be present, but hey, why not make it safe :D
80+
Long rawIssuedAt = (Long) result.rawIdentityClaims().get("iat");
81+
long issuedAt = rawIssuedAt != null ? rawIssuedAt : -1;
82+
7983
IdentityData extraData = result.identityClaims().extraData;
8084
// TODO!!! identity won't persist
81-
session.setAuthData(new AuthData(extraData.displayName, extraData.identity, extraData.xuid));
85+
session.setAuthData(new AuthData(extraData.displayName, extraData.identity, extraData.xuid, issuedAt));
8286
if (authPayload instanceof CertificateChainPayload certificateChainPayload) {
8387
session.setCertChainData(certificateChainPayload.getChain());
8488
} else {

0 commit comments

Comments
 (0)