-
-
Notifications
You must be signed in to change notification settings - Fork 356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Discover webfinger through host-meta #1588
[feature] Discover webfinger through host-meta #1588
Conversation
5c3a62a
to
ccf5573
Compare
I've added a test by redirecting to a different |
7353e02
to
b7214ca
Compare
b7214ca
to
3bc79ec
Compare
899495b
to
f15bd91
Compare
f15bd91
to
cd9e456
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far :) I'm wondering, do we need/want to cache cases where the webfinger URL didn't require any host-meta looking up, and just the initial constructed webfinger uri worked OK? I was thinking we could only cache cases where the host-meta lookup revealed a different uri from what we expected, if you see what I mean.
I've updated that now. |
454e14b
to
458f440
Compare
58029f4
to
5013c56
Compare
suite.True(wc.Has("misconfigured-instance.com"), "expect webfinger cache to have entry for misconfigured-instance.com") | ||
} | ||
|
||
func (suite *FingerTestSuite) TestFingerWithHostMetaCacheStrategy() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one's a bit long but it tests that things happen as currently intended:
- If we get a webfinger redirect, cache it
- Future successful requests extend the TTL
- Future failed requests don't touch the TTL so the entry will eventually expire
"github.com/superseriousbusiness/gotosocial/testrig" | ||
) | ||
|
||
type TransportTestSuite struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cribbed this from other test suites. I don't know if I need all this. But it works 😅
ec28755
to
4fed212
Compare
testrig.StandardDBSetup(suite.db, nil) | ||
testrig.StandardStorageSetup(suite.storage, "../../testrig/media") | ||
|
||
ts, err := suite.federator.TransportController().NewTransportForUsername(context.TODO(), "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Idk if this should be here/how to better do this. But I need a transport.Transport
to call Finger
4fed212
to
ed380f4
Compare
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 superseriousbusiness#1558.
This adds a test suite for transport and moves the finger cache tests into there instead of abusing the search test suite.
We don't really need a separate function for the oddly located webfinger response as we check the full URL string anyway
ed380f4
to
082306d
Compare
Looks good! A few comments but then should be ready to go :) |
7874c42
to
edd504d
Compare
When we receive an HTTP 410 on webfinger it means the resource we asked for (the account) is gone, but the endpoint itself responded. In such cases we want to treat the request as successful from a cache (renewal) point of view, while still returning an error from Finger. Follow-up for superseriousbusiness#1588
When we receive an HTTP 410 on webfinger it means the resource we asked for (the account) is gone, but the endpoint itself responded. In such cases we want to treat the request as successful from a cache (renewal) point of view, while still returning an error from Finger. Follow-up for #1588
Description
I'm opening this as a draft because:
I want to figure out how to properly test the fallback and ideally verify what gets set in the cacheThis 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.
Checklist
Please put an x inside each checkbox to indicate that you've read and followed it:
[ ]
->[x]
If this is a documentation change, only the first checkbox must be filled (you can delete the others if you want).
go fmt ./...
andgolangci-lint run
.