Skip to content

Conversation

evan-goode
Copy link

This PR includes several fixes for authlib-injector (here called "Yggdrasil" or "Authlib") accounts. For unmojang/drasl#66.

  • Add a new config option, Main.General.AuthServer.AuthlibInjectorAPIPath, to allow specifying the path to the root of the authlib-injector API. Whereas Blessing Skin places their API at /api/yggdrasil, other authlib-injector servers (Drasl, Ely.By) do not, so this change enables compatibility with them.
  • Add docstrings for some AuthServer config options
  • Don't send an invalid ("dummy") profile key signature for authlib-injector accounts; this breaks vanilla Minecraft servers
  • Replace the custom HTTP implementation in DoHTTPSRequest with System.Net.Http.HttpClient, but still respect the configured proxy.
    • Note: I am unsure of this change. According to a comment, the custom HTTP client was used "since we must directly use a TcpClient because of the proxy." But it seems straightforward to pass a custom TcpClient to HttpClient---that's what I did here. It sent the request through my TCP proxy when I tested it. Is this correct?
  • Fetch certificates for authlib-injector accounts if the authlib-injector server has the feature.enable_profile_key flag set

See commit message for more details. I'm a C# amateur, so a thorough review would be appreciated :)

The previous authlib-injector authentication implementation always
assumed that the authlib-injector API location was located at
https://authlibinjectorserver.example.com/api/yggdrasil. Blessing Skin
structures their API like that, but other authlib-injector-compatible
Yggdrasil implementations do not. Per the authlib-injector
specification, the API root can be located at any path, and that path
should be pointed to by the `X-Authlib-Injector-API-Location` header
[1].

With this change, the default AuthlibInjectorAPIPath is kept as
`/api/yggdrasil`, so users will not need to update their config.

See also
unmojang/drasl#66 (comment).

[1] https://github.com/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83
Instead of sending an invalid profile key signature, it's better to just
send no signature. If we send an invalid signature, the vanilla server will
throw an error even if `enforce-secure-profile` is `false`.

See also yushijinhun/authlib-injector#266.
The DIY HTTP client had many problems, as is expected when
rolling your own HTTP implementation without following the spec.

Fortunately, we can use SocketsHttpHandler.ConnectCallback to make
HttpClient use our custom TCP client.
Some authlib-injector-compatible authentication servers implement the
POST /player/certificates route used for fetching player certificates.

To comply with the authlib-injector Yggdrasil server specification [1], we
first query the authlib-injector metadata and check for the
`feature.enable_profile_key` flag. If the flag is set, the
authentication server supports the /player/certificates route.

In this case, checking the authlib-injector metadata isn't really
necessary; if the /player/certificates request fails for any reason, we
simply ignore it anyway.

[1] https://github.com/yushijinhun/authlib-injector/wiki/Yggdrasil-%E6%9C%8D%E5%8A%A1%E7%AB%AF%E6%8A%80%E6%9C%AF%E8%A7%84%E8%8C%83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant