From df6d323908baaae56a0eed898ac2ec4351450803 Mon Sep 17 00:00:00 2001 From: Dunrong Huang Date: Wed, 23 Dec 2015 22:05:49 +0800 Subject: [PATCH] rgw: add a new error code for invalid secret key From http://docs.ceph.com/docs/master/radosgw/adminops/ when invalid secret key specified, rgw should return 400 with InvalidSecretKey Signed-off-by: Dunrong Huang --- src/rgw/rgw_common.h | 1 + src/rgw/rgw_http_errors.h | 1 + src/rgw/rgw_user.cc | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 9565f98e84b..505098a81d0 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -158,6 +158,7 @@ using ceph::crypto::MD5; #define ERR_NOT_SLO_MANIFEST 2031 #define ERR_EMAIL_EXIST 2032 #define ERR_KEY_EXIST 2033 +#define ERR_INVALID_SECRET_KEY 2034 #define ERR_USER_SUSPENDED 2100 #define ERR_INTERNAL_ERROR 2200 #define ERR_NOT_IMPLEMENTED 2201 diff --git a/src/rgw/rgw_http_errors.h b/src/rgw/rgw_http_errors.h index 0bb69fa7377..9d2ab3c7186 100644 --- a/src/rgw/rgw_http_errors.h +++ b/src/rgw/rgw_http_errors.h @@ -53,6 +53,7 @@ const static struct rgw_http_errors RGW_HTTP_ERRORS[] = { { ERR_USER_EXIST, 409, "UserAlreadyExists" }, { ERR_EMAIL_EXIST, 409, "EmailExists" }, { ERR_KEY_EXIST, 409, "KeyExists"}, + { ERR_INVALID_SECRET_KEY, 400, "InvalidSecretKey"}, { ENOTEMPTY, 409, "BucketNotEmpty" }, { ERR_PRECONDITION_FAILED, 412, "PreconditionFailed" }, { ERANGE, 416, "InvalidRange" }, diff --git a/src/rgw/rgw_user.cc b/src/rgw/rgw_user.cc index fb46e4e8acf..14b1f14c313 100644 --- a/src/rgw/rgw_user.cc +++ b/src/rgw/rgw_user.cc @@ -917,7 +917,7 @@ int RGWAccessKeyPool::generate_key(RGWUserAdminOpState& op_state, std::string *e if (!gen_secret) { if (op_state.get_secret_key().empty()) { set_err_msg(err_msg, "empty secret key"); - return -EINVAL; + return -ERR_INVALID_SECRET_KEY; } key = op_state.get_secret_key(); @@ -1049,7 +1049,7 @@ int RGWAccessKeyPool::modify_key(RGWUserAdminOpState& op_state, std::string *err if (key.empty()) { set_err_msg(err_msg, "empty secret key"); - return -EINVAL; + return -ERR_INVALID_SECRET_KEY; } // update the access key with the new secret key -- 2.47.3