-
Notifications
You must be signed in to change notification settings - Fork 69
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
Basic implementation of "client to server" ActivityPub protocol #499
Comments
|
Due to pressing need due to imminent end of Google Plus, I have been knocking together the world's simplest client-to-server ActivityPub service which exclusively works on static HTML website generators such as Jekyll and Hugo. No databases, no subscriptions, no followers, no complexity. All I want is that an Android app can post new blog posts, possibly with photos and/or location, to my static HTML website, like I currently can do with Google Plus. What I have so far can be found at https://github.com/ned14/static-website-activitypub. It is still missing the inbox and outbox implementations (coming soon). Can I request that your checkbox list above can be broken into a simpler "initial support"? What I would need:
|
|
@ned I see that I need to start with at least "Add "ActivityPub" type of Social network" and adding "application/ld+json" to a couple of places as mentioned above. This could be done quickly and will allow to add other features as "compatibility improvements". |
|
Thanks for the tip. Reading through https://github.com/pump-io/pump.io/blob/master/API.md, as far as I can tell these are the main significant differences between pump.io and W3C ActivityPub:
Otherwise, they do indeed look quite similar. The major blocker is the OAuth support really. I'm a bit loathe to implement it, because it's fundamentally broken, where HTTP signatures are not. But if it gets me up and running with andStatus quicker, I guess I can live with it. |
|
@ned14 Regarding restpoints. In pump.io, they are not hardcoded. Although they are usually the same, and this may lead to the hardcoded implementations in clients. Recently I fixed hardcoded endpoints for pump.io in AndStatus (exactly for ActivityPub migration), see https://github.com/andstatus/andstatus/blob/master/app/src/main/java/org/andstatus/app/net/social/ActorEndpoints.java |
… -> Troubleshooting). Content-Type "application/ld+json..."
|
@ned14 I think that now you can start testing/working at a server-side of "client to server" ActivityPub protocol. AndStatus client is just updated to allow creation of a Social Network of ActivityPub type. As I wrote there, I reused OAuth 2.0 implementation that works in AndStatus for Mastodon (with bearer token...). Everything else - from existing Pump.io implementation. Plus added "application/ld+json..." as required.
In order to move forward, past authorisation step, I need an account on a server that successfully authenticates/authorises a User... |
|
A couple of years ago we did the same OAuth implementation exercise with @Gargron for Mastodon, please see this post #419 (comment) and below.
|
|
@ned14 Mastodon, Pleroma and others uses http signatures only when interacting server-to-server. For interacting with clients Mastodon uses custom API, not related to ActivityPub. Pleroma just cloned it from Mastodon, and other servers uses custom APIs. OAuth is recommended way to authorize the client https://www.w3.org/TR/activitypub/#authorization -> https://www.w3.org/wiki/SocialCG/ActivityPub/Authentication_Authorization#Client_to_Server When test suite on https://test.activitypub.rocks/ is trying to obtain a token (when testing client-to-server interaction with server), it follows next steps
|
|
Bah, looks like I'll have to implement OAuth 2.0 so. It looks complex and hard to get right. But I'll give it a go. Thanks for the feedback, you saved me work! |
|
@ned14 You can try copypasting from this repo https://github.com/autogestion/pubgate |
|
@autogestion @ned14 Please note that in both Pump.io and Mastodon client-to-server OAuth implementations the Client application starts with Dynamic client registration (implemented differently though...). Something like https://tools.ietf.org/html/rfc7591#section-1.3 (see Dynamic Registration as part of https://openid.net/connect/ also) I think we must have Client Registration in our new solutions, because even existing social networks implemented this (formally optional) step years ago. Even Twitter has Client Registration, although it's not dynamic: application developer has to register his Client application manually at Twitter's developer's site. If you want a server code to be compatible with different client applications, not only with the one that You (or we) created, please make it at least look like generic OAuth 2.0 server solution (i.e. having similar public API / process implemented). Dynamic registration should result in at least two ids, returned from a server: "client identifier" and "client secret". They are referred to e.g. as "YOUR_API_KEY" and "YOUR_API_SECRET" in the ScribeJava client library docs: https://github.com/scribejava/scribejava And another note on dynamic registration metadata (returned by a server) for @autogestion and his Pubgate (as defined in RFC 7591) : |
|
pleroma.site (as well as any other Pleroma install) has ActivityPub C2S available through OAuth. You will need to use the Mastodon API to obtain client secrets for OAuth. |
|
@kaniini I registered at pleroma.site as andstatus@pleroma.site and then tried to adapt my current ActivityPub implementation to it:
What should I do, where can I get more info on correct API? |
|
the correct location to make AP C2S calls is at /users/:username/inbox |
@kaniini Thank you, after several attempts I figured out the correct full URL:
However, this URL, looking like an actor's inbox, is conceptually incorrect for the "whoami" call as even AntivityPub spec says: "The inbox is discovered through the inbox property of an actor's profile". This is why URL of the "whoami" endpoint should be the same for every user, and not the "inbox" of a concrete user/actor. This is "whoami" endpoint where the authenticated Actor receives his/her profile information, including URLs of other endpoints! ?! |
Ugh wait. What's the point of having a C2S standard if OAuth registration isn't even part of it? How was it intended to work? 🤔 |
@Gargron Yes, ActivityPub refers to OAuth but doesn't mention the "registration" word explicitly.
The RFC7591 ( https://tools.ietf.org/html/rfc7591 ) is "OAuth 2.0 Dynamic Client Registration Protocol". So OAuth Client Registration is at least a part of the specification's best practices :-) We do have working OAuth 1.0 and Dynamic Client registration and the "whoami" endpoint for a federated network that's very close to ActivityPub from a Client app point of view ( pump.io https://github.com/pump-io/pump.io/blob/master/API.md ). Plus we do have OAuth 2.0 e.g. in Mastodon. So I think that we just need to go only one step further to implement OAuth 2.0 + Dynamic Client registration + "whoami" point in order to have a "bootstrap" for the "Client to Server interactions", which are actually a part of the ActivityPub spec. This is how it will work. |
|
Have to say, that this is a bit strange to use OAuth in federated network. Because it's a standard which allows to authorize using some centralized authority, and fediverse do not have one |
|
my current Pleroma tree has /api/ap/whoami for this purpose. I will deploy it on pleroma.site in a few hours. will this work for you? |
|
I deployed that endpoint on pleroma.site. |
|
The AP C2S whoami endpoint which allows for mapping OAuth credentials to an actor endpoint is now in Pleroma upstream.
|
@kaniini Frankly I don't understand, why these two endpoints may be needed, if I get them after OAuth authentication procedure.
I think that
?! We need to dig more in standards: I suspect that solution for whoami endpoint is already defined... |
|
[2019-02-06 22:23:57] Yuri Volkov:
> The AP C2S whoami endpoint which allows for mapping OAuth credentials to an actor endpoint is now in Pleroma upstream.
>
> `oauthAuthorizationEndpoint` and `oauthTokenEndpoint` will be added to actors too.
@kaniini Frankly I don't understand, why these two endpoints may be needed, if I get them _after_ OAuth authentication procedure.
An actor is public data, it would allow to give https://pleroma.site/users/kaniini (actor IRI) or kaniini@pleroma.site (actor WebFinger) to register.
Which have the nice addition of giving username+instance in one shot.
What worries me in our growing solution, are URLs of the two quite voluntary/hardcoded endpoints:
1. Client registration at https://pleroma.site/api/v1/apps
2. whoami endpoint at https://pleroma.site/api/ap/whoami
Both endpoints are unknown to a client application, visiting this host.
I think that
1. we need to use more "standard" URL for the Client Registration, e.g.
https://pleroma.site/register (just like in examples, although non-normative, in https://tools.ietf.org/html/rfc7591
2. Whoami endpoint URL should be added as a separate property to a metadata, returned by a server during Client registration
?!
Why would the mastodon one not become the standard one for client registeration? It’s basically the de-facto one.
But maybe there should be something in nodeinfo (but that’s not strictly ActivityPub) about which authentification is supported on the server.
|
Why it is so important to perform client registration first? Client could start with fetching user profile using webfinger. It is de-facto standard for activitypub servers and is used to fetch user profiles, when user from one server searches for user from another server User profile MAY contain
and it could be extended with attribute which contains url for dynamic registration. And there will be no need to standardize endpoints names Still, this discussion looks like trying to stretch owl over the globe. OAuth is designed for cases when there is certain centralized server (which defines endpoints due to OAuth spec), not for chaotic federation |
…tor. "Open in Browser" works for ActivityPub
…udience. In particular, with "acct" URI scheme
|
I created the issue in Pleroma on uploading images: https://git.pleroma.social/pleroma/pleroma/issues/1171 |
|
Copied from my Mastodon posts...
In response to "Follow your nose":
The AP Actor document isn't a great service description, but it's the one we have Finally, a more correct and coherent statement of what I was trying to say on https://banana.dog/web/statuses/102810770163813523 is that client_secret is not required in the registration response, but client_secret_expires is required if a client_secret is provided. At first I thought it was funny that the client didn't include the secret when making a grant request, but I see that the client_secret is only used when the client is changing its own information My use case is porting games from play by email to play by AP, where players usually have a close relationship with someone developing a custom client. I'm also thinking of Epicyon, a more privacy focused AP implementation from another developer that would probably benefit if this workflow were settled |
|
@swift2plunder I'm glad to hear about another server side implementation. Please let me know when I can create an account at your server and start testing, improving and extending implementation in AndStatus. |
@yvolk : I case you didn't get the notification on pleroma's gitlab, I have implemented it about a week ago: https://git.pleroma.social/pleroma/pleroma/merge_requests/1706 |
|
@lanodan Thank you, the ball is on my side now :-) Please don't forget to implement/fix https://git.pleroma.social/pleroma/pleroma/issues/751 also "No way to request newer page of the Collection" :-) |
|
@lanodan I've looked into the change https://git.pleroma.social/pleroma/pleroma/merge_requests/1706/diffs and checked uptated "whoami" response at https://pleroma.site/api/whoami |
|
In v.51.02 posting and downloading multiple attachments is implemented. Tested at https://queer.hacktivis.me/AndStatus?tab=statuses thanks to @lanodan Now I can successfully post and download posted note with attachments (tried one and two so far...), but these posts aren't visible in the Web site's timeline yet... |
…ver. Viewing Home (inbox) and posting are not supported by Mastodon yet. But we can see our own posts and navigate to other Actors via them (you can see profiles of other Actors and see their posts...)
|
See current state of this implementation in the first comment of this thread. |
|
Further discussion regarding proper OAuth implementation for ActivityPub C2S is here: #528 (April 2021) |


