Wykres commitów

76 Commity (main)

Autor SHA1 Wiadomość Data
Ryan Barrett c345d95b5e
webfinger: add a self link with type application/activity+json
for interop with some fediverse servers like Pleroma (and Akkoma etc) that are unnecessarily picky about which self content type they use from XRD vs JRD.

for #995. thanks @qazmlp!
2024-05-05 08:39:38 -07:00
Ryan Barrett c065c712f1
more id/handle translation tweaks for protocol bot users
hopefully fixes Accept actor for responding to bot user follows in AP
2024-04-25 14:29:48 -07:00
Ryan Barrett 9fe715137a
webfinger: check that AP protocol is enabled 2024-04-23 15:31:24 -07:00
Ryan Barrett 34692abc60
handle protocol bot users in webfinger, ids.translate_handle, Web.owns_handle
for #880
2024-04-22 14:01:09 -07:00
Ryan Barrett 95e46c5ebb
Revert "cache outbound HTTP request responses, locally to each inbound request"
This reverts commit 30debfc8fa.

seemed promising, but broke in production. Saw a lot of `IncompleteRead`s on both GETs and POSTs. Rolled back for now.

```
('Connection broken: IncompleteRead(9172 bytes read, -4586 more expected)', IncompleteRead(9172 bytes read, -4586 more expected))
...
File "oauth_dropins/webutil/util.py", line 1673, in call
  resp = getattr((session or requests), fn)(url, *args, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/session.py", line 102, in get
  return self.request('GET', url, params=params, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/session.py", line 158, in request
  return super().request(method, url, *args, headers=headers, **kwargs)  # type: ignore
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests/sessions.py", line 589, in request
  resp = self.send(prep, **send_kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/session.py", line 205, in send
  response = self._send_and_cache(request, actions, cached_response, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/session.py", line 233, in _send_and_cache
  self.cache.save_response(response, actions.cache_key, actions.expires)
File "requests_cache/backends/base.py", line 89, in save_response
  cached_response = CachedResponse.from_response(response, expires=expires)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/models/response.py", line 102, in from_response
  obj.raw = CachedHTTPResponse.from_response(response)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests_cache/models/raw_response.py", line 69, in from_response
  _ = response.content  # This property reads, decodes, and stores response content
      ^^^^^^^^^^^^^^^^
File "requests/models.py", line 899, in content
  self._content = b"".join(self.iter_content(CONTENT_CHUNK_SIZE)) or b""
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "requests/models.py", line 818, in generate
  raise ChunkedEncodingError(e)
```
2024-03-11 15:31:30 -07:00
Ryan Barrett 30debfc8fa
cache outbound HTTP request responses, locally to each inbound request
using requests-cache. pretty straightforward! for #588
2024-03-08 12:34:49 -08:00
Ryan Barrett 9489204d64
AP: add profile to Content-Type: application/ld+json
for #895
2024-02-27 11:38:00 -08:00
Ryan Barrett 675e39809e
web UI: tweak user links in user page header 2024-02-11 14:39:09 -08:00
Ryan Barrett fcef6c21ab
Revert "heuristic: assume no AP actor id is the root path on its host"
This reverts commit b7e890b4bb.

it was a nice idea, but we're now hitting AP actor ids that are the root path on their host. this is evidently how microblog.pub does AP; 0x3b0b's site https://bw3.dev/ is an example. general info on https://docs.microblog.pub/user_guide.html#activitypub but not this specifically.

