Skip to content

Commit 2c7d6f9

Browse files
committed
improve username/password detection for IIS
1 parent 1356e60 commit 2c7d6f9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

sapi/isapi/php4isapi.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,25 @@ static void sapi_isapi_register_server_variables(zval *track_vars_array TSRMLS_D
571571
}
572572
php_register_variable("DOCUMENT_ROOT", humi.lpszPath, track_vars_array TSRMLS_CC);
573573
}
574+
575+
if (!SG(request_info).auth_user || !SG(request_info).auth_password ||
576+
!SG(request_info).auth_user[0] || !SG(request_info).auth_password[0]) {
577+
DWORD variable_len;
578+
char static_variable_buf[ISAPI_SERVER_VAR_BUF_SIZE];
579+
580+
variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
581+
if (lpECB->GetServerVariable(lpECB->ConnID, "HTTP_AUTHORIZATION", static_variable_buf, &variable_len)
582+
&& static_variable_buf[0]) {
583+
php_handle_auth_data(static_variable_buf TSRMLS_CC);
584+
}
585+
}
586+
587+
if (SG(request_info).auth_user) {
588+
php_register_variable("PHP_AUTH_USER", SG(request_info).auth_user, track_vars_array TSRMLS_CC );
589+
}
590+
if (SG(request_info).auth_password) {
591+
php_register_variable("PHP_AUTH_PW", SG(request_info).auth_password, track_vars_array TSRMLS_CC );
592+
}
574593
}
575594
#endif
576595
}

0 commit comments

Comments
 (0)