函数
wp_populate_basic_auth_from_authorization_header ( No parameters )
- 定义位置
-
-
wp-includes/load.php
, line 102
-
wp-includes/load.php
- 引入
- 5.6.0
- 弃用
- –
从授权头填充Basic Auth服务器的细节。
一些以CGI或FastCGI模式运行的服务器不会把授权头传递给WordPress。如果它被改写成了`HTTP_AUTHORIZATION`头,请填写适当的$_SERVER变量。
function wp_populate_basic_auth_from_authorization_header() { // If we don't have anything to pull from, return early. if ( ! isset( $_SERVER['HTTP_AUTHORIZATION'] ) && ! isset( $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ) ) { return; } // If either PHP_AUTH key is already set, do nothing. if ( isset( $_SERVER['PHP_AUTH_USER'] ) || isset( $_SERVER['PHP_AUTH_PW'] ) ) { return; } // From our prior conditional, one of these must be set. $header = isset( $_SERVER['HTTP_AUTHORIZATION'] ) ? $_SERVER['HTTP_AUTHORIZATION'] : $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; // Test to make sure the pattern matches expected. if ( ! preg_match( '%^Basic [a-zd/+]*={0,2}$%i', $header ) ) { return; } // Removing `Basic ` the token would start six characters in. $token = substr( $header, 6 ); $userpass = base64_decode( $token ); list( $user, $pass ) = explode( ':', $userpass ); // Now shove them in the proper keys where we're expecting later on. $_SERVER['PHP_AUTH_USER'] = $user; $_SERVER['PHP_AUTH_PW'] = $pass; }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。