summaryrefslogtreecommitdiffstats
path: root/routers/web/web.go
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-05-09 20:20:21 +0200
committerGitHub <noreply@github.com>2022-05-09 20:20:21 +0200
commit3da9dafc605d9160f317388a302578df55e46b98 (patch)
treec7fb4e63541e09d5d25c8785f820a4dae08fb98e /routers/web/web.go
parenta61a47f9a00a387015a2f00f656f9f51dfd2b341 (diff)
downloadgitea-3da9dafc605d9160f317388a302578df55e46b98.tar.gz
gitea-3da9dafc605d9160f317388a302578df55e46b98.zip
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.
Diffstat (limited to 'routers/web/web.go')
-rw-r--r--routers/web/web.go12
1 files changed, 10 insertions, 2 deletions
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)
})