SUPPORT-8592. Проверка подписи маркера доступа
This commit is contained in:
parent
9e85e4e8de
commit
4fa45a1f5e
46 changed files with 1970 additions and 250 deletions
|
|
@ -17,6 +17,57 @@ fcgi_get_content_length(const FCGX_Request* request)
|
|||
}
|
||||
|
||||
|
||||
fcgi_handler_status_t
|
||||
check_content_length(int content_length, int client_max_body_size)
|
||||
{
|
||||
LOG_TRACE("check_content_length");
|
||||
|
||||
if (content_length > 0 && content_length <= client_max_body_size) {
|
||||
LOG_DEBUG("Content-Length is ok");
|
||||
return HANDLER_SUCCESS;
|
||||
}
|
||||
|
||||
if (content_length == 0) {
|
||||
LOG_DEBUG("Content-Length == 0, so there is no body");
|
||||
return HANDLER_HTTP_OK;
|
||||
}
|
||||
|
||||
if (content_length < 0) {
|
||||
LOG_WARN("Content-Length < 0 (%d)", content_length);
|
||||
return HANDLER_HTTP_BAD_REQUEST;
|
||||
}
|
||||
|
||||
/* (content_length > client_max_body_size) */
|
||||
LOG_WARN("Content-Length (%d) is too large (> %d)",
|
||||
content_length,
|
||||
client_max_body_size);
|
||||
return HANDLER_HTTP_REQUEST_ENTITY_TOO_LARGE;
|
||||
}
|
||||
|
||||
|
||||
fcgi_handler_status_t
|
||||
check_content_type(const FCGX_Request* request, const char* acceptable_content_type)
|
||||
{
|
||||
LOG_TRACE("check_content_type");
|
||||
|
||||
const char* content_type = FCGX_GetParam(FCGI_PARAM_NAME_CONTENT_TYPE, request->envp);
|
||||
if (content_type == NULL) {
|
||||
LOG_ERROR("Could not get FCGI param: "FCGI_PARAM_NAME_CONTENT_TYPE);
|
||||
return HANDLER_HTTP_BAD_REQUEST;
|
||||
}
|
||||
|
||||
if (strcmp(content_type, acceptable_content_type) == 0) {
|
||||
LOG_DEBUG("Content-Type is ok");
|
||||
return HANDLER_SUCCESS;
|
||||
}
|
||||
|
||||
LOG_WARN("Content-Type is not acceptable, '%s' (!= '%s')",
|
||||
content_type, acceptable_content_type);
|
||||
|
||||
return HANDLER_HTTP_NOT_ACCEPTABLE;
|
||||
}
|
||||
|
||||
|
||||
char*
|
||||
fcgi_request_get_param(const FCGX_Request* request, const char* name, /*out*/ bool* err)
|
||||
{
|
||||
|
|
@ -45,6 +96,40 @@ error:
|
|||
}
|
||||
|
||||
|
||||
fcgi_handler_status_t
|
||||
fcgi_request_load_data(const FCGX_Request* request, int content_length, char** content)
|
||||
{
|
||||
LOG_TRACE("fcgi_request_load_data enter");
|
||||
|
||||
char* data = malloc(content_length + 1);
|
||||
if (data == NULL) {
|
||||
LOG_ERROR("Could not allocate memory for request body (%d bytes)", content_length + 1);
|
||||
return HANDLER_ERROR;
|
||||
}
|
||||
|
||||
int actual_content_length = FCGX_GetStr(data, content_length, request->in);
|
||||
|
||||
if (actual_content_length != content_length) {
|
||||
LOG_ERROR("fcgi_request_load_data: "
|
||||
"actual_content_length(%d) != content_length(%d); content: '%.*s'",
|
||||
actual_content_length, content_length,
|
||||
actual_content_length, data);
|
||||
free(data);
|
||||
return HANDLER_HTTP_BAD_REQUEST;
|
||||
}
|
||||
|
||||
data[content_length] = '\0';
|
||||
*content = data;
|
||||
|
||||
LOG_DEBUG("content_length: %d", content_length);
|
||||
LOG_DEBUG("content: '%s'", *content);
|
||||
|
||||
LOG_TRACE("fcgi_request_load_data exit");
|
||||
|
||||
return HANDLER_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
fcgi_handler_status_t
|
||||
fcgi_printf_str(const FCGX_Request* request, const char* response, int response_len)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue