Mod

Custom-Mojang-Auth

Quick rating

Custom-Mojang-Auth

No reviews yet

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

API/Library
Mod Loaders
Fabric
Minecraft

Community voices

Reviews

Versions
Loading versions…
Match includes

Click once to include, again to exclude, again to clear

Rating Any
Any 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
Min
Max
Play Status
Reviews
Time Played
hrs+
Verified developers only
Has developer response
List view
Grid view
Compact view
Sort by
Date
Rating
Helpful
Unhelpful
Edited
Sort ascending
Delete this review?

This removes your review from the project. You can write a new review after.

Review submitted for moderation

Your review has been sent to moderators, who will check that it meets our guidelines before it appears publicly.

No reviews yet. Be the first to review this project!

Get it on

Available Platforms

Compatibility

Supported Environments

Dev Environment
Client Required
Server Unsupported

About

Project Details

Type
Mod
License
MIT License
Latest Version
1.0.0
Authors

For authors

Embed Badge

If you're the author of this project, you can embed a live badge anywhere that supports HTML or Markdown. It updates automatically whenever ratings change.

Custom banner text
ModDex rating badge preview

Use HTML for any page that supports it, or Markdown for README files and Markdown-based descriptions.

Identifiers

Platform IDs

Modrinth ID

Resources

External Links

Source Issues Wiki Discord

About

Description

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.

Screenshots

Gallery

This project has no gallery images yet.

Versions

Files

Relations

Project Relations

More like this

Similar Mods

Suggestions use data such as tags, dependencies, dependents, descriptions, titles, and more to rank how much they overlap with this mod.

On ModDex

Community snapshot

0
Ratings
0
Followers
0
In stacks

By the numbers

Statistics

<1,000
Downloads
Last Updated
CurseForge
Modrinth
Created
Last synced
When ModDex last fetched and imported data for this project from CurseForge or Modrinth. High-traffic and active projects are checked more often.
Next pipeline sync