]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Use correct secret key for POST authn 1114/head
authorRobin H. Johnson <robbat2@gentoo.org>
Sun, 19 Jan 2014 02:01:20 +0000 (18:01 -0800)
committerRobin H. Johnson <robbat2@gentoo.org>
Sun, 19 Jan 2014 05:30:17 +0000 (21:30 -0800)
The POST authentication by signature validation looked up a user based
on the access key, then used the first secret key for the user. If the
access key used was not the first access key, then the expected
signature would be wrong, and the POST would be rejected.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
src/rgw/rgw_rest_s3.cc

index de56e24842cfbae233f88540ec0154b67afc1766..68dba64375e34f13181ad06e0779b604fb60ec6b 100644 (file)
@@ -964,7 +964,14 @@ int RGWPostObj_ObjStore_S3::get_policy()
 
     map<string, RGWAccessKey> access_keys  = user_info.access_keys;
 
-    map<string, RGWAccessKey>::const_iterator iter = access_keys.begin();
+    map<string, RGWAccessKey>::const_iterator iter = access_keys.find(s3_access_key);
+    // We know the key must exist, since the user was returned by
+    // rgw_get_user_info_by_access_key, but it doesn't hurt to check!
+    if (iter == access_keys.end()) {
+      ldout(s->cct, 0) << "Secret key lookup failed!" << dendl;
+      err_msg = "No secret key for matching access key";
+      return -EACCES;
+    }
     string s3_secret_key = (iter->second).key;
 
     char expected_signature_char[CEPH_CRYPTO_HMACSHA1_DIGESTSIZE];