Add Webfinger endpoint (#19462)

This adds the [Webfinger](https://webfinger.net/) endpoint for federation.

Supported schemes are `acct` and `mailto`. The profile and avatar url are returned as metadata.
This commit is contained in:
KN4CK3R 2022-05-09 20:20:21 +02:00 committed by GitHub
parent a61a47f9a0
commit 3da9dafc60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 189 additions and 2 deletions

View file

@ -282,6 +282,13 @@ func RegisterRoutes(m *web.Route) {
}
}
federationEnabled := func(ctx *context.Context) {
if !setting.Federation.Enabled {
ctx.Error(http.StatusNotFound)
return
}
}
// FIXME: not all routes need go through same middleware.
// Especially some AJAX requests, we can reduce middleware number to improve performance.
// Routers.
@ -289,9 +296,10 @@ func RegisterRoutes(m *web.Route) {
m.Get("/", Home)
m.Group("/.well-known", func() {
m.Get("/openid-configuration", auth.OIDCWellKnown)
if setting.Federation.Enabled {
m.Group("", func() {
m.Get("/nodeinfo", NodeInfoLinks)
}
m.Get("/webfinger", WebfingerQuery)
}, federationEnabled)
m.Get("/change-password", func(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req, "/user/settings/account", http.StatusTemporaryRedirect)
})