Skip to content
GitLab
Explore
Sign in
Commits on Source (1)
Do not require authentication for /.well-known/ endpoints
· 1062fd8f
ale
authored
Nov 19, 2022
1062fd8f
Hide whitespace changes
Inline
Side-by-side
ai-authenticate-rest-api.php
View file @
1062fd8f
...
...
@@ -10,6 +10,13 @@
* License URI: http://opensource.org/licenses/MIT
*/
function
ai_authenticate_rest_api_is_well_known_request
()
{
return
strncmp
(
$_SERVER
[
'REQUEST_URI'
],
'/.well-known/'
,
strlen
(
'/.well-known/'
))
==
0
;
}
add_filter
(
'rest_authentication_errors'
,
function
(
$result
)
{
// If a previous authentication check was applied,
// pass that result along without modification.
...
...
@@ -19,7 +26,8 @@ add_filter('rest_authentication_errors', function($result) {
// No authentication has been performed yet.
// Return an error if user is not logged in.
if
(
!
is_user_logged_in
())
{
if
(
!
is_user_logged_in
()
&&
!
ai_authenticate_rest_api_is_well_known_request
())
{
return
new
WP_Error
(
'rest_not_logged_in'
,
__
(
'You are not currently logged in.'
),
...
...