mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	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:
		@@ -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)
 | 
			
		||||
		})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user