Wykres commitów

127 Commity (0cf13a33a4c7e890fa5bfe99a4a42a77ff50c9f9)

Autor SHA1 Wiadomość Data
Jason Robinson 2fb2da6955 Work on ActivityPub HTTP signatures and payload delivery
Also removes some legacy cruft for the failed Diaspora URI's as ID's experiment.

Refs: #7
2019-03-06 22:42:33 +02:00
Jason Robinson 2fa8271af7 Refactor handle_receive to require a RequestType
The ActivityPub protocol handlers require access to HTTP headers,
method and url from the incoming request. Thus require passing in
a RequestType object, which has the same structure as a Django
HttpRequest for compatibility.

This is a breaking backwards compatible change requiring Diaspora
payloads be wrapped in a RequestType object.

Refs: #7
2019-03-03 03:04:08 +02:00
Jason Robinson dbaae4842b Changelog for the various changes 2019-03-02 23:52:09 +02:00
Jason Robinson 5baa0b5fe6 Added network utility `network.fetch_host_ip` to fetch IP by hostname 2019-02-13 23:05:10 +02:00
Jason Robinson c3f59e832e Change activitypub_object_view get_object_function call signature
Pass now full request object instead of the object ID. This allows
the app to check permissions for the object.
2018-10-10 22:43:17 +03:00
Jason Robinson 6dd20c3521 Simplify process_payload call by passing in just request 2018-10-09 22:53:54 +03:00
Jason Robinson aff1a8e59e Tweak activitypub_object_view process_payload call signature
Now passes `response.content` as is and also passes in the request
object.
2018-10-09 22:46:23 +03:00
Jason Robinson 17c23b3be8 Django activitypub_object_view now processes POST to /inbox/ 2018-10-09 22:24:46 +03:00
Jason Robinson cae76b3da8 Add changelog entries for recent changes 2018-09-30 20:50:32 +03:00
Jason Robinson ceb5d0446e Add support for AS2 document webfinger rel used by Mastodon et al
Also fix reference to RFC by renaming RFC3033 to RFC7033 :P
2018-09-30 16:20:03 +03:00
Jason Robinson 2be12c356d Changelogs for changes 2018-09-24 23:13:39 +03:00
Jason Robinson 258a067412 Merge branch 'master' into patch-017 2018-08-11 21:50:35 +03:00
Jason Robinson bc38ac990b Switch crypto library `pycrypto` to `pycryptodome`
This is a more up to date fork of the former. This fixes CVE-2018-6594 found in the former.

**Deployment note.** When updating an application, you *must* uninstall `pycrypto` first, otherwise there will be a conflict if both the versions are installed at the same time. To uninstall, do `pip uninstall pycrypto`.

Release 0.17.0
2018-08-11 21:47:16 +03:00
Jason Robinson 454dc8ccbc Drop compatibility for Python <= 3.5 2018-07-23 18:33:47 +03:00
Jason Robinson 6cbe9cee9d Start new development cycle 2018-07-23 18:32:54 +03:00
Jason Robinson afee56cac6 Release 0.16.0 2018-07-23 16:28:08 +03:00
Jason Robinson bfb4792f16 Fix Diaspora `Profile` mapping regarding `last_name` property
Previously only `first_name` was used when creating the `Profile.name`
value. Now both `first_name` and `last_name` are used.