Note on current state (as of 2020-05-24)
Pleroma
Minimal "client to server" #ActivityPub implementation is available. It is tested at https://queer.hacktivis.me/AndStatus (that site has the latest Pleroma builds... some requests work at other Pleroma instances also!) and can:
Latest #AndStatus version is here: #456
All critical Pleroma problems fixed as I test developer's builds at https://queer.hacktivis.me/ , so "Basic ActivityPub C2S implementation" could be considered completed.
Mastodon
Mastodon (not AndStatus!) doesn't give you enough features to switch client connection to ActivityPub simply because Home timeline and posting via ActivityPub connection is not supported yet (corresponding pages give 404 Not found error).
But you can see your authenticated Actor's own posts on Mastodon servers and navigate to other Actors and their posts via them (you can see profiles of other Actors and see their posts...). You can even play with Mastodon as an "ActivityPub" type Social network in AndStatus today (I implemented a hack to log into Mastodon... not ActivityPub way unfortunately...)! But prepare to see empty Home timeline (due to above mentioned deficiency) and to be read-only there for now. Switch to "Sent" timeline and see your Actor's posts, see other actors and their posts similarly...
These new Mastodon improvements make me very optimistic about the future of ActivityPub in the client apps across all server platforms.
Description
As defined at https://www.w3.org/TR/activitypub/ , ActivityPub provides two layers:
The "ActivityPub test suite" (worked in 2018-2019... see on ActivityPub testing here) site contained a test suite that checked basic features that are required for a client app to implement #ActivityPub.
Below is a list of corresponding steps/features (for the start, copied from that site), which we are implementing in AndStatus, together with their implementation status:
AndStatus UI changes:
Client: Basic submission
Currently we reused OAuth 2.0 implementation that works in AndStatus for Mastodon.
Client: Required properties
Client: Add targets on reply
Reply to a post with multiple recipients.
inReplyTo, See Section 7), and adds these targets to the new submission's audience. (The client suggests audience targeting based on participants in the referenced thread)Client: Accept header on object retrieval
Trigger the client to retrieve some remote object.
The text was updated successfully, but these errors were encountered: