From 3da9dafc605d9160f317388a302578df55e46b98 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Mon, 9 May 2022 20:20:21 +0200 Subject: 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. --- routers/web/web.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'routers/web/web.go') diff --git a/routers/web/web.go b/routers/web/web.go index 38754025ee..97ea1e9035 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -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) }) -- cgit v1.2.3