fixes https://console.cloud.google.com/errors/detail/CLSnttKfy4v90wE;time=P30D?project=bridgy-federated
2024-01-26 12:59:54 -08:00
Ryan Barrett d0f7264db7
webfinger: handle users without handles
fixes https://console.cloud.google.com/errors/detail/CJ7P7OGD5oz_Dw;time=P30D?project=bridgy-federated
2023-12-01 15:46:37 -08:00
Ryan Barrett 2f4bae8dc9
change Web.ap_subdomain default to 'web' 2023-11-30 20:08:41 -08:00
Ryan Barrett 6e236e2d70
switch User.ap_actor to id_as, use Web.ap_subdomain property 2023-11-30 17:10:18 -08:00
Ryan Barrett d33832be1c
add Web.ap_subdomain property, use it in webfinger
Originally, BF served Web users' AP actor ids on fed.brid.gy, eg
https://fed.brid.gy/snarfed.org . When we started adding new protocols, we
switched to per-protocol subdomains, eg https://web.brid.gy/snarfed.org .
However, we need to preserve the old users' actor ids as is. So, this property
tracks which subdomain a given Web user's AP actor uses.
2023-11-30 15:43:38 -08:00
Ryan Barrett 520b2fd3b0
User.ap_address() => handle_as(ActivityPub) 2023-11-29 21:06:55 -08:00
Ryan Barrett 4d095fa3d9
misc cleanup
* remove obsolete TODOs, commented out code
* remove obsolete circular imports of per-protocol modules
* minimize Object put in Protocol.load
* remove duplicated Protocol.load tests in test_activitypub
* re-enable rest of ActivityPubUtilsTest.test_postprocess_as2_idempotent
* drop default cls=Web in TestCase.make_user
2023-11-15 14:23:08 -08:00
Ryan Barrett 2d8fb1f57f
webfinger: handle unknown protocol subdomain 2023-10-12 17:55:44 -07:00
Ryan Barrett 247e8a465f
test_webfinger: tests for bad protocol subdomains 2023-09-29 12:33:55 -07:00
Ryan Barrett f85ab9ef41
noop: add a couple minor tests and comments 2023-09-29 11:32:29 -07:00
Ryan Barrett a823dd1d65
use protocol subdomains in AP inbox
...and other misc protocol subdomain fixes
2023-09-27 13:55:16 -07:00
Ryan Barrett ad0a942034
switch webfinger and AP actors to mostly protocol subdomains
except Web, it still mostly serves on fed.brid.gy for backcompat, don't want to change existing Web users' AP actor ids.
2023-09-26 16:43:48 -07:00
Ryan Barrett 9b8b02e99f
consolidate ap_address in ATProto, Fake, Web (partially) into User 2023-09-25 12:45:47 -07:00
Ryan Barrett e9e8827ef9
standardize more on 'handle' and 'id' terms
* User.readable_id => handle
* User.readable_or_key_id => handle_or_id
2023-09-25 12:33:24 -07:00
Ryan Barrett e257d43f21
webfinger: if user part isn't an id, try resolving it as a handle 2023-09-22 15:14:15 -07:00
Ryan Barrett e97270b344
add webfinger.fetch_actor_url, use it in follow
also add a basic test for webfinger.fetch
2023-09-22 12:48:00 -07:00
Ryan Barrett cba4845394
disable ndb in-memory cache
it has a bug/weird behavior that we want to avoid, at least for now.

https://github.com/googleapis/python-ndb/issues/888
https://github.com/snarfed/bridgy-fed/issues/558
2023-06-22 14:27:02 -07:00
Ryan Barrett ab1c28ee4d
noop, lint fixes from flake8
remaining:

$ flake8 --extend-ignore=E501 *.py tests/*.py
"pyflakes" failed during execution due to "'FlakesChecker' object has no attribute 'NAMEDEXPR'"
Run flake8 with greater verbosity to see more details
activitypub.py:15:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
activitypub.py:36:1: F401 'web' imported but unused
activitypub.py:48:1: E302 expected 2 blank lines, found 1
activitypub.py:51:9: F811 redefinition of unused 'web' from line 36
app.py:6:1: F401 'flask_app.app' imported but unused
app.py:9:1: F401 'activitypub' imported but unused
app.py:9:1: F401 'convert' imported but unused
app.py:9:1: F401 'follow' imported but unused
app.py:9:1: F401 'pages' imported but unused
app.py:9:1: F401 'redirect' imported but unused
app.py:9:1: F401 'superfeedr' imported but unused
app.py:9:1: F401 'ui' imported but unused
app.py:9:1: F401 'webfinger' imported but unused
app.py:9:1: F401 'web' imported but unused
app.py:9:1: F401 'xrpc_actor' imported but unused
app.py:9:1: F401 'xrpc_feed' imported but unused
app.py:9:1: F401 'xrpc_graph' imported but unused
app.py:9:19: E401 multiple imports on one line
models.py:19:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
models.py:364:31: E114 indentation is not a multiple of four (comment)
models.py:364:31: E116 unexpected indentation (comment)
protocol.py:17:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
redirect.py:26:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
web.py:18:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
webfinger.py:13:1: F401 'oauth_dropins.webutil.util.json_loads' imported but unused
webfinger.py:110:13: E122 continuation line missing indentation or outdented
webfinger.py:111:13: E122 continuation line missing indentation or outdented
webfinger.py:131:13: E122 continuation line missing indentation or outdented
webfinger.py:132:13: E122 continuation line missing indentation or outdented
webfinger.py:133:13: E122 continuation line missing indentation or outdented
webfinger.py:134:13: E122 continuation line missing indentation or outdented
tests/__init__.py:2:1: F401 'oauth_dropins.webutil.tests' imported but unused
tests/test_follow.py:11:1: F401 'oauth_dropins.webutil.util.json_dumps' imported but unused
tests/test_follow.py:14:1: F401 '.testutil.Fake' imported but unused
tests/test_models.py:156:15: E122 continuation line missing indentation or outdented
tests/test_models.py:157:15: E122 continuation line missing indentation or outdented
tests/test_models.py:158:11: E122 continuation line missing indentation or outdented
tests/test_web.py:12:1: F401 'oauth_dropins.webutil.util.json_dumps' imported but unused
tests/test_web.py:17:1: F401 '.testutil' imported but unused
tests/test_web.py:1513:13: E128 continuation line under-indented for visual indent
tests/test_web.py:1514:9: E124 closing bracket does not match visual indentation
tests/testutil.py:106:1: E402 module level import not at top of file
tests/testutil.py:107:1: E402 module level import not at top of file
tests/testutil.py:108:1: E402 module level import not at top of file
tests/testutil.py:109:1: E402 module level import not at top of file
tests/testutil.py:110:1: E402 module level import not at top of file
tests/testutil.py:301:24: E203 whitespace before ':'
tests/testutil.py:301:25: E701 multiple statements on one line (colon)
tests/testutil.py:301:25: E231 missing whitespace after ':'
2023-06-20 11:29:31 -07:00
Ryan Barrett d3c4415cd3
migrate User.actor_as2 to obj key pointing to Object
for #547
2023-06-15 21:23:31 -07:00
Ryan Barrett 60a4a2bb9f
move domain non-TLD validation from webfinger into Web
fixes https://console.cloud.google.com/errors/detail/CMG7h4PJju67Og;time=P30D?project=bridgy-federated
2023-06-15 11:25:31 -07:00
Ryan Barrett 0902994af0
webfinger: infer protocol from brid.gy subdomain in request or resource
first commit for inferring protocol. exciting! for #512
2023-06-12 15:50:00 -07:00
Ryan Barrett 239976ca43
drop old /acct: URL route for serving Webfinger
honestly no clue where this came from, haven't found it in the spec, couldn't figure out when/why I originally added it in git history. 🤷
2023-06-12 13:32:21 -07:00
Ryan Barrett 861552f455
webfinger verification: handle URL-encoded Location header
fixes #535
2023-06-08 11:07:24 -07:00
Ryan Barrett 51c2773594
AP users: /r/: switch external user to indirect user
for #512
2023-06-04 20:58:21 -07:00
Ryan Barrett daba73ce38
update a few user page links in the web UI, /user/ => /web/
for #512
2023-06-03 08:03:38 -07:00
Ryan Barrett d9cd5d14b9
AP users: fetch user on demand on /[actor] if we don't already have it
also change Web.fetch() to allow missing mf2 instead of raising exception. we now create Web users with None for mf2 property if the site has no mf2.

for #512
2023-06-02 12:55:07 -07:00
Ryan Barrett 29f1a1d4ac
AP users: start parameterizing URLs, including UI pages and AP endpoints
user pages now have /[protocol]/ prefix, AP endpoints have /ap/ prefix. for #512
2023-05-30 16:38:58 -07:00
Ryan Barrett 93f621aaf5
AP users: start to replace external with indirect, starting with webfinger
#512
2023-05-29 20:16:15 -07:00
Ryan Barrett 624355d85a
AP users: add new User.direct property
direct users signed up or otherwise interacted with BF explicitly, indirect users didn't
2023-05-29 19:37:41 -07:00
Ryan Barrett c8b2103e13
rename Webmention class => Web, webmention.py => web.py 2023-05-26 17:40:29 -07:00
Ryan Barrett 6333b7126a
AP users: serve webfinger for external users
#512
2023-05-23 11:53:32 -07:00
Ryan Barrett aeb2fd480a
tests: rename remaining test data hostnames to clarify web vs fediverse
followup to f6e5727602
2023-03-19 15:43:55 -07:00
Ryan Barrett 5169c2e44e
misc noop tweaks, mostly tests 2023-03-19 09:34:42 -07:00
Ryan Barrett 106bbe623b
tests optimization: reuse same RSA key across Users
speeds up tests from ~22s to ~6s (!) on my laptop. for #398
2023-03-10 15:13:45 -08:00
Ryan Barrett fd27dabe61
switch JSON properties to custom JSONProperty that works in web console UI
https://github.com/googleapis/python-ndb/issues/874#issuecomment-1442753255
2023-02-24 07:25:29 -06:00
Ryan Barrett 5d455b7d18
switch webfinger to serve entirely out of Users in datastore
no more fetching and converting users' home pages on demand!

for #392, helps #378
2023-02-09 20:00:58 -08:00
Ryan Barrett d523cc085a
remove OStatus parts of Webfinger
background on Mastodon interop:
* https://docs.joinmastodon.org/spec/webfinger/
* https://github.com/mastodon/mastodon/pull/11280
* https://docs.joinmastodon.org/spec/activitypub/#publicKey
2023-01-25 20:59:40 -08:00
Ryan Barrett f0a5f1745e
webfinger: return data even if site has no representative h-card
fixes #384
2023-01-25 20:41:29 -08:00
Ryan Barrett 38c7c1bc5f
webfinger: return 404 if User not found
for #384
2023-01-25 20:00:54 -08:00
Ryan Barrett bb2d3e03de
noop: convert a few %s'es to f-strings
thanks flynt! https://github.com/ikamensh/flynt
2023-01-24 12:17:24 -08:00
Ryan Barrett fe5c3947a8
drop OStatus! it's been unused for years
fixes #282
2023-01-04 19:22:11 -08:00
Ryan Barrett bd4d30f61c
add remote follow link rel to webfinger
https://socialhub.activitypub.rocks/t/what-is-the-current-spec-for-remote-follow/2020/11?u=snarfed
https://github.com/snarfed/bridgy-fed/issues/60#issuecomment-1325589750
and #60
2022-12-01 10:09:57 -08:00