When creating outgoing payloads, the `Profile.name` will still be placed
in `first_name` to avoid trying to artificially split it.
2018-06-24 22:12:43 +03:00
Jason Robinson af920604a2 Extract mentions from Diaspora payloads that have text content
The mentions will be available in the entity as `_mentions` which is
a set of Diaspora ID's in URI format.
2018-06-23 23:09:18 +03:00
Jason Robinson a2c8d1c061 Switch to ipdata.co service for country lookups 2018-05-27 20:34:47 +03:00
Jason Robinson 6353e47a85 Add parser for Mastodon server info and activity documents 2018-05-27 01:46:55 +03:00
Jason Robinson 7590e65f79 Don't automatically fetch ip and country when parsing meta docs
Otherwise we spam the country providing service too much.
2018-05-10 11:48:55 +03:00
Jason Robinson 33c6ed817a Add fetching of IP and country
Network utils has a method `fetch_host_ip_and_country` which will
fetch both. The country fetching uses the `ip-api.com` free service
to resolve country information.
2018-05-07 22:58:25 +03:00
Jason Robinson 435c3d6d43 Add NodeInfo2 generator and Django view
See https://github.com/jaywink/nodeinfo2
2018-04-08 15:02:18 +03:00
Jason Robinson a798b1d4b5
Merge pull request #122 from jaywink/server-meta-parsers
Add fetchers for nodeinfo, nodeinfo2 and statisticsjson
2018-04-08 13:30:35 +03:00
Jason Robinson eef1f7d820 Add fetchers for nodeinfo, nodeinfo2 and statisticsjson 2018-04-08 12:57:08 +03:00
Jason Robinson 2a02f866aa Allow port in Diaspora handles as per the protocol specification
Previously handles were validated like emails.
2018-03-09 22:17:08 +02:00
Jason Robinson 4c2a42dfb9 Fix validation of `Retraction` with entity type `Share` 2018-03-09 21:50:54 +02:00
Jason Robinson ab3e2451b8 Ensure when processing payload empty payload tags don't create None values 2018-02-27 23:03:23 +02:00
Jason Robinson c15aa14e8e Switch Diaspora protocol to send new style entities
We've already accepted these on incoming payloads for a long time and so do all the other platforms now, so now we always send out entities with the new property names. This can break federation with really old servers that don't understand these keys yet.

Closes #59
2018-02-24 15:04:07 +02:00
Jason Robinson aa8e8a7960 Use unquote instead of unquote_plus when preparing XML payload
Change unquote method used when preparing Diaspora XML payloads for verification.

Some platforms deliver payloads not using the urlsafe base64 standard which caused problems when validating the unquoted signature. Ensure maximum compatibility by allowing non-standard urlsafe quoted payloads.

Closes #115
2018-02-24 14:02:06 +02:00
Jason Robinson f80211b178 Add RFC3033 webfinger generator
Also provided is a Django view and url configuration for easy addition into Django projects. Django is not a hard dependency of this library, usage of the Django view obviously requires installing Django itself. For configuration details see documentation.

Closes #108
2018-02-17 01:38:37 +02:00
Jason Robinson 47f79205f1 Changelog entries for last commits 2018-02-13 23:11:53 +02:00
Jason Robinson c1efc1add1 Enable generating encrypted JSON payloads with the Diaspora protocol
This adds possibility for private message support.

JSON encrypted payload encryption and decryption is handled by the Diaspora `EncryptedPayload` class.

Refs: #82
2018-02-12 23:14:27 +02:00
Jason Robinson c6bbd3ac4b Send outbound Diaspora payloads in new format
Remove possibility to generate legacy MagicEnvelope payloads.

