diff --git a/inc/authentication/namespace.php b/inc/authentication/namespace.php index 0078792..02e7d63 100644 --- a/inc/authentication/namespace.php +++ b/inc/authentication/namespace.php @@ -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 ") 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();