Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion inc/authentication/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,28 @@ function get_authorization_header() {
function get_provided_token() {
$header = get_authorization_header();
if ( $header ) {
return get_token_from_bearer_header( $header );
$token = get_token_from_bearer_header( $header );
if ( $token ) {
return $token;
}
}

/**
* Provide an alternative authorization header value.
*
* Use this filter when the standard Authorization header is consumed by a
* proxy or server layer (e.g. Imperva HTTP Basic Auth). Return the raw
* header value (e.g. "Bearer <token>") to have it parsed as a bearer token.
* Return null to skip the fallback entirely.
*
* @param string|null $header Raw header value, or null to skip.
*/
$alt_header = apply_filters( 'oauth2.authentication.alternative_authorization_header', null );
if ( $alt_header ) {
$token = get_token_from_bearer_header( $alt_header );
if ( $token ) {
return $token;
}
}

$token = get_token_from_request();
Expand Down