🚀 DISCORDAUTHMEBRIDGE
DiscordAuthMeBridge 是一个 Paper 插件,通过 HTTP 桥接器将 Minecraft 服务器、AuthMe Reloaded、LuckPerms 与外部 Discord 机器人连接起来。
该插件允许你自己的 Discord 机器人或外部应用程序与 Minecraft 服务器进行通信,而无需嵌入 Discord 机器人。它提供了用于账户认证、注册、Discord 账户绑定、IP 验证、权限管理、密钥分发和事件处理的 HTTP 端点。
✨ 功能特性
- 🔐 AuthMe 认证 — 直接通过 AuthMe 验证 Minecraft 用户名和密码。
- 📝 账户注册 — 通过 AuthMe 使用用户名和密码验证来注册新的 Minecraft 账户。
- 🔗 Discord 账户绑定 — 在 Discord 用户与已认证的 Minecraft 玩家之间创建账户绑定请求。
- 🌐 IP 验证 — 存储受信任的 IP 地址,并与你的外部 Discord 机器人集成登录验证工作流。
- 🏷️ 权限管理 — 获取 LuckPerms 主组并将支持的权限应用于在线玩家。
- 🗝️ 密钥分发 — 通过服务器端命令请求游戏内密钥分发。
- 📡 事件队列 — 获取待处理的桥接事件并确认已处理的事件。
- ❤️ 健康监控 — 检查 HTTP 桥接器是否正在响应。
- 🛡️ API 认证 — 使用共享密钥保护 API 端点。
- ⚙️ 灵活配置 — 配置桥接地址、端口、共享密钥、IP 验证和请求过期时间。
🔌 HTTP API 参考
所有 API 请求均使用配置的 HTTP 桥接器地址。
默认基础 URL:
"
将 "<SERVER_IP>" 替换为你的机器人或应用程序可以访问的地址。
🔐 API 认证
所有 "/api/*" 端点需要以下标头:
"X-Bridge-Secret: YOUR_BRIDGE_SECRET"
JSON 请求应包含:
"Content-Type: application/json"
在 "plugins/DiscordAuthMeBridge/config.yml" 中配置密钥:
Bridge:
Port: 25459
Host: '0.0.0.0'
Secret: "YOUR_STRONG_SECRET"
"/health" 端点不需要密钥。其他所有端点都需要一个配置的、非空的密钥,且必须与请求标头匹配。
❤️ 1. 健康检查
"GET /health"
检查 HTTP 桥接器是否正在响应。
示例响应:
{
"success": true,
"service": "DiscordAuthMeBridge"
}
此端点确认基本桥接可用性,而非每个依赖项的健康状况。
🔑 2. 认证 Minecraft 账户
"POST /api/auth/login"
通过 AuthMe 验证 Minecraft 账户。
请求体:
{
"username": "Steve",
"password": "your_password"
}
功能特性:
- 检查账户是否存在于 AuthMe 中。
- 验证提供的密码。
- 验证 Minecraft 用户名格式。
- 返回指示成功或失败的结构化 JSON 响应。
成功的响应包括已认证的用户名。无效的凭证和不可用的 AuthMe 服务会返回错误响应。
📝 3. 注册 Minecraft 账户
"POST /api/auth/register"
在版本 1.1.2 中引入,此端点允许外部应用程序通过 AuthMe 注册 Minecraft 账户。
请求体:
{
"username": "Steve",
"password": "your_password"
}
功能特性:
- 检查 AuthMe 中是否启用了注册。
- 要求 AuthMe 的注册模式支持密码注册。
- 根据配置的长度和字符限制验证用户名。
- 验证密码长度和允许的字符。
- 拒绝列入 AuthMe 不安全密码列表中的密码。
- 防止重复注册。
- 限制请求体大小。
- 为成功的注册和验证错误返回结构化的 JSON 响应。
成功的注册返回 HTTP "201 Created"。
该端点也支持 URL 编码的表单请求。
🔗 4. 请求 Discord 账户绑定
"POST /api/link/request"
创建将 Discord 账户与 Minecraft 账户绑定的请求。
请求体:
{
"discordId": "123456789012345678",
"minecraftName": "Steve"
}
功能特性:
- 要求 Minecraft 玩家在线。
- 检查玩家是否已通过 AuthMe 认证。
- 防止 Minecraft 账户被绑定到不同的 Discord 账户。
- 防止 Discord 账户被绑定到不同的 Minecraft 账户。
- 为待处理的请求生成请求 ID 和过期时间戳。
- 向外部机器人返回请求 ID 和 Minecraft 用户名。
预期的确认命令是:
"/discordauth confirm <requestId>"
实现说明:在提供的 JAR 文件中,该命令在 "plugin.yml" 中声明,但我找不到注册的命令执行器来处理它。因此,最终的游戏中确认流程似乎不完整,在生产环境中依赖账户绑定之前应予以修复。
🌐 5. 批准受信任的 IP
"POST /api/ip/approve"
将受信任的 IP 地址添加到 Minecraft 账户。
请求体:
{
"uuid": "PLAYER_UUID",
"ip": "203.0.113.10"
}
功能特性:
- 要求 Minecraft 玩家的 UUID。
- 要求 IP 地址。
- 通过插件数据库存储受信任的 IP。
- 对无效的 UUID 或数据库故障返回错误。
此端点可在外部 Discord 机器人批准验证请求后被调用。
🚫 6. 拒绝 IP 验证请求
"POST /api/ip/reject"
提供旨在用于 IP 验证拒绝工作的端点。
已知限制:在提供的构建中,此端点当前返回 "{"success":true}",而不验证请求 ID 或执行拒绝逻辑。不应将其视为功能性的 IP 拒绝机制。
🏷️ 7. 检索玩家的权限等级
"POST /api/rank/get"
使用 Minecraft UUID 检索玩家 LuckPerms 的主组。
请求体:
{
"uuid": "PLAYER_UUID"
}
成功响应示例:
{
"success": true,
"uuid": "PLAYER_UUID",
"username": "Steve",
"primaryGroup": "default"
}
功能特性:
- 验证 UUID。
- 通过 LuckPerms 加载玩家数据。
- 返回 UUID、用户名和主组。
- 报告不可用的 LuckPerms 服务和查找失败情况。
使用此端点必须安装并启用 LuckPerms。
🎖️ 8. 应用玩家的等级
"POST /api/rank/apply"
为在线 Minecraft 玩家应用支持的等级。
请求体:
{
"username": "Steve",
"rank": "plus"
}
支持的等级值:
功能特性:
- 验证 Minecraft 用户名。
- 将等级值限制在支持的列表中。
- 要求目标玩家处于在线状态。
- 执行服务端命令以应用等级,并更新相关的标签页(tab)和名称标签前缀。
相关的 LuckPerms 和 TAB 命令必须在服务器上可用且配置正确。
🗝️ 9. 赠送游戏内钥匙
"POST /api/key/give"
通过服务器的钥匙命令请求发放钥匙。
请求体:
{
"username": "Steve",
"key": "gold",
"amount": "2"
}
支持的钥匙类型:
- "common"
- "gold"
- "prime"
- "crimson"
- "amethyst"
验证规则:
- 用户名、钥匙类型和数量均为必填项。
- 数量必须是介于 "1" 到 "1000" 之间的整数。
- "common" 类型钥匙的数量必须是 "2" 的倍数。
- 不支持的钥匙类型和无效的数量将被拒绝。
桥接程序会执行相应的服务端命令,并返回成功或错误响应。
📡 10. 检索待处理事件
"GET /api/events"
检索等待外部 Discord 机器人或应用程序处理的事件。
示例响应结构:
{
"success": true,
"events": [
{
"id": "EVENT_ID",
"data": {
"type": "EVENT_TYPE"
}
}
]
}
实际的事件数据取决于插件生成的事件类型。
功能特性:
- 返回带有其 ID 和相关数据的排队事件。
- 允许外部服务在没有嵌入式 Discord 机器人的情况下处理事件。
- 需要 API 身份验证。
事件队列在内存中维护,并在插件关闭时清除。
✅ 11. 确认已处理的事件
"POST /api/events/ack"
在外部应用程序处理后确认一个事件。
请求体:
{
"id": "EVENT_ID"
}
功能特性:
- 需要事件 ID。
- 从待处理队列中移除匹配的事件。
- 返回 "removed" 字段以指示是否移除了某个事件。
请在确认之前先处理事件,以免在您的机器人处理完之前丢弃事件。
⚙️ 配置
主配置文件位于:
"plugins/DiscordAuthMeBridge/config.yml"
可用的设置包括:
- "Bridge.Host" — HTTP 服务器绑定地址。
- "Bridge.Port" — HTTP 服务器端口;默认为 "25459"。
- "Bridge.Secret" — 受保护的 API 端点所需的共享密钥。
- "Check-IP" — 控制配置的 IP 检查功能。
- "Link-Code.Expires-In" — 链接请求的过期时间。
- "IP-Verification.Timeout" — IP 验证请求的超时时间。
默认绑定地址为 "0.0.0.0",监听所有可用的网络接口。请使用防火墙规则或其他网络控制措施来适当限制访问。
📦 依赖要求
- Minecraft Server:提供的构建版本使用 Paper 26.1.2。
- AuthMe Reloaded:用于账户认证和注册。
- LuckPerms:用于支持的等级查找和等级管理功能。
- TAB 或兼容命令:用于等级应用实现中所使用前缀命令。
🔒 安全建议
- 始终配置一个强大且唯一的 "Bridge.Secret"。
- 切勿将共享密钥暴露在公共源代码或客户端应用程序中。
- 使用防火墙规则或专用网络限制对 HTTP Bridge 的访问。
- 避免在不安全的网络上发送 Minecraft 密码。该桥接程序使用 HTTP,而非内置的 HTTPS。
- 未经额外的访问控制,不要直接将注册或等级管理端点暴露给公共互联网。
⚠️ 已知限制
- "/api/ip/reject" 目前不执行拒绝逻辑。
DiscordAuthMeBridge — 一个可配置的 HTTP 桥接程序,用于连接 Minecraft、AuthMe、LuckPerms 以及自定义 Discord 机器人集成。
🚀 DISCORDAUTHMEBRIDGE
DiscordAuthMeBridge is a Paper plugin that connects Minecraft servers, AuthMe Reloaded, LuckPerms, and external Discord bots through an HTTP Bridge.
The plugin allows your own Discord bot or external application to communicate with your Minecraft server without requiring an embedded Discord bot. It provides HTTP endpoints for account authentication, registration, Discord account linking, IP verification, rank management, key delivery, and event handling.
✨ FEATURES
- 🔐 AuthMe Authentication — Verify Minecraft usernames and passwords directly through AuthMe.
- 📝 Account Registration — Register new Minecraft accounts through AuthMe with username and password validation.
- 🔗 Discord Account Linking — Create account-linking requests between Discord users and authenticated Minecraft players.
- 🌐 IP Verification — Store trusted IP addresses and integrate login verification workflows with your external Discord bot.
- 🏷️ Rank Management — Retrieve LuckPerms primary groups and apply supported ranks to online players.
- 🗝️ Key Delivery — Request in-game key delivery through server-side commands.
- 📡 Event Queue — Retrieve pending bridge events and acknowledge processed events.
- ❤️ Health Monitoring — Check whether the HTTP Bridge is responding.
- 🛡️ API Authentication — Protect API endpoints with a shared secret.
- ⚙️ Flexible Configuration — Configure the bridge address, port, shared secret, IP verification, and request expiration.
🔌 HTTP API REFERENCE
All API requests use the configured HTTP Bridge address.
Default base URL:
"
Replace "<SERVER_IP>" with the address your bot or application can reach.
🔐 API AUTHENTICATION
All "/api/*" endpoints require the following header:
"X-Bridge-Secret: YOUR_BRIDGE_SECRET"
JSON requests should include:
"Content-Type: application/json"
Configure the secret in "plugins/DiscordAuthMeBridge/config.yml":
Bridge:
Port: 25459
Host: '0.0.0.0'
Secret: "YOUR_STRONG_SECRET"
The "/health" endpoint does not require the secret. All other endpoints require a configured, non-empty secret matching the request header.
❤️ 1. HEALTH CHECK
"GET /health"
Checks whether the HTTP Bridge is responding.
Example response:
{
"success": true,
"service": "DiscordAuthMeBridge"
}
This endpoint confirms basic bridge availability, not the health of every dependency.
🔑 2. AUTHENTICATE A MINECRAFT ACCOUNT
"POST /api/auth/login"
Verifies a Minecraft account through AuthMe.
Request body:
{
"username": "Steve",
"password": "your_password"
}
Features:
- Checks whether the account exists in AuthMe.
- Verifies the supplied password.
- Validates the Minecraft username format.
- Returns a structured JSON response indicating success or failure.
A successful response includes the authenticated username. Invalid credentials and unavailable AuthMe services return an error response.
📝 3. REGISTER A MINECRAFT ACCOUNT
"POST /api/auth/register"
Introduced in version 1.1.2, this endpoint allows external applications to register Minecraft accounts through AuthMe.
Request body:
{
"username": "Steve",
"password": "your_password"
}
Features:
- Checks whether registration is enabled in AuthMe.
- Requires AuthMe's registration mode to support password registration.
- Validates usernames against the configured length and character restrictions.
- Validates password length and permitted characters.
- Rejects passwords listed in AuthMe's unsafe password list.
- Prevents duplicate registrations.
- Limits request body size.
- Returns structured JSON responses for successful registrations and validation errors.
A successful registration returns HTTP "201 Created".
The endpoint also supports URL-encoded form requests.
🔗 4. REQUEST DISCORD ACCOUNT LINKING
"POST /api/link/request"
Creates a request to link a Discord account with a Minecraft account.
Request body:
{
"discordId": "123456789012345678",
"minecraftName": "Steve"
}
Features:
- Requires the Minecraft player to be online.
- Checks that the player is authenticated through AuthMe.
- Prevents a Minecraft account from being linked to a different Discord account.
- Prevents a Discord account from being linked to a different Minecraft account.
- Generates a request ID and expiration timestamp for pending requests.
- Returns the request ID and Minecraft username to the external bot.
The intended confirmation command is:
"/discordauth confirm <requestId>"
Implementation note: In the supplied JAR, the command is declared in "plugin.yml", but I could not find a command executor registered to handle it. The final in-game confirmation flow therefore appears incomplete and should be fixed before relying on account linking in production.
🌐 5. APPROVE A TRUSTED IP
"POST /api/ip/approve"
Adds a trusted IP address to a Minecraft account.
Request body:
{
"uuid": "PLAYER_UUID",
"ip": "203.0.113.10"
}
Features:
- Requires the Minecraft player's UUID.
- Requires an IP address.
- Stores the trusted IP through the plugin's database.
- Returns an error for invalid UUIDs or database failures.
This endpoint can be called by an external Discord bot after a verification request has been approved.
🚫 6. REJECT AN IP VERIFICATION REQUEST
"POST /api/ip/reject"
Provides an endpoint intended for IP verification rejection workflows.
Known limitation: In the supplied build, this endpoint currently returns "{"success":true}" without validating a request ID or performing rejection logic. It must not be treated as a functional IP rejection mechanism.
🏷️ 7. RETRIEVE A PLAYER'S RANK
"POST /api/rank/get"
Retrieves a player's LuckPerms primary group using their Minecraft UUID.
Request body:
{
"uuid": "PLAYER_UUID"
}
Example successful response:
{
"success": true,
"uuid": "PLAYER_UUID",
"username": "Steve",
"primaryGroup": "default"
}
Features:
- Validates the UUID.
- Loads the player data through LuckPerms.
- Returns the UUID, username, and primary group.
- Reports unavailable LuckPerms services and lookup failures.
LuckPerms must be installed and enabled to use this endpoint.
🎖️ 8. APPLY A PLAYER'S RANK
"POST /api/rank/apply"
Applies a supported rank to an online Minecraft player.
Request body:
{
"username": "Steve",
"rank": "plus"
}
Supported rank values:
Features:
- Validates the Minecraft username.
- Restricts rank values to the supported list.
- Requires the target player to be online.
- Executes server-side commands to apply the rank and update the associated tab and name-tag prefixes.
The relevant LuckPerms and TAB commands must be available and configured correctly on the server.
🗝️ 9. GIVE IN-GAME KEYS
"POST /api/key/give"
Requests key delivery through the server's key command.
Request body:
{
"username": "Steve",
"key": "gold",
"amount": "2"
}
Supported key types:
- "common"
- "gold"
- "prime"
- "crimson"
- "amethyst"
Validation rules:
- The username, key type, and amount are required.
- The amount must be an integer between "1" and "1000".
- The amount for "common" keys must be a multiple of "2".
- Unsupported key types and invalid quantities are rejected.
The bridge executes the corresponding server-side command and returns a success or error response.
📡 10. RETRIEVE PENDING EVENTS
"GET /api/events"
Retrieves events waiting to be processed by an external Discord bot or application.
Example response structure:
{
"success": true,
"events": [
{
"id": "EVENT_ID",
"data": {
"type": "EVENT_TYPE"
}
}
]
}
The actual event data depends on the event generated by the plugin.
Features:
- Returns queued events with their IDs and associated data.
- Allows the external service to process events without an embedded Discord bot.
- Requires API authentication.
The event queue is maintained in memory and is cleared when the plugin shuts down.
✅ 11. ACKNOWLEDGE A PROCESSED EVENT
"POST /api/events/ack"
Acknowledges an event after the external application has processed it.
Request body:
{
"id": "EVENT_ID"
}
Features:
- Requires an event ID.
- Removes the matching event from the pending queue.
- Returns a "removed" field to indicate whether an event was removed.
Process events before acknowledging them to avoid discarding events before your bot has handled them.
⚙️ CONFIGURATION
The main configuration file is:
"plugins/DiscordAuthMeBridge/config.yml"
Available settings include:
- "Bridge.Host" — HTTP server bind address.
- "Bridge.Port" — HTTP server port; defaults to "25459".
- "Bridge.Secret" — Shared secret required by protected API endpoints.
- "Check-IP" — Controls the configured IP-check feature.
- "Link-Code.Expires-In" — Expiration time for link requests.
- "IP-Verification.Timeout" — Timeout for IP verification requests.
The default bind address is "0.0.0.0", which listens on all available network interfaces. Use firewall rules or other network controls to restrict access as appropriate.
📦 REQUIREMENTS
- Minecraft Server: Paper 26.1.2 for the supplied build.
- AuthMe Reloaded: Required for account authentication and registration.
- LuckPerms: Required for the supported rank lookup and rank management functionality.
- TAB or compatible commands: Required for the prefix commands used by the rank application implementation.
🔒 SECURITY RECOMMENDATIONS
- Always configure a strong, unique "Bridge.Secret".
- Never expose the shared secret in public source code or client-side applications.
- Restrict access to the HTTP Bridge using firewall rules or a private network.
- Avoid sending Minecraft passwords over untrusted networks. The bridge uses HTTP, not built-in HTTPS.
- Do not expose registration or rank-management endpoints directly to the public internet without additional access controls.
⚠️ KNOWN LIMITATIONS
- "/api/ip/reject" does not currently perform rejection logic.
DiscordAuthMeBridge — A configurable HTTP Bridge for connecting Minecraft, AuthMe, LuckPerms, and custom Discord bot integrations.
评论 0
登录后参与评分
还没有评论,来抢沙发吧