akirk / enable-mastodon-apps

Allow accessing your WordPress blog with Mastodon clients
https://wordpress.org/plugins/enable-mastodon-apps
GNU General Public License v2.0
34 stars 5 forks source link

Register OAuth Rewrite Path #130

Closed akirk closed 1 month ago

akirk commented 2 months ago

When a post exists on the WordPress site that includes the word "authorize", WordPress redirects there instead of letting EMA handle the path.

This adds the necessary rewrite routing for this. In the course I fixed two more bugs:

Fixes #129.

akirk commented 2 months ago

The tests fail because WordPress redirects to oauth/authorize/. The flow works (i.e. fixes the issue described in #129) for clients that support and follow those redirects but the test expects oauth/authorize to be served without a redirect. I think it's better for compatibility to avoid the redirect.

The responsible code is here in core: https://github.com/WordPress/wordpress-develop/blob/a4123728068e09200d7dfe2d5a88f803c1adf2aa/src/wp-includes/canonical.php#L695-L697

Which calls https://github.com/WordPress/wordpress-develop/blob/a4123728068e09200d7dfe2d5a88f803c1adf2aa/src/wp-includes/class-wp-query.php#L4345-L4348

And then https://github.com/WordPress/wordpress-develop/blob/a4123728068e09200d7dfe2d5a88f803c1adf2aa/src/wp-includes/class-wp-query.php#L1029-L1033

So rest routes get special treatment, I think this is what we need to convert this to.

akirk commented 2 months ago

I found another solution, so I think this is ready.