WPIntell

Source evidence

CORS

API Bearer Auth · support · 2020-11-09T12:46:00+00:00

complaintsentiment
mediumseverity
0.92relevance
5replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

5 / 25 rows with source links

20.0% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

20 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
EvdHeuvel unresolved
I’m implementation a solution where I need to obtain a bearer token from a different domain (running a solution in a Docker app). Is there a way to enable/support CORS? Groet, Erik You mean you have 2 WordPress installations and from installation 1 you want to be able to authenticate to installation 2? I’m running WordPress and an automation tool side by side (Node-RED or OL Connect Workflow). The automation tool fetches a bearer key in order to create and update (custom) posts via custom end points. This works like a charm when running everything on the same box. We use this setup in various on-premise solutions. I’m currently moving this setup to run on containers to simplify deployment in the cloud. This is where I ran into the CORS challenge. If you can write down what you exactly need from this plugin to make it work for your situation, I can look if this improves the plugin and if I can implement it. Alright, let me work on that. Hi Michiel, I did some debugging and traced things down to the rest_authentication_errors_filter function. The problem in my setup is related to the fact that the host in $currentUrl differs from the $siteUrl. This is caused by the fact that I’m contacting the end points in WordPress from a separate container. This causes the preg_match to return an error resulting in an 401 error in the client in my other container. Initally I thought that I could workaround this by setting the Access-Control-Allow-Origin header but I couldn’t get that to work. Hope this is of some help.

Comments

5 shown
michielve 2020-11-10T06:50:00+00:00

You mean you have 2 WordPress installations and from installation 1 you want to be able to authenticate to installation 2?

EvdHeuvel 2020-11-10T08:29:00+00:00

I’m running WordPress and an automation tool side by side (Node-RED or OL Connect Workflow). The automation tool fetches a bearer key in order to create and update (custom) posts via custom end points. This works like a charm when running everything on the same box. We use this setup in various on-premise solutions. I’m currently moving this setup to run on containers to simplify deployment in the cloud. This is where I ran into the CORS challenge.

michielve 2020-11-19T06:57:00+00:00

If you can write down what you exactly need from this plugin to make it work for your situation, I can look if this improves the plugin and if I can implement it.

EvdHeuvel 2020-11-20T14:47:00+00:00

Alright, let me work on that.

EvdHeuvel 2020-11-23T09:15:00+00:00

Hi Michiel, I did some debugging and traced things down to the rest_authentication_errors_filter function. The problem in my setup is related to the fact that the host in $currentUrl differs from the $siteUrl. This is caused by the fact that I’m contacting the end points in WordPress from a separate container. This causes the preg_match to return an error resulting in an 401 error in the client in my other container. Initally I thought that I could workaround this by setting the Access-Control-Allow-Origin header but I couldn’t get that to work. Hope this is of some help.