@@ -60,19 +60,33 @@ public function parse_header( $header ) {
60
60
61
61
}
62
62
63
+ public function retrieve_authorization_headers () {
64
+ $ auth_headers = ! empty ( $ _SERVER ['HTTP_AUTHORIZATION ' ] ) ? $ _SERVER ['HTTP_AUTHORIZATION ' ] : false ;
65
+
66
+ if ( ! $ auth_headers && function_exists ( 'apache_request_headers ' ) ) {
67
+ $ all_headers = apache_request_headers ();
68
+
69
+ $ auth_headers = array_key_exists ( 'Authorization ' , $ all_headers ) ? $ all_headers ['Authorization ' ] : false ;
70
+ }
71
+
72
+ return $ auth_headers ;
73
+ }
74
+
63
75
public function get_parameters ( $ require_token = true , $ extra = array () ) {
64
76
$ params = array_merge ( $ _GET , $ _POST );
65
77
$ params = wp_unslash ( $ params );
66
78
67
- if ( ! empty ( $ _SERVER ['HTTP_AUTHORIZATION ' ] ) ) {
68
- $ header = wp_unslash ( $ _SERVER ['HTTP_AUTHORIZATION ' ] );
79
+ $ auth_headers = $ this ->retrieve_authorization_headers ();
80
+
81
+ if ( ! empty ( $ auth_headers ) ) {
82
+ $ auth_headers = wp_unslash ( $ auth_headers );
69
83
70
84
// Trim leading spaces
71
- $ header = trim ( $ header );
85
+ $ auth_headers = trim ( $ auth_headers );
72
86
73
- $ header_params = $ this ->parse_header ( $ header );
74
- if ( ! empty ( $ header_params ) ) {
75
- $ params = array_merge ( $ params , $ header_params );
87
+ $ auth_header_params = $ this ->parse_header ( $ auth_headers );
88
+ if ( ! empty ( $ auth_header_params ) ) {
89
+ $ params = array_merge ( $ params , $ auth_header_params );
76
90
}
77
91
}
78
92
@@ -504,6 +518,7 @@ public function revoke_access_token( $key ) {
504
518
* @return boolean|WP_Error True on success, error otherwise
505
519
*/
506
520
protected function check_oauth_signature ( $ consumer , $ oauth_params , $ token = null ) {
521
+
507
522
$ http_method = strtoupper ( $ _SERVER ['REQUEST_METHOD ' ] );
508
523
509
524
switch ( $ http_method ) {
0 commit comments