A custom Minecraft authentication server built with Spring Boot that implements the Yggdrasil protocol and supports Microsoft account linking.
- Yggdrasil Protocol Support: Full compatibility with standard Minecraft authentication
- Microsoft Account Integration: Link Microsoft/Xbox accounts to import official profiles
- Authlib-Injector Compatible: Works with authlib-injector for easy client setup
- Multi-Profile Support: Users can have multiple player profiles
- Skin & Cape Support: Custom skins and capes per player
- Invite System: Optional invite-only registration
- Web UI: Built-in registration and account management pages
- Java 21 or later
- Maven 3.8+
- (Optional) PostgreSQL or MySQL for production
cd KmAuth
mvn clean package# Using Maven
mvn spring-boot:run
# Or using the JAR
java -jar target/kmauth-1.0.0-SNAPSHOT.jarThe server will start on http://localhost:8080 by default.
- Open
http://localhost:8080/registerin your browser - Create an account
- Configure your Minecraft launcher (see below)
Edit src/main/resources/application.yml or set environment variables:
kmauth:
server-name: My Server # Display name
base-url: http://localhost:8080 # Public URL of your server
require-invite: false # Require invite codes for registration
allow-microsoft-auth: true # Enable Microsoft account linking
allow-password-auth: true # Enable username/password authspring:
datasource:
url: jdbc:h2:file:./data/kmauth
driver-class-name: org.h2.Driver
username: sa
password:spring:
datasource:
url: jdbc:postgresql://localhost:5432/kmauth
driver-class-name: org.postgresql.Driver
username: kmauth
password: your_secure_password
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.PostgreSQLDialectspring:
datasource:
url: jdbc:mysql://localhost:3306/kmauth?useSSL=false&serverTimezone=UTC
driver-class-name: com.mysql.cj.jdbc.Driver
username: kmauth
password: your_secure_password
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQLDialectTo enable Microsoft authentication:
- Go to Azure Portal
- Navigate to "App registrations" → "New registration"
- Configure:
- Name:
KmAuth(or your server name) - Supported account types: "Personal Microsoft accounts only"
- Redirect URI:
http://your-server:8080/oauth/microsoft/callback
- Name:
- Copy the Application (client) ID
- Create a client secret under "Certificates & secrets"
kmauth:
microsoft:
client-id: your-client-id
client-secret: your-client-secret
redirect-uri: http://your-server:8080/oauth/microsoft/callbackOr use environment variables:
export MICROSOFT_CLIENT_ID=your-client-id
export MICROSOFT_CLIENT_SECRET=your-client-secret
export MICROSOFT_REDIRECT_URI=http://your-server:8080/oauth/microsoft/callback- Download authlib-injector
- Add to your Minecraft launch arguments:
-javaagent:authlib-injector.jar=http://your-server:8080
Add these JVM arguments to your Minecraft launcher:
-Dminecraft.api.auth.host=http://your-server:8080/authserver
-Dminecraft.api.session.host=http://your-server:8080/sessionserver
-Dminecraft.api.services.host=http://your-server:8080
- Prism Launcher / PolyMC: Add account → Microsoft → Use custom auth server
- MultiMC: Edit instance → Settings → Custom commands
- Fjord Launcher: Native authlib-injector support
- HMCL: Native third-party auth support
For Minecraft servers to verify players against your auth server:
Add to your server start script:
java -javaagent:authlib-injector.jar=http://your-auth-server:8080 -jar server.jarIf not using authlib-injector, the server must be in offline mode and use a plugin for verification.
| Endpoint | Method | Description |
|---|---|---|
/authserver/authenticate |
POST | Login with username/password |
/authserver/refresh |
POST | Refresh access token |
/authserver/validate |
POST | Validate token |
/authserver/invalidate |
POST | Invalidate token |
/authserver/signout |
POST | Sign out (invalidate all tokens) |
| Endpoint | Method | Description |
|---|---|---|
/sessionserver/session/minecraft/join |
POST | Client join request |
/sessionserver/session/minecraft/hasJoined |
GET | Server verification |
/sessionserver/session/minecraft/profile/{uuid} |
GET | Get player profile with textures |
| Endpoint | Method | Description |
|---|---|---|
/users/profiles/minecraft/{name} |
GET | Get profile by name |
/profiles/minecraft |
POST | Bulk profile lookup |
| Endpoint | Method | Description |
|---|---|---|
/oauth/microsoft/login |
GET | Start Microsoft OAuth flow |
/oauth/microsoft/callback |
GET | OAuth callback |
/oauth/microsoft/authenticate |
POST | API authentication with code |
This authentication server is designed for private servers and works alongside Microsoft authentication rather than replacing it. When Microsoft account linking is enabled:
- Users authenticate through Microsoft's official OAuth
- Player UUIDs and profiles come from official Minecraft accounts
- Skins and capes are imported from official profiles
This approach ensures compliance with Minecraft's Terms of Service while allowing self-hosted infrastructure.
src/main/java/me/kmathers/kmauth/
├── config/ # Configuration classes
├── controller/ # REST controllers
├── dto/ # Data transfer objects
├── exception/ # Exception handling
├── model/ # JPA entities
├── repository/ # Data repositories
└── service/ # Business logic
mvn testmvn clean package -Pprod- Tokens expire after 30 days by default
- Check that your server time is synchronized
- Ensure the client is sending the correct clientToken
- Verify client ID and secret are correct
- Check redirect URI matches exactly
- Ensure your Azure app allows personal Microsoft accounts
- Server must use authlib-injector pointing to same auth server
- Check firewall allows connections between server and auth server
- Verify session hasn't expired (30 second window)
MIT License - See LICENSE file for details.
Contributions are welcome! Please feel free to submit issues and pull requests.