Refs: #82
2018-02-12 23:00:22 +02:00
Jason Robinson f6091d270a Release 0.15.0 2018-02-12 22:37:11 +02:00
Jason Robinson 29b6f79705 Support fetching new style Diaspora protocol Webfinger (RFC 3033) (#110)
The legaxy Webfinger is still used as fallback if the new Webfinger is not found.

Refs: #108
2018-02-02 18:28:36 +02:00
Jason Robinson 9c132df16e
Ensure handle is always lower cased when fetching remote profile (#109)
Using `retrieve_remote_profile`. Warning will be logged if an upper case handle is passed in.
2018-01-20 15:29:56 +02:00
Jason Robinson 1da5a05cd5
Changelog for #107 2018-01-04 23:17:26 +02:00
Jason Robinson a65b040969 Support Diaspora URI scheme
Add 'id' and 'target_id' to Diaspora entities. Refactor retrieve content fetcher to use the Diaspora URI scheme based ID.
2017-10-22 14:40:12 +03:00
Jason Robinson e343369f5b New high level fetcher function retrieve_remote_content
The given ID will be fetched using the correct entity class specific remote endpoint, validated to be from the correct author against their public key and then an instance of the entity class will be constructed and returned.

Also related changes and refactoring:

* New Diaspora protocol helper `federation.utils.diaspora.retrieve_and_parse_content`. See notes regarding the high level fetcher above.
* New Diaspora protocol helper `federation.utils.fetch_public_key`. Given a `handle` as a parameter, will fetch the remote profile and return the `public_key` from it.
* Refactoring for Diaspora `MagicEnvelope` class.
* Diaspora procotol receive flow now uses the `MagicEnvelope` class to verify payloads.
* Diaspora protocol receive flow now fetches the sender public key over the network if a `sender_key_fetcher` function is not passed in. Previously an error would be raised.

Closes #103
2017-10-21 22:04:05 +03:00
Jason Robinson fb2f9d091d Added base entity Share
Maps to a `DiasporaReshare` for the Diaspora protocol.

The `Share` entity supports all the properties that a Diaspora reshare does. Additionally two other properties are supported: `raw_content` and `entity_type`. The former can be used for a "quoted share" case where the sharer adds their own note to the share. The latter can be used to reference the type of object that was shared, to help the receiver, if it is not sharing a `Post` entity. The value must be a base entity class name.

Closes #94
2017-08-22 12:12:47 +03:00
Jason Robinson b3c4ac76a6 Fix DiasporaProfile.from_base
Converting base entity `Profile` to `DiasporaProfile` for outbound sending missed two attributes, `image_urls` and `tag_list`. Those are now included so that the values transfer into the built payload.
2017-08-09 00:02:49 +03:00
Jason Robinson 5d3db57e65 Release 0.14.1... 2017-08-06 16:20:30 +03:00
Jason Robinson c6343bbd74 Fix regression in handling Diaspora relayables
Due to security fix in 0.14.0. Payload and entity handle need to be allowed to be different when handling relayables.
2017-08-06 16:06:45 +03:00
Jason Robinson 36da89e0bb Release 0.14.0 2017-08-06 15:35:54 +03:00
Jason Robinson 934bd69bba Verify payload and entity handle are the same
Add proper checks to make sure Diaspora protocol payload handle and entity handle are the same. Even though we already verified the signature of the sender, we didn't ensure that the sender isn't trying to fake an entity authored by someone else.

The Diaspora protocol functions `message_to_objects` and `element_to_objects` now require a new parameter, the payload sender handle. These functions should normally not be needed to be used directly.
2017-08-06 14:04:50 +03:00
Jason Robinson 977c584d96 Refactor handle_send and handle_create_payload signatur
**Breaking change.** The high level `federation.outbound` functions `handle_send` and `handle_create_payload` signatures have been changed. This has been done to better represent the objects that are actually sent in and to add an optional `parent_user` object.

For both functions the `from_user` parameter has been renamed to `author_user`. Optionally a `parent_user` object can also be passed in. Both the user objects must have `private_key` and `handle` attributes. In the case that `parent_user` is given, that user will be used to sign the payload and for Diaspora relayables an extra `parent_author_signature` in the payload itself.
2017-07-29 13:43:35 +03:00
Jason Robinson f0eba0e3d1 Release 0.13.0 2017-07-22 00:03:49 +03:00
Jason Robinson 10fa2cf846 Enable correct Diaspora relayable behaviour
Store the original object when signing with parent, then use that for sending, not serializing our entity object.

This fixes relayable support broken with the new Diaspora protocol.
2017-07-21 23:21:30 +03:00
Jason Robinson 5b04e5ea84 Add created_at to Diaspora Comment entity XML creator
This is required in renewed Diaspora protocol.

Refs: #59
2017-07-21 22:51:16 +03:00