PHP: populating PHP_AUTH_* server variables.

This closes #498 issue on GitHub.
This commit is contained in:
Valentin Bartenev
2020-12-08 01:59:46 +03:00
parent bda76b04e9
commit 2348229dc7
6 changed files with 26 additions and 0 deletions

View File

@@ -15,6 +15,13 @@ invalid HTTP responses were generated for some unusual status codes.
</para> </para>
</change> </change>
<change type="bugfix">
<para>
PHP_AUTH_USER, PHP_AUTH_PW, and PHP_AUTH_DIGEST server variables were missing
in PHP module.
</para>
</change>
</changes> </changes>

View File

@@ -174,6 +174,8 @@ static nxt_http_field_proc_t nxt_h1p_fields[] = {
{ nxt_string("Content-Type"), &nxt_http_request_field, { nxt_string("Content-Type"), &nxt_http_request_field,
offsetof(nxt_http_request_t, content_type) }, offsetof(nxt_http_request_t, content_type) },
{ nxt_string("Content-Length"), &nxt_http_request_content_length, 0 }, { nxt_string("Content-Length"), &nxt_http_request_content_length, 0 },
{ nxt_string("Authorization"), &nxt_http_request_field,
offsetof(nxt_http_request_t, authorization) },
}; };

View File

@@ -156,6 +156,7 @@ struct nxt_http_request_s {
nxt_http_field_t *cookie; nxt_http_field_t *cookie;
nxt_http_field_t *referer; nxt_http_field_t *referer;
nxt_http_field_t *user_agent; nxt_http_field_t *user_agent;
nxt_http_field_t *authorization;
nxt_off_t content_length_n; nxt_off_t content_length_n;
nxt_sockaddr_t *remote; nxt_sockaddr_t *remote;

View File

@@ -1038,6 +1038,17 @@ nxt_php_execute(nxt_php_run_ctx_t *ctx, nxt_unit_request_t *r)
ctx->cookie = nxt_unit_sptr_get(&f->value); ctx->cookie = nxt_unit_sptr_get(&f->value);
} }
if (r->authorization_field != NXT_UNIT_NONE_FIELD) {
f = r->fields + r->authorization_field;
php_handle_auth_data(nxt_unit_sptr_get(&f->value));
} else {
SG(request_info).auth_digest = NULL;
SG(request_info).auth_user = NULL;
SG(request_info).auth_password = NULL;
}
SG(sapi_headers).http_response_code = 200; SG(sapi_headers).http_response_code = 200;
SG(request_info).path_translated = NULL; SG(request_info).path_translated = NULL;

View File

@@ -5169,6 +5169,7 @@ nxt_router_prepare_msg(nxt_task_t *task, nxt_http_request_t *r,
req->content_length_field = NXT_UNIT_NONE_FIELD; req->content_length_field = NXT_UNIT_NONE_FIELD;
req->content_type_field = NXT_UNIT_NONE_FIELD; req->content_type_field = NXT_UNIT_NONE_FIELD;
req->cookie_field = NXT_UNIT_NONE_FIELD; req->cookie_field = NXT_UNIT_NONE_FIELD;
req->authorization_field = NXT_UNIT_NONE_FIELD;
dst_field = req->fields; dst_field = req->fields;
@@ -5193,6 +5194,9 @@ nxt_router_prepare_msg(nxt_task_t *task, nxt_http_request_t *r,
} else if (field == r->cookie) { } else if (field == r->cookie) {
req->cookie_field = dst_field - req->fields; req->cookie_field = dst_field - req->fields;
} else if (field == r->authorization) {
req->authorization_field = dst_field - req->fields;
} }
nxt_debug(task, "add field 0x%04Xd, %d, %d, %p : %d %p", nxt_debug(task, "add field 0x%04Xd, %d, %d, %p : %d %p",

View File

@@ -31,6 +31,7 @@ struct nxt_unit_request_s {
uint32_t content_length_field; uint32_t content_length_field;
uint32_t content_type_field; uint32_t content_type_field;
uint32_t cookie_field; uint32_t cookie_field;
uint32_t authorization_field;
uint64_t content_length; uint64_t content_length;