mirror of
https://github.com/ceph/ceph
synced 2025-04-08 10:42:01 +00:00
rgw: fix certain return status cases in CORS
Change return values in certain cases, reorder checks, etc. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
6ae4049a09
commit
6af5a5377f
@ -2043,7 +2043,7 @@ int RGWOptionsCORS::validate_cors_request(RGWCORSConfiguration *cc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!validate_cors_rule_method(rule, req_meth)) {
|
if (!validate_cors_rule_method(rule, req_meth)) {
|
||||||
return -ENOTSUP;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -2059,12 +2059,7 @@ void RGWOptionsCORS::execute()
|
|||||||
dout(0) <<
|
dout(0) <<
|
||||||
"Preflight request without mandatory Origin header"
|
"Preflight request without mandatory Origin header"
|
||||||
<< dendl;
|
<< dendl;
|
||||||
ret = -EACCES;
|
ret = -EINVAL;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!cors_exist) {
|
|
||||||
dout(2) << "No CORS configuration set yet for this bucket" << dendl;
|
|
||||||
ret = -ENOENT;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req_meth = s->info.env->get("HTTP_ACCESS_CONTROL_REQUEST_METHOD");
|
req_meth = s->info.env->get("HTTP_ACCESS_CONTROL_REQUEST_METHOD");
|
||||||
@ -2072,7 +2067,12 @@ void RGWOptionsCORS::execute()
|
|||||||
dout(0) <<
|
dout(0) <<
|
||||||
"Preflight request without mandatory Access-control-request-method header"
|
"Preflight request without mandatory Access-control-request-method header"
|
||||||
<< dendl;
|
<< dendl;
|
||||||
ret = -EACCES;
|
ret = -EINVAL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!cors_exist) {
|
||||||
|
dout(2) << "No CORS configuration set yet for this bucket" << dendl;
|
||||||
|
ret = -ENOENT;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
req_hdrs = s->info.env->get("HTTP_ACCESS_CONTROL_ALLOW_HEADERS");
|
req_hdrs = s->info.env->get("HTTP_ACCESS_CONTROL_ALLOW_HEADERS");
|
||||||
|
@ -1486,18 +1486,16 @@ void RGWOptionsCORS_ObjStore_S3::send_response()
|
|||||||
uint32_t max_age = CORS_MAX_AGE_INVALID;
|
uint32_t max_age = CORS_MAX_AGE_INVALID;
|
||||||
/*EACCES means, there is no CORS registered yet for the bucket
|
/*EACCES means, there is no CORS registered yet for the bucket
|
||||||
*ENOENT means, there is no match of the Origin in the list of CORSRule
|
*ENOENT means, there is no match of the Origin in the list of CORSRule
|
||||||
*ENOTSUPP means, the HTTP_METHOD is not supported
|
|
||||||
*/
|
*/
|
||||||
if (ret == -ENOENT)
|
if (ret == -ENOENT)
|
||||||
ret = -EACCES;
|
ret = -EACCES;
|
||||||
if (ret != -EACCES) {
|
if (ret < 0) {
|
||||||
get_response_params(hdrs, exp_hdrs, &max_age);
|
|
||||||
} else {
|
|
||||||
set_req_state_err(s, ret);
|
set_req_state_err(s, ret);
|
||||||
dump_errno(s);
|
dump_errno(s);
|
||||||
end_header(s, NULL);
|
end_header(s, NULL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
get_response_params(hdrs, exp_hdrs, &max_age);
|
||||||
|
|
||||||
dump_errno(s);
|
dump_errno(s);
|
||||||
dump_access_control(s, origin, req_meth, hdrs.c_str(), exp_hdrs.c_str(), max_age);
|
dump_access_control(s, origin, req_meth, hdrs.c_str(), exp_hdrs.c_str(), max_age);
|
||||||
|
Loading…
Reference in New Issue
Block a user