verbb / consume

A Craft CMS plugin to create HTTP requests in your Twig templates to consume JSON, XML or CSV content.
Other
4 stars 1 forks source link

Add headless support for auth callback #13

Closed webrgp closed 5 months ago

webrgp commented 5 months ago

In some headless setups, the primary site url can be pointing to another domain. That breaks the OAuthClient because it tries to redirect to the primary site url.

This adds a headlessMode configuration check that allows for the route consume/auth/callback to be available in the control panel.

engram-design commented 5 months ago

You shouldn't actually need to create a CP URL for this endpoint, as there's already an action endpoint for this:

https://my-site.test/actions/consume/auth/callback

The reason we use a Site URL is that it forgoes the need to use an Action URL that might use pathInfo (query strings) for the action, like https://my-site.test/index.php?q=actions/consume/auth/callback. This is because a few providers don't allow query strings in the callback URL.

So I've actually changed the Redirect URI to show the Action URL when headlessMode is enabled, rather than creating the CP URL as per this PR. Appreciate the effort!

To get this early, run composer require verbb/consume:"dev-craft-4 as 1.0.10".

engram-design commented 5 months ago

Although on second thought, I think it's nicer to define the route as a CP one for a slightly tidier URL, so we'll go with what you have! https://github.com/verbb/consume/commit/f2063a27ecb0d4730a964a30c63fdf47bff5f138