rgw: add AWS4 completion support for RGW_OP_PUT_OBJ

Signed-off-by: Javier M. Mellid <jmunhoz@igalia.com>
This commit is contained in:
Javier M. Mellid 2016-01-13 16:13:01 +01:00
parent 55477546e8
commit e28072e392
5 changed files with 41 additions and 1 deletions

View File

@ -496,6 +496,30 @@ int RGWOp::verify_op_mask()
return 0;
}
int RGWOp::do_aws4_auth_completion()
{
int ret;
if (s->aws4_auth_needs_complete) {
/* complete */
ret = RGW_Auth_S3::authorize_aws4_auth_complete(store, s);
s->aws4_auth_needs_complete = false;
if (ret) {
return ret;
}
/* verify signature */
if (s->aws4_auth->signature != s->aws4_auth->new_signature) {
ret = -ERR_SIGNATURE_NO_MATCH;
ldout(s->cct, 20) << "delayed aws4 auth failed" << dendl;
return ret;
}
/* authorization ok */
dout(10) << "v4 auth ok" << dendl;
}
return 0;
}
int RGWOp::init_quota()
{
/* no quota enforcement for system requests */

View File

@ -84,6 +84,8 @@ protected:
RGWQuotaInfo user_quota;
int op_ret;
int do_aws4_auth_completion();
virtual int init_quota();
public:
RGWOp() : s(NULL), dialect_handler(NULL), store(NULL), cors_exist(false),

View File

@ -189,7 +189,7 @@ public:
virtual int verify_params();
virtual int get_params();
int get_data(bufferlist& bl);
virtual int get_data(bufferlist& bl);
};
class RGWPostObj_ObjStore : public RGWPostObj

View File

@ -812,6 +812,19 @@ int RGWPutObj_ObjStore_S3::get_params()
return RGWPutObj_ObjStore::get_params();
}
int RGWPutObj_ObjStore_S3::get_data(bufferlist& bl)
{
int ret = RGWPutObj_ObjStore::get_data(bl);
if (ret < 0)
s->aws4_auth_needs_complete = false;
if ((ret == 0) && s->aws4_auth_needs_complete) {
int ret_auth = do_aws4_auth_completion();
if (ret_auth)
return ret_auth;
}
return ret;
}
static int get_success_retcode(int code)
{
switch (code) {

View File

@ -140,6 +140,7 @@ public:
~RGWPutObj_ObjStore_S3() {}
int get_params();
int get_data(bufferlist& bl);
void send_response();
};