diff options
author | 2023-03-08 13:57:41 +0100 | |
---|---|---|
committer | 2023-03-08 12:57:41 +0000 | |
commit | e397272fe8550e4f81958d5d00bf3233e1bd0bfc (patch) | |
tree | 156bc2ebc49563a1ed3decd2171bf2da21b071cf /internal/api | |
parent | [chore] Update uptrace/bun and modernc/sqlite dependencies (#1598) (diff) | |
download | gotosocial-e397272fe8550e4f81958d5d00bf3233e1bd0bfc.tar.xz |
[feature] Discover webfinger through host-meta (#1588)
* [feature] Discover webfinger through host-meta
This implements a fallback for discovering the webfinger endpoint in
case the /.well-known/webfinger endpoint wasn't properly redirected.
Some instances do this because the recommendation used to be to use
host-meta for the webfinger redirect in the before times.
Closes #1558.
* [bug] Ensure we only ever update cache on success
* [chore] Move finger tests to their own place
This adds a test suite for transport and moves the finger cache tests
into there instead of abusing the search test suite.
* [chore] cleanup the test a bit more
We don't really need a separate function for the oddly located webfinger
response as we check the full URL string anyway
* Address review comments
* [chore] update config example
* [chore] access DB only through state in controller
Diffstat (limited to 'internal/api')
-rw-r--r-- | internal/api/model/well-known.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/internal/api/model/well-known.go b/internal/api/model/well-known.go index bf61a6085..f3481ad72 100644 --- a/internal/api/model/well-known.go +++ b/internal/api/model/well-known.go @@ -18,6 +18,8 @@ package model +import "encoding/xml" + // WellKnownResponse represents the response to either a webfinger request for an 'acct' resource, or a request to nodeinfo. // For example, it would be returned from https://example.org/.well-known/webfinger?resource=acct:some_username@example.org // @@ -32,12 +34,12 @@ type WellKnownResponse struct { // Link represents one 'link' in a slice of links returned from a lookup request. // -// See https://webfinger.net/ +// See https://webfinger.net/ and https://www.rfc-editor.org/rfc/rfc6415.html#section-3.1 type Link struct { - Rel string `json:"rel"` - Type string `json:"type,omitempty"` - Href string `json:"href,omitempty"` - Template string `json:"template,omitempty"` + Rel string `json:"rel" xml:"rel,attr"` + Type string `json:"type,omitempty" xml:"type,attr,omitempty"` + Href string `json:"href,omitempty" xml:"href,attr,omitempty"` + Template string `json:"template,omitempty" xml:"template,attr,omitempty"` } // Nodeinfo represents a version 2.1 or version 2.0 nodeinfo schema. @@ -87,3 +89,13 @@ type NodeInfoUsage struct { type NodeInfoUsers struct { Total int `json:"total"` } + +// HostMeta represents a hostmeta document. +// See: https://www.rfc-editor.org/rfc/rfc6415.html#section-3 +// +// swagger:model hostmeta +type HostMeta struct { + XMLName xml.Name `xml:"XRD"` + XMLNS string `xml:"xmlns,attr"` + Link []Link `xml:"Link"` +} |