mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-11-02 08:59:31 +01:00
Fixed legacy public key signature tracking
Fixed https://github.com/ViaVersion/ViaFabricPlus/issues/258 Fixed https://github.com/ViaVersion/ViaFabricPlus/issues/255
This commit is contained in:
parent
959604c296
commit
f88407f0bd
@ -0,0 +1,13 @@
|
||||
package de.florianmichael.viafabricplus.definition.authlib;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
/*
|
||||
This library is part of the AuthLib, we are overwriting this class to add a new field.
|
||||
*/
|
||||
|
||||
public record KeyPairResponseBypass(KeyPair keyPair, ByteBuffer publicKeySignatureV2, ByteBuffer publicKeySignature /* own field */, String expiresAt, String refreshedAfter) {
|
||||
|
||||
public record KeyPair(String privateKey, String publicKey) {
|
||||
}
|
||||
}
|
@ -5,4 +5,6 @@ import java.nio.ByteBuffer;
|
||||
public interface IKeyPairResponse {
|
||||
|
||||
ByteBuffer viafabricplus_getLegacyPublicKeySignature();
|
||||
|
||||
void viafabricplus_setLegacyPublicKeySignature(final ByteBuffer signature);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.authlib;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.injection.access.IKeyPairResponse;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
@ -8,15 +7,19 @@ import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
@Mixin(KeyPairResponse.class)
|
||||
@Mixin(value = KeyPairResponse.class, remap = false)
|
||||
public class MixinKeyPairResponse implements IKeyPairResponse {
|
||||
|
||||
@Unique
|
||||
@SerializedName("publicKeySignature")
|
||||
private ByteBuffer viafabricplus_legacyKeySignature;
|
||||
|
||||
@Override
|
||||
public ByteBuffer viafabricplus_getLegacyPublicKeySignature() {
|
||||
return this.viafabricplus_legacyKeySignature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void viafabricplus_setLegacyPublicKeySignature(ByteBuffer signature) {
|
||||
this.viafabricplus_legacyKeySignature = signature;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of ViaFabricPlus - https://github.com/FlorianMichael/ViaFabricPlus
|
||||
* Copyright (C) 2021-2023 FlorianMichael/EnZaXD and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package de.florianmichael.viafabricplus.injection.mixin.fixes.authlib;
|
||||
|
||||
import com.mojang.authlib.minecraft.client.MinecraftClient;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilUserApiService;
|
||||
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
|
||||
import de.florianmichael.viafabricplus.definition.authlib.KeyPairResponseBypass;
|
||||
import de.florianmichael.viafabricplus.injection.access.IKeyPairResponse;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/*
|
||||
Workaround for https://github.com/ViaVersion/ViaFabricPlus/issues/258
|
||||
*/
|
||||
|
||||
@Mixin(value = YggdrasilUserApiService.class, remap = false)
|
||||
public class MixinYggdrasilUserApiService {
|
||||
|
||||
@Shadow @Final private MinecraftClient minecraftClient;
|
||||
|
||||
@Shadow @Final private URL routeKeyPair;
|
||||
|
||||
@Inject(method = "getKeyPair", at = @At("HEAD"), cancellable = true)
|
||||
public void trackLegacyKeyPair(CallbackInfoReturnable<KeyPairResponse> cir) {
|
||||
final var response = minecraftClient.post(routeKeyPair, KeyPairResponseBypass.class);
|
||||
if (response == null) return;
|
||||
|
||||
final var keyPair = response.keyPair();
|
||||
final var returnValue = new KeyPairResponse(
|
||||
keyPair == null ? null : new KeyPairResponse.KeyPair(keyPair.privateKey(), keyPair.publicKey()),
|
||||
response.publicKeySignatureV2(),
|
||||
response.expiresAt(),
|
||||
response.refreshedAfter()
|
||||
);
|
||||
((IKeyPairResponse) (Object) returnValue).viafabricplus_setLegacyPublicKeySignature(response.publicKeySignature());
|
||||
|
||||
cir.setReturnValue(returnValue);
|
||||
}
|
||||
}
|
@ -173,6 +173,7 @@
|
||||
"fixes.viaversion.protocol1_9to1_8.MixinEntityTracker1_9",
|
||||
"fixes.viaversion.protocol1_9to1_8.MixinMetadataRewriter1_9To1_8",
|
||||
"fixes.viaversion.protocol1_9to1_8.MixinViaIdleThread",
|
||||
"fixes.authlib.MixinYggdrasilUserApiService",
|
||||
"jsonwebtoken.MixinClasses",
|
||||
"jsonwebtoken.MixinDefaultCompressionCodecResolver",
|
||||
"jsonwebtoken.MixinDefaultJwtParserBuilder"
|
||||
|
Loading…
Reference in New Issue
Block a user