Option to disable auth from FallbackAPIServers

Resolves https://github.com/unmojang/drasl/issues/146
This commit is contained in:
Evan Goode 2025-04-06 19:17:30 -04:00
parent 3ed22110b3
commit 9436529e59
2 changed files with 8 additions and 3 deletions

View File

@ -54,6 +54,8 @@ Other available options:
- `DenyUnknownUsers`: Don't allow clients using this authentication server to log in to a Minecraft server using Drasl unless there is a Drasl user with the client's player name. This option effectively allows you to use Drasl as a whitelist for your Minecraft server. You could allow users to authenticate using, for example, Mojang's authentication server, but only if they are also registered on Drasl. Boolean. Default value: `false`.
- `EnableAuthentication`: Allow Minecraft clients using this authentication server to log in to a Minecraft server using Drasl. Disable this option if you, for example, want to use `ForwardSkins = true` but don't want to allow authentication from the fallback API server. Boolean. Default value: `true`.
- `OfflineSkins`: Try to resolve skins for "offline" UUIDs. When `online-mode` is set to `false` in `server.properties` (sometimes called "offline mode"), players' UUIDs are computed deterministically from their player names instead of being managed by the authentication server. If this option is enabled and a skin for an unknown UUID is requested, Drasl will search for a matching player by offline UUID. This option is required to see other players' skins on offline servers. Boolean. Default value: `true`.
<!-- - `[TransientLogin]`: Allow certain usernames to authenticate with a shared password, without registering. Useful for supporting bot accounts. -->

View File

@ -142,13 +142,16 @@ func (app *App) hasJoined(c *echo.Context, playerName string, serverID string, l
}
if result.Error != nil || !player.ServerID.Valid || serverID != player.ServerID.String {
for _, fallbackAPIServer := range app.Config.FallbackAPIServers {
if fallbackAPIServer.DenyUnknownUsers && result.Error != nil {
for _, fallbackAPIServer := range app.FallbackAPIServers {
if !fallbackAPIServer.Config.EnableAuthentication {
continue
}
if fallbackAPIServer.Config.DenyUnknownUsers && result.Error != nil {
// If DenyUnknownUsers is enabled and the player name is
// not known, don't query the fallback server.
continue
}
base, err := url.Parse(fallbackAPIServer.SessionURL)
base, err := url.Parse(fallbackAPIServer.Config.SessionURL)
if err != nil {
log.Println(err)
continue