Skip to content

Commit

Permalink
Forward Authorization to global content repo
Browse files Browse the repository at this point in the history
When using HTTP Basic Auth with the global media feature the requests would fail as the Auth header is missing. This forwards the auth header if found.
Fixes #377
  • Loading branch information
roborourke committed Jan 27, 2022
1 parent 452d1d8 commit 0ad2271
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions inc/global_content/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,5 +396,11 @@ function filter_global_content_requests_for_auth( array $parsed_args, string $ur
] );
}, $_COOKIE, array_keys( $_COOKIE ) );

// Check for Auth header and forward it, for Basic Auth feature support.
if ( ! isset( $parsed_args['headers']['Authorization'] ) && ! empty( $_SERVER['HTTP_AUTHORIZATION'] ) ) {
// phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
$parsed_args['headers']['Authorization'] = wp_unslash( $_SERVER['HTTP_AUTHORIZATION'] );
}

return $parsed_args;
}

0 comments on commit 0ad2271

Please sign in to comment.