Mastodon

如何轻松地将 XMPP 服务器与 Mastodon 集成。

数据库集成

ejabberd 服务器链接到同一服务器上的 Mastodon 实例的最简单方法是使用直接与 Mastodon Postgresql 数据库交互的外部认证脚本。此方法仅在本地网络上安全工作,但已在中型 Mastodon 实例上进行了良好的测试。

ejabberd 的 Mastodon 机器人

Another easy to use option is to run a bot on your Mastodon instance that can be interacted with to register accounts via the Ejabberd API. You can find the necessary bot software here. This bot also has some other nice functionality to get details from Ejabberd, so it might be worth running even if another account integration method is used.

通过 LDAP

如果要设置新的 Mastodon 实例,您还可以考虑通过单独的 LDAP 数据库管理用户账号,如 Mastodon 官方文档中所述。有关 XMPP 服务器部分,请参阅我们的 LDAP 专用教程

Prosody

You might be able to adapt the Prosody Sharkey integration, or use the new Oauth2 passthrough feature explained below.

目前处于实验阶段。

Prosody 服务器与 Mastodon 的集成可以通过 OAuth2 完成。为此需要新的 mod_auth_oauth_external 模块(它需要最近的每晚 Prosody 构建)。

首先,需要从 Mastodon 端注册一个新应用程序。这可以在 Mastodon → 设置 → 开发 → 新应用程序中完成。重定向 URI 并不重要。Prosody 需要 read:accounts 范围,仅此而已。

然后,需要将这几行添加到 Prosody 配置中:

1authentication = "oauth_external"
2oauth_external_token_endpoint = "https://mastodon.example/oauth/token"
3oauth_external_validation_endpoint = "https://mastodon.example/api/v1/accounts/verify_credentials"
4oauth_external_username_field = "username"
5oauth_external_scope = "read:accounts"
6oauth_external_client_id = "Get client_id from https://mastodon.example/settings/applications"
7oauth_external_client_secret = "Get client_secret from https://mastodon.example/settings/applications"

现在,用户可以使用此用户名登录:email\40example.com@xmpp.example.org,它由他们在 Mastodon 服务器上注册的电子邮件地址(其中 @ 转义为 \40)和第二个 @ 后面的 XMPP 服务器的域组成。希望这个复杂的登录名将来可以简化。