]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: introduce rgw::auth::s3::AWS4_HMAC_SHA256_STR to kill magics.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Thu, 11 May 2017 12:48:10 +0000 (14:48 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 7 Jun 2017 10:43:19 +0000 (12:43 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_auth_s3.cc
src/rgw/rgw_auth_s3.h
src/rgw/rgw_rest_s3.cc

index c02fb550218217a2c8480952fbec40bd9f469d88..d8113e6109dca341b40f9d2fd092a9318e787918 100644 (file)
@@ -331,9 +331,7 @@ static inline int parse_v4_credentials_hdrs(const req_info& info,           /* i
   const char* const http_auth = info.env->get("HTTP_AUTHORIZATION");
   string auth_str = http_auth;
 
-#define AWS4_HMAC_SHA256_STR "AWS4-HMAC-SHA256"
-#define CREDENTIALS_PREFIX_LEN (sizeof(AWS4_HMAC_SHA256_STR) - 1)
-  uint64_t min_len = CREDENTIALS_PREFIX_LEN + 1;
+  constexpr size_t min_len = strlen(AWS4_HMAC_SHA256_STR) + 1;
   if (auth_str.length() < min_len) {
     dout(10) << "credentials string is too short" << dendl;
     return -EINVAL;
index 0d2a9608933281a5675f4acccf0d82e3ce1732d5..9d0cb129515eb3ed52dd6ac4d5fcce239065e892 100644 (file)
@@ -318,6 +318,8 @@ namespace rgw {
 namespace auth {
 namespace s3 {
 
+static constexpr char AWS4_HMAC_SHA256_STR[] = "AWS4-HMAC-SHA256";
+
 static constexpr char AWS4_EMPTY_PAYLOAD_HASH[] = \
   "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
 
index 06c0417cc2815c58223732ab3fbf45306c41ca2d..b6006114827cb4005f47720f9021c728197ca5c1 100644 (file)
@@ -3108,6 +3108,8 @@ enum class AwsRoute {
 static inline std::pair<AwsVersion, AwsRoute>
 discover_aws_flavour(const req_info& info)
 {
+  using rgw::auth::s3::AWS4_HMAC_SHA256_STR;
+
   AwsVersion version = AwsVersion::UNKOWN;
   AwsRoute route = AwsRoute::UNKOWN;
 
@@ -3116,7 +3118,8 @@ discover_aws_flavour(const req_info& info)
     /* Authorization in Header */
     route = AwsRoute::HEADERS;
 
-    if (!strncmp(http_auth, "AWS4-HMAC-SHA256", 16)) {
+    if (!strncmp(http_auth, AWS4_HMAC_SHA256_STR,
+                 strlen(AWS4_HMAC_SHA256_STR))) {
       /* AWS v4 */
       version = AwsVersion::V4;
     } else if (!strncmp(http_auth, "AWS ", 4)) {
@@ -3126,7 +3129,7 @@ discover_aws_flavour(const req_info& info)
   } else {
     route = AwsRoute::QUERY_STRING;
 
-    if (info.args.get("X-Amz-Algorithm") == "AWS4-HMAC-SHA256") {
+    if (info.args.get("X-Amz-Algorithm") == AWS4_HMAC_SHA256_STR) {
       /* AWS v4 */
       version = AwsVersion::V4;
     } else if (!info.args.get("AWSAccessKeyId").empty()) {