Skyblock Maniacs Auth service is a custom authentication service for the Skyblock Maniacs Discord server and its related web services. It is built using Go, utilizing the Gin web framework for handling HTTP requests and responses. Relies on MongoDB & Redis.
You can access the live instance of the Skyblock Maniacs Auth service at auth.sbm.gg.
- Discord OAuth2 authentication
- MC-Auth OAuth2 authentication
- JWT token generation and validation
- Permission management for authenticated users
| Method | Endpoint | Description | Query Parameters | Cookies | Example |
|---|---|---|---|---|---|
| GET | /healthz |
Health check endpoint to verify if the service is running | - | - | https://auth.sbm.gg/healthz |
| GET | /@me/permissions |
Retrieves the permissions of the authenticated user | - | sbm_jwt, discord_refresh_token, discord_access_token |
https://auth.sbm.gg/@me/permissions |
| GET | /discord/login |
Initiates Discord OAuth2 login flow | redirect_uri (optional) |
- | https://auth.sbm.gg/discord/login?redirect_uri=https://sbm.gg |
| GET | /discord/callback |
Callback endpoint for Discord OAuth2 login | code (required) |
- | https://auth.sbm.gg/discord/callback?code=YOUR_CODE_HERE |
| GET | /discord/refresh |
Refreshes the Discord OAuth2 token | refresh_token (required) |
- | https://auth.sbm.gg/discord/refresh?refresh_token |
| GET | /discord/logout |
Logs out the user from Discord and revokes sbm_jwt | - | - | https://auth.sbm.gg/discord/logout |
| GET | /minecraft/login |
Initiates MC-Auth OAuth2 login flow | redirect_uri (optional) |
- | https://auth.sbm.gg/minecraft/login?redirect_uri=https://sbm.gg |
| GET | /minecraft/callback |
Callback endpoint for MC-Auth OAuth2 login | code (required) |
- | https://auth.sbm.gg/minecraft/callback?code=YOUR_CODE_HERE |
| GET | /minecraft/logout |
Logs out the user from MC-Auth and revokes mc_jwt | - | - | https://auth.sbm.gg/minecraft/logout |
- Clone the repository:
git clone https://github.com/Skyblock-Maniacs/auth.git
- Navigate to the project directory:
cd auth - Install dependencies:
go mod tidy
- Set up environment variables:
Create a
.envfile in the root directory with the following variables:Optionally, you can use the .env.example file as a template withPORT=3000 JWT_SECRET=your_jwt_secret_key DISCORD_GUILD_ID=your_discord_guild_id DISCORD_CLIENT_ID=your_discord_client_id DISCORD_CLIENT_SECRET=your_discord_client_secret DISCORD_REDIRECT_URI=http://localhost:8080/callback MCAUTH_CLIENT_ID=your_mc_auth_client_id MCAUTH_CLIENT_SECRET=your_mc_auth_client_secret MCAUTH_OAUTH_REDIRECT_URI=http://localhost:3000/minecraft/callback MONGO_URI=mongodb://localhost:27017/your_database_name MONGO_DATABASE=your_database_name REDIS_HOST=your_redis_host REDIS_PORT=your_redis_port REDIS_PASSWORD=your_redis_password REDIS_USER="default"
cp .env.example .env. - Run the application:
go run ./cmd/auth
- Access the service:
Check the webservice is running at
http://localhost:3000/healthz.
This app is designed to be run in a Docker container. To deploy, use the provided Dockerfile. The live version of the app is hosted on Skyblock Maniacs Auth using Dokploy.