Minecraft Velocity OIDC Auth
该插件允许你通过代理端使用 OIDC/OAuth2 和 LDAP 来限制对后端服务器的访问。
或者,它提供了一种使用密码登录的方式(详见下文)。
专为与 Velocity 代理配合使用而设计。
工作原理
Velocity 支持强制主机(forced hosts),根据玩家加入服务器时使用的hostname,将他们直接发送到指定的后端服务器。由于该插件仅在玩家完成身份验证后才允许其进入相应的后端服务器,因此它会先将目标服务器保存到缓存中,并将玩家重定向到一个“中间状态”服务器(limbo server)。
玩家会被留在此处,直到他们成功完成身份验证。
使用 OIDC 进行身份验证:
当玩家加入游戏时,他们会在游戏聊天中收到一个链接。点击此链接会在他们的浏览器中打开 OIDC 登录页面。登录成功后,回调服务器会从 OIDC 提供商处接收必要的数据。
如果这是玩家首次使用给定的 Minecraft 用户名加入游戏,该用户名将被绑定到 OIDC 账户。如果该 Minecraft 用户名已经注册了 OIDC 账户,系统会检查是否使用了正确的账户进行登录。
随后,插件会使用 OIDC 账户的 uid(通常是用户名)查询 LDAP 服务器,并根据配置授予对原本受限的后端服务器的访问权限。
之后,玩家会被发送回最初想要进入的后端服务器。
使用密码进行身份验证:
默认情况下,所有账户都使用 OIDC 进行身份验证。管理员可以将任何玩家的账户切换为使用密码认证。实现此功能是为了让管理员能够给那些可能没有基于 OIDC 账户的玩家提供访问权限。仅在你希望给完全无法拥有 OIDC 账户的玩家提供访问权限时使用此功能
当玩家加入游戏时,如果尚未注册,系统会要求他们使用 /register <password> <password> 进行注册。
如果玩家已经注册,系统会要求他们使用 /login <password> 进行登录。
成功登录后,玩家会被发送回最初想要进入的后端服务器。
会话
为了方便起见,一旦认证成功,就会为用户创建一个与其设备绑定的会话。
这意味着他们可以断开与服务器的连接,并在重新连接时,只要会话仍然有效,就无需再次进行身份验证。默认情况下,会话有效期为 12 小时,这可以在配置文件中更改。
服务器权限(LDAP)
该插件还使用权限来控制对后端服务器的访问。这些权限可以在配置文件中设置。
默认服务器是任何经过身份验证的玩家都可以访问的服务器。受限服务器是只有拥有相应权限的玩家才能访问的服务器。
对于每个服务器,插件都会创建一个 LuckPerms 组,并赋予该组访问给定后端服务器的权限。这是通过 oidcauth.serverperm.<servername> 权限实现的,插件在有人尝试加入特定后端服务器时会检查此权限。
如果使用 OIDC 进行身份验证,插件将从 LDAP 同步用户的权限,并通过 LuckPerms API 授予玩家对后端服务器的访问权限。
如果使用密码认证,玩家仍然可以访问默认服务器,但受限服务器的权限不会同步。你可以使用 LuckPerms 手动为他们授予访问权限。
例如:
如果有一个名为 survival 的服务器,那么你需要给予玩家的权限是 oidcauth.serverperm.survival
权限和命令
所有使用 OIDC 身份验证的玩家都可以访问以下命令:
/login - 在游戏聊天中发送登录链接
/logout - 使当前会话失效,并将玩家发送回中间状态服务器以重新进行身份验证
所有使用密码身份验证的玩家都可以访问以下命令:
/login <password> - 使用密码登录
/register <password> <password> - 使用密码注册
/logout - 使当前会话失效,并将玩家发送回中间状态服务器以重新进行身份验证
如果玩家拥有 oidcauth.manageauth 权限,他们将获得以下命令的访问权限
(仅管理员应拥有这些权限):
/oidcauth <player> unregister - 注销玩家。下次登录时,系统将要求他们重新注册
(无论他们是什么类型的账户)
/oidcauth <player> setAccountType <oidc/password> - 切换给定玩家的账户类型
警告:这也将注销玩家!他们在更改账户类型后必须重新注册!
配置
该插件使用两个 YAML 格式的配置文。如果文件不存在,插件将尝试创建它们。
请查看它们,其中包含详细的注释和说明。
static-config.yml - 主要包含连接详细信息。仅在完整服务器重启时应用更改。
dynamic-config.yml - 主要包含服务器访问详细信息和消息。在执行 /velocity reload 时应用。
依赖项
此插件需要设置 MySQL/MariaDB 数据库和 OIDC 提供商。
它还依赖于另一个插件 LuckPerms 来管理权限。
为了让权限正常工作,至少需要在代理上设置 LuckPerms。
Minecraft Velocity OIDC Auth
This plugin allows you to gate access to backend servers from the proxy side using OIDC/Oauth2 and LDAP.
Alternatively, provides a way to sign in using password (more on this later).
Made to use with Velocity proxy.
How it works
Velocity allows for forced hosts, which sends joining players directly to a specified backend server, based on the
hostname they joined the server with. Since the plugin only allows players to proceed to said backed servers
after authentication, it first saves the desired server to a cache, and redirects players to a limbo server.
The players are kept here until they successfully authenticate.
Authentication using OIDC:
Upon the player joining, they get sent a link in the game's chat. Clicking this
opens the OIDC login page in their browser. After successful login, the callback server receives the necessary
data from the OIDC provider.
If this is the first time the player joined the game using a given Minecraft username, the username gets tied
to the OIDC account. If the Minecraft username was already registered with an OIDC account, it checks if the
correct account was used for sign in.
After that, the plugin queries the LDAP server using the OIDC account's uid (usually username) to grant
access to otherwise restricted backend servers based on configuration.
Following this the player gets sent to the initially desired backend server.
Authentication using password:
By default, every account uses OIDC for authentication. Any player's account can be toggled to use password
authentication by an admin. This feature was implemented so admins can give access to certain players who might
not have an OIDC based account. Only use if you want to give access to a player who in no way can have an OIDC account
Upon the player joining, if the player has not registered yet, they get asked to do so using /register <password> <password>.
If the player is already registered, they get asked to log in using /login <password>.
After successfully logging in, the player is sent to the initially desired backend server.
Sessions
For convenience, once an authentication succeeds, a session is created for the user that is tied to their device.
This means they can disconnect from the server, and upon reconnecting, they will not need to authenticate again
if the session is still valid. By default, a session is valid for 12 hours, this can be changed in the configuration.
Server permissions (LDAP)
The plugin also gates access to backend servers using permissions. These can be set in the configuration file.
Default servers are servers that every player who authenticated can access. Restricted servers are servers
that only players with the right permissions can access.
For every server, the plugin creates a LuckPerms group, and gives that group access to the given
backend server. This is done using oidcauth.serverperm.<servername> permission, this is what the plugin checks
any time someone tries to join a given backend server.
If a player is authenticated using OIDC, the plugin will sync the user's permission from LDAP, and gives permission
to players for backend servers using LucksPerms API.
If a player is using password authentication, they can still access default servers, but access to restricted
servers will not be synced. You can give them access manually using LuckPerms.
For example:
If there is a server named survival, then the permission you need to give the player isoidcauth.serverperm.survival
Permissions and commands
Every player who uses OIDC authentication can access the following commands:
/login - Sends a login link in game chat
/logout - Invalidates current session, and sends player back to the limbo server for reauthenticating
Every player who uses password authentication can access the following commands:
/login <password> - Log in using password
/register <password> <password> - Register using a password
/logout - Invalidates current session, and sends player back to the limbo server for reauthenticating
If a player has the permission oidcauth.manageauth, it grants them access to the following commands
(only admins should have these permissions):
/oidcauth <player> unregister - Unregisters a player. On next login, they will be asked to re-register
(no matter what account type they have)
/oidcauth <player> setAccountType <oidc/password> - Switches between account type for the give player
WARNING: This will also unregister the player! They will have to re-register after changing account types!
Configuration
The plugin uses two configuration files using YAML formatting. If the files don't exist, the plugin will try to create them.
Check them out, it is commented and explained thoroughly.
static-config.yml - Mostly contains connection details. Only applies changes on full server restart.
dynamic-config.yml - Mostly contains server access details and messages. Applies when the /velocity reload is issued.
Dependencies
This plugin requires a MySQL/MariaDB database and an OIDC provider to be set up.
It also depends on another plugin, LuckPerms to manage permissions
LuckPerms needs to be set up on at least the proxy for the permissions to work.
评论 0
登录后参与评分
还没有评论,来抢沙发吧