Skip to content
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

WordPress compatibility #21

Open
pfefferle opened this issue Jan 29, 2021 · 8 comments
Open

WordPress compatibility #21

pfefferle opened this issue Jan 29, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@pfefferle
Copy link

Hey @landrok , I am the author of the WordPress ActivityPub Plugin (https://github.com/pfefferle/wordpress-activitypub) and @mediaformat and I investigated if it is possible to use your lib in the plugin, so I have some questions.

  • WordPress comes with it's own API endpoints and with it's request handlers, do you see a way to provide a bit more generic way to verify requests, withouth the requirement of guzzle or symfony?
  • Because we can't use the server part of your lib, what do you think about a fromJson method for the Activity Objects, so that we will be able to init the objects, using the JSON request?
@landrok landrok added the enhancement New feature or request label Jan 31, 2021
@landrok
Copy link
Owner

landrok commented Jan 31, 2021

Hey @pfefferle, nice to hear you.

HTTP Client

I don't have a lot of experiences on Wordpress but as far as I know, Wordpress has its own HTTP "stack" such as functions like wp_get_http(), wp_post_http() etc... and static shortcut methods in the WP_Http class like WP_Http::get(), WP_Http::get() etc...

Do you know if there are some higher level methods that implements PSR 7 / ? The idea behind this is to implement a driver parameter, as it has been made for caching or logging, so that you may configure it on the fly.

fromJson

I just released a version 0.5.5 with a fromJson() method.

Server part

The server part of this library does not listen on any port. It's more intended to be integrated in a controller method. It's a precision because I don't know if this is the blocking aspect in your usage.

@pfefferle
Copy link
Author

pfefferle commented Feb 5, 2021

Hey @landrok, sorry for the late reply.

I just released a version 0.5.5 with a fromJson() method.

Nice, thanks!

HTTP Client

As you said, WordPress has it's own WP_Http class and mainly uses https://github.com/WordPress/Requests and there is sadly no PSR-7 planned any time soon: WordPress/Requests#320

Nevertheless, do you see a way to remove the hard dependencies of the guzzlehttp/guzzle, symfony/http-foundation, symfony/cache and monolog/monolog? Maybe to only use the PSR interfaces, so that we will be able to implement them mapping the internal handlers/classes.

Alternative

If this is not possible (at least in short term), do you think it make sense to "only" use the Activity Objects and keep the server handling we currently use?

@pfefferle
Copy link
Author

Hey @landrok

how likely is it, that the PSR 7 driver feature will make it into the code?

Do you know if there are some higher level methods that implements PSR 7 / ? The idea behind this is to implement a driver parameter, as it has been made for caching or logging, so that you may configure it on the fly.

Are you willing to accept pull requests?

@landrok
Copy link
Owner

landrok commented May 9, 2022

Hey Matthias,
First, sorry for the long time since your previous issues. I have played a little bit with WP HTTP features, implemented some anonymous functions to switch between "HTTP driver" (default implementation could be overridden by these anonymous features). I have not published anything because I was not satisfied. Finally I decided to take some time to think about it. And I think you know the following...
So, I am still interested in an implementation of PSR 7 as a driver feature but I have not enough time these days to implement it.
Of course, I will accept pull requests with pleasure and I would take the time to review them.

@pfefferle
Copy link
Author

I have two more questions if you don't mind:

  • why does the lib use "guzzle" and "HttpFoundation"? Do you think it is possible to only use a PSR compatible request handler, so I can try to mock it for WordPress?
  • are you fine with making the signature verification configurable, so that I can try to use an alternative to phpseclib?

@landrok
Copy link
Owner

landrok commented May 11, 2022

Guzzle and HTTP foundation

Guzzle is used as an HTTP client and should be replaced by PSR-18 (ie: https://github.com/landrok/activitypub/blob/master/src/ActivityPhp/Server/Http/Request.php#L42)

HTTP foundation is used as HTTP message and should be replaced by PSR-7 (ie: https://github.com/landrok/activitypub/blob/master/src/ActivityPhp/Server/Http/HttpSignature.php#L66)

Maybe the 2 should be handled as 2 distinct commits, don't you think ?

Signature verification

It could be great. It goes beyond the scope of this "Wordpress compatibility" issue and needs another one that let us discuss about alternatives before implementing.

@mediaformat
Copy link

mediaformat commented Oct 30, 2022

By the way @Art4 has an open PR to Add PSR-7 support, with an accompanying PSR18-Adapter if anyone is able to test it with this library!

@Art4
Copy link

Art4 commented Oct 31, 2022

Thanks for mentioning me 👍 Atm the adapter is only supporting Requests v2, but I'm working at support for Requests v1 too.

I would be glad if my library could be helpful.

Update: I released 1.0.0 with support for Requests v1 and v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants