Custom-Mojang-Auth

Custom-Mojang-Auth

A small library that allows your mod to automatically sign in to your custom server using the players mojang account

by
967 Downloads
fabriclibrarymanagementutility
Rent Server with this Mod

About this Mod

custom-mojang-auth

A small library that allows your mod to automatically sign in to your custom server using the players mojang account.
Works for any minecraft version.
This mod allows a server to reliably identify a player and helps enforcing bans and prevents identity theft.
MCSR Ranked uses this library.

Usage

Client

In your mod initialize the Authenticator:

String accessToken;
UUID uuid;
java.net.Proxy proxy;
String messagePrefix //optional
ClientAuth.initialize(accessToken, uuid, proxy, messagePrefix);

The way accessToken, uuid and proxy are obtained depends on the Minecraft Version.
Obtaining the uuid of the player is pretty trivial, it can usually be found this way:

UUID uuid = net.minecraft.client.MinecraftClient.getInstance().getSession().getProfile().getId(); //1.16.1

or

UUID uuid = net.minecraft.client.MinecraftClient.getInstance().getSession().getUuidOrNull(); //1.20.2

Obtaining the accessToken is relatively easy as well:

String accessToken= net.minecraft.client.MinecraftClient.getInstance().getSession().getAccessToken();

Obtaining the proxy can be a bit more difficult.
In every version that I know of it is initialized in net.minecraft.client.mainmMian.main(String args[]). Just follow the Proxy object from here,
usually it's given to the net.minecraft.client.MinecraftClient constructor, and find a place where you can easily obtain it either via a method call, reflection, a mixin etc
In 1.20.2 the proxy can be obtained this way:

Field field =net.minecraft.client.MinecraftClient.class.getField("authenticationService");
field.setAccessible(true);
java.net.Proxy proxy =((com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)field.get(net.minecraft.client.MinecraftClient.getInstance())).getProxy();

In 1.16.1 the proxy can be obtained this way:

java.net.Proxy proxy = ((com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService)net.minecraft.client.MinecraftClient.getInstance().getSessionService()).getAuthenticationService().getProxy();

If you need help locating any of the fields for your version, feel free to dm me on discord: void_x_walker

Server

Install the library:

npm install custom-mojang-auth  

use the following function to verify that a payload has been signed by the client.

function isValid(uuid, randomLong, data, date, publicKeyString, signatureBytes, payload)

where payload is an array.

Privacy

The client simply signs messages using its private key, which can then be send to a server. No login information, or other compromising information ever leaves the client's machine.

Available Versions

Custom-Mojang-Auth 1.0.0release
MC 1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.16.5, 1.17, 1.17.1, 1.18, 1.18.1, 1.18.2, 1.19, 1.19.1, 1.19.2, 1.19.3, 1.19.4, 1.20, 1.20.1, 1.20.2fabric
October 8, 2023

How to Install Custom-Mojang-Auth on Your Server

1

Order Server

Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).

2

Set fabric Loader

In the panel under "Egg", select the fabric loader and matching Minecraft version (1.20.2).

3

Install Mod

Open the mod browser in the dashboard and search for "Custom-Mojang-Auth". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.

Compatibility

Mod Loaders

fabric

Minecraft Versions

1.20.2, 1.20.1, 1.20 (+16 more)

Server-side

Unsupported

Recommended RAM

4 GB(min. 3 GB)

Frequently Asked Questions

Custom-Mojang-Auth server crashes on startup – what to do?

Most common cause: wrong fabric version or insufficient RAM. Check the server log (latest.log) for "OutOfMemoryError" or "Mixin" errors. With Mado Hosting: ensure at least 3 GB RAM is allocated and the loader matches the mod version (1.20.2). You can switch loaders with one click in the panel.

Is Custom-Mojang-Auth compatible with fabric?

Custom-Mojang-Auth officially supports fabric for Minecraft 1.20.2, 1.20.1, 1.20. The Mado dashboard automatically detects incompatible loader combinations.

Server lagging with Custom-Mojang-Auth – how to optimize performance?

Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if Custom-Mojang-Auth consumes the most tick time. Common fixes: reduce server view-distance to 8-10, install "performant" or "starlight" as supplementary mods on Forge. With Mado Hosting, your server runs on NVMe SSDs with dedicated CPU cores for minimal latency.

Rent Modded Server

Install Custom-Mojang-Auth with just one click on your server.

Recommended RAM
4 GBab €8/mo
Min. 3 GB | +1 GB pro 8 Spieler
Create Server Now
1-Click Mod Install
NVMe SSD Storage
DDoS Protection included

Details

License
MIT License
Server-side
Unsupported

Supported Versions

1.20.21.20.11.201.19.41.19.31.19.21.19.11.191.18.21.18.1+9 more