https://github.com/andcool-systems/mc-oauth-rs
A simple way to add Minecraft authentication to your website or project written in Rust
https://github.com/andcool-systems/mc-oauth-rs
minecraft rust tokio yggdrasil-minecraft-login
Last synced: 2 months ago
JSON representation
A simple way to add Minecraft authentication to your website or project written in Rust
- Host: GitHub
- URL: https://github.com/andcool-systems/mc-oauth-rs
- Owner: Andcool-Systems
- Created: 2025-02-04T16:28:03.000Z (4 months ago)
- Default Branch: master
- Last Pushed: 2025-02-15T09:37:44.000Z (3 months ago)
- Last Synced: 2025-02-15T10:27:42.407Z (3 months ago)
- Topics: minecraft, rust, tokio, yggdrasil-minecraft-login
- Language: Rust
- Homepage: https://mc-oauth.andcool.ru
- Size: 67.4 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Minecraft OAuth Provider
## ๐ Description
MC-oAuth-rs is an all-in-one solution that allows users to log in to a website using their Minecraft account without entering their username or password.Itโs secure, simple, and user-friendly, enabling logins only for users with a licensed Minecraft account.
The service supports Minecraft versions above 1.8.## ๐ก How it works?
Our service provides an authentication system that requires no complex actions from users or developers.
All you need to do is join a Minecraft server and get a 6-digit code, then enter it on the website that uses this service.### ๐ Features
- ๐ Get username, UUID, and skin through REST API
- ๐ก๏ธ Zero Trust (it is impossible to fake Minecraft account data)
- โก Easy to use and implement
- ๐ The server only processes the authentication process and nothing more## ๐ป For Users
Websites that use this service will ask you for a 6-digit code, which you can get by joining the Minecraft server `auth.mc-oauth.andcool.ru` (or others), then entering it on the website.
**The website developer will get access to your username, UUID, and skin.**## ๐ ๏ธ For Developers
To integrate this service, add a form on your website for entering the 6-digit code. After the user enters the code, make a request to the API endpoint described below.### ๐ก API Endpoint
```
GET /code/<6-digit code>
```### Example of a successful response from the server:
```json
{
"nickname": "AndcoolSystems",
"UUID": "1420c63cb1114453993fb3479ba1d4c6",
"properties": [
{
"name": "textures",
"signature": "",
"value": ""
}
]
}
```
*You can read more about the data inside `properties` [here](https://minecraft.wiki/w/Mojang_API#Query_player's_skin_and_cape).*> [!NOTE]
> The code is valid for 5 minutes after issuance and can only be used once.## ๐ ๏ธ Local Deployment
To run this service locally, first install [Rust](https://www.rust-lang.org/tools/install).Then run these commands:
```shell
git clone https://github.com/Andcool-Systems/mc-oauth-rs.git
cd mc-oauth-rscargo build --release
```After the project is fully built, the binary file for your OS will be available at `./target/release/mc-oauth.*`.
### ๐ Configuration
For the server to work, create a `config.toml` file in the same directory as the executable with the following contents:```toml
[api]
# API address
addr = "0.0.0.0"
# API port
port = 8008
# Life time of assigned code
code_life_time = 300[server]
# Minecraft server address
addr = "0.0.0.0"
# Minecraft server port
port = 25565
# Server connection timeout
timeout = 10[server.config]
# Minecraft server name
server_name = "mc-oauth-rs"
# Protocol version (`0` for auto)
protocol = 0
# Minecraft version string
version = "1.21"
# Session Auth URL
# `{{NAME}}` in string will be replaced by the client nickname
# `{{HASH}}` will be replaced by the generated client hash
auth_url = "https://sessionserver.mojang.com/session/minecraft/hasJoined?username={{NAME}}&serverId={{HASH}}"[server.status]
# Server description (you can use MOTD)
description = "ยง6mc-oauth.andcool.ru"
# Max players count, displayed in server list
players_max = 0
# Online players count, displayed in server list
players_online = 0
# Path to the server icon (can be empty)
icon_path = "server_icon.png"[messages]
# Message for successful auth
# `{{NAME}}` will be replaced by the client nickname
# `{{UUID}}` will be replaced by the client UUID
# `{{CODE}}` will be replaced by the generated code
success = "Hello, ยง6{{NAME}}ยงr! Your code is: ยงa{{CODE}}"
# Message for Mojang API error
bad_session = "ยงcFailed to login: Invalid session (Try restarting your game and the launcher)"
```> [!NOTE]
> The server icon should be in `.png` format and 64x64 pixels in size.
> `timeout` in the config sets the **maximum** time that the client can be connected before the server disconnects.
> `protocol` is used only during the server ping and is ignored when trying to connect. If set to `0`, the protocol version that the client uses will be applied.### ๐ Running
After configuring, run the compiled binary file through the console.## Known issues
- For Minecraft 1.19.* clients, encryption does not work correctly---
**Created by AndcoolSystems with โค, 3 February, 2025**