You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We’re currently using the [CheckView] to expose custom REST API endpoints on our WordPress site. Our plugin relies on JWT tokens passed in the Authorization header to authenticate API calls.
However, we’ve encountered a conflict between our plugin and Loops and Logic because of how the Authorization header is being processed globally. Specifically, your plugin appears to handle all REST API requests with the following code snippet:
if ( ! $auth ) {
$auth = isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] )
? $_SERVER['REDIRECT_HTTP_AUTHORIZATION']
: false;
}
This code is attempting to validate the Authorization header for every REST API request, including those unrelated to the Loops and Logic API. Since our plugin also uses the Authorization header for JWT-based validation, this results in errors when the Loops and Logic plugin tries to interpret our JWT tokens as API keys.
Suggested Solution
To prevent conflicts and ensure both plugins can coexist without issues, we kindly request that you modify the header validation logic to only process Authorization headers for your specific endpoints.
Here is an example of how this can be achieved:
$requested_route = rest_get_url_prefix() . '/your-api-base'; // Replace with your API base route.if ( strpos( $_SERVER['REQUEST_URI'], $requested_route ) !== false ) {
$header_name = 'HTTP_AUTHORIZATION';
$auth = isset( $_SERVER[ $header_name ] ) ? $_SERVER[ $header_name ] : false;
if ( ! $auth ) {
$auth = isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] )
? $_SERVER['REDIRECT_HTTP_AUTHORIZATION']
: false;
}
// Proceed with your plugin's authentication logic here.
}
Thanks!
The text was updated successfully, but these errors were encountered:
Hi [Loops and logic Developer's],
I hope this message finds you well.
We’re currently using the [CheckView] to expose custom REST API endpoints on our WordPress site. Our plugin relies on JWT tokens passed in the Authorization header to authenticate API calls.
However, we’ve encountered a conflict between our plugin and Loops and Logic because of how the Authorization header is being processed globally. Specifically, your plugin appears to handle all REST API requests with the following code snippet:
add_filter( 'rest_pre_dispatch', array( $this, 'rest_pre_dispatch' ), 10, 3 );
$header_name = 'HTTP_AUTHORIZATION';
$auth = isset( $_SERVER[ $header_name ] ) ? $_SERVER[ $header_name ] : false;
if ( ! $auth ) {
$auth = isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] )
? $_SERVER['REDIRECT_HTTP_AUTHORIZATION']
: false;
}
This code is attempting to validate the Authorization header for every REST API request, including those unrelated to the Loops and Logic API. Since our plugin also uses the Authorization header for JWT-based validation, this results in errors when the Loops and Logic plugin tries to interpret our JWT tokens as API keys.
Suggested Solution
To prevent conflicts and ensure both plugins can coexist without issues, we kindly request that you modify the header validation logic to only process Authorization headers for your specific endpoints.
Here is an example of how this can be achieved:
$requested_route = rest_get_url_prefix() . '/your-api-base'; // Replace with your API base route.if ( strpos( $_SERVER['REQUEST_URI'], $requested_route ) !== false ) {
$header_name = 'HTTP_AUTHORIZATION';
$auth = isset( $_SERVER[ $header_name ] ) ? $_SERVER[ $header_name ] : false;
}
Thanks!
The text was updated successfully, but these errors were encountered: