Turnstile
Turnstile 是一个面向服务端 Fabric 模组,为离线模式 Minecraft 服务器添加了基于令牌的认证机制。玩家通过以个人令牌作为首个子域名的服务器地址连接进行认证,因此无需使用游戏内的登录命令。
Turnstile 专为离线模式服务器设计。它不替代 Mojang/Microsoft 账户认证,在启用在线模式的服务器上也不需要此模组。
要求
- Fabric Loader
0.19.3 或兼容版本
- Fabric API
0.153.0+26.2 或兼容版本
配置一个通配符 DNS 记录(例如 *.mc.example.com)指向你的服务器或代理。此模组不适用于没有域名的服务器。
工作原理
- 玩家使用其个人令牌作为最底层域名进行连接:
TOKEN.mc.example.com
- Turnstile 根据玩家的离线模式 UUID 验证令牌。
- 如果有效,玩家可以加入服务器。令牌在重新生成或被撤销之前一直有效。
令牌生成
已连接的玩家必须通过执行命令 /turnstile token generate 或与提示交互来请求令牌。
出于安全考虑,服务器管理员不能为其他玩家生成令牌。因此,在请求令牌之前,必须先向玩家授予一次性通行码。令牌不会在服务端日志中记录,且在存储前会进行哈希处理。
生成新令牌将替换该玩家之前的令牌。
一次性通行码
服务器管理员可以授予一次性通行码,允许玩家在无令牌的情况下加入服务器。在使用通行码加入后,系统会提示玩家生成新令牌。当玩家成功使用令牌认证后,其通行码将被重置。
命令
| 命令 |
权限 |
描述 |
/turnstile token generate |
任意玩家 |
为自己生成一个新令牌。 |
/turnstile token revoke <player> |
管理员 |
撤销某玩家的令牌。 |
/turnstile passes get |
任意玩家 |
显示你剩余的一次性通行码数量。 |
/turnstile passes get <player> |
管理员 |
显示某玩家剩余的一次性通行码数量。 |
/turnstile passes set <player> <amount> |
管理员 |
设置某玩家的一次性通行码数量。使用 0 可移除所有通行码。 |
配置
服务器域名
在向玩家提供令牌时,服务器可以选择返回完整的地址而不仅仅是令牌本身。为此,需要在 config/turnstile.txt 文件中写入服务器域名。如果服务器希望仅显示令牌,则不应存在该文件。
例如,内容为 mc.example.com 的文件会向玩家显示 TOKEN.mc.example.com。
游戏规则
可以在运行时启用或禁用认证功能:
/gamerule turnstile:enable true
默认情况下处于启用状态。禁用它将恢复服务器常规的离线模式登录行为。
安全注意事项
由于令牌暴露在主机名中,DNS 提供商和代理可以看到它们,并且可能会被记录在日志中。请使用你完全控制的软件栈,并且仅与信任的人共享服务器基础设施。始终保留服务器的备份。
该模组目前处于测试阶段,可能包含其他漏洞。预计未来版本将引入其他认证方法、安全功能以及对界面的更改。
Turnstile
Turnstile is a server-side Fabric mod that adds token-based authentication to offline-mode Minecraft servers. Players authenticate by connecting through a server address with a personal token as its first subdomain, so no in-game login command is required.
Turnstile is intended for offline-mode servers. It does not replace Mojang/Microsoft account authentication and is not needed on servers with online mode enabled.
Requirements
- Fabric Loader
0.19.3 or compatible
- Fabric API
0.153.0+26.2 or compatible
Configure a wildcard DNS record such as *.mc.example.com pointing to your server or proxy. This mod is not suitable for servers without a domain name.
How it works
- A player connects using their personal token as the bottom-level domain:
TOKEN.mc.example.com
- Turnstile verifies the token against the player's offline-mode UUID.
- If valid, the player may join. The token remains valid until it is regenerated or revoked.
Token generation
A connected client must request a token by executing the command /turnstile token generate or interacting with prompts.
For security reasons, a server operator cannot generate a token for another player. Because of this, a one-time pass must be granted to players before a token request can be made. The token is not logged on the server and is hashed before being stored.
Generating a new token replaces the previous one for that player.
One-time passes
Server moderators can grant one-time passes to let a player join without their token. After joining with a pass, the player is prompted to generate a new token. When a player successfully authenticates with their token, their passes are reset.
Commands
| Command |
Permission |
Description |
/turnstile token generate |
Any player |
Generates a new token for yourself. |
/turnstile token revoke <player> |
Moderator |
Revokes a player's token. |
/turnstile passes get |
Any player |
Shows your remaining one-time passes. |
/turnstile passes get <player> |
Moderator |
Shows a player's remaining one-time passes. |
/turnstile passes set <player> <amount> |
Moderator |
Sets a player's one-time pass count. Use 0 to remove all passes. |
Configuration
Server domain
When providing a token to a player, the server has the option of returning a full address instead of just the token. For that, the server domain must be written in config/turnstile.txt. If the server wishes to display just the token, the file should not exist.
For example, a file with the contents mc.example.com would display TOKEN.mc.example.com to a player.
Game rule
Authentication can be enabled or disabled at runtime:
/gamerule turnstile:enable true
It is enabled by default. Disabling it restores the server's usual offline-mode login behavior.
Security concerns
Since tokens are exposed in the hostname, they are visible to DNS providers and proxies, and may be recorded in logs. Use a software stack that you have control over, and only share server infrastructure with people you trust. Always keep backups of your server.
The mod is currently in beta and may contain other vulnerabilities. Other approaches to authentication, security features, and changes to the interface are expected to be introduced in future versions.
评论 0
登录后参与评分
还没有评论,来抢沙发吧