]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check for timestamp for s3 keystone auth 3958/head
authorAbhishek Lekshmanan <abhishek.lekshmanan@gmail.com>
Mon, 17 Nov 2014 12:07:00 +0000 (17:37 +0530)
committerLoic Dachary <ldachary@redhat.com>
Wed, 11 Mar 2015 10:11:03 +0000 (11:11 +0100)
This commit ensures that we check for timestamp of s3 request is within
acceptable grace time of radosgw
Addresses some failures in #10062
Fixes: #10062
Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@gmail.com>
(cherry picked from commit 4b35ae067fef9f97b886afe112d662c61c564365)

src/rgw/rgw_rest_s3.cc

index 6fcecf7ac540e5f65c7d06cd66282054d9debedc..aaff84cf189ba2963fc57282daff75b9699a37cf 100644 (file)
@@ -2115,7 +2115,18 @@ int RGW_Auth_S3::authorize(RGWRados *store, struct req_state *s)
     } else {
       keystone_result = keystone_validator.validate_s3token(auth_id, token, auth_sign);
       if (keystone_result == 0) {
-        s->user.user_id = keystone_validator.response.token.tenant.id;
+       // Check for time skew first
+       time_t req_sec = s->header_time.sec();
+
+       if ((req_sec < now - RGW_AUTH_GRACE_MINS * 60 ||
+            req_sec > now + RGW_AUTH_GRACE_MINS * 60) && !qsr) {
+         dout(10) << "req_sec=" << req_sec << " now=" << now << "; now - RGW_AUTH_GRACE_MINS=" << now - RGW_AUTH_GRACE_MINS * 60 << "; now + RGW_AUTH_GRACE_MINS=" << now + RGW_AUTH_GRACE_MINS * 60 << dendl;
+         dout(0) << "NOTICE: request time skew too big now=" << utime_t(now, 0) << " req_time=" << s->header_time << dendl;
+         return -ERR_REQUEST_TIME_SKEWED;
+       }
+
+
+       s->user.user_id = keystone_validator.response.token.tenant.id;
         s->user.display_name = keystone_validator.response.token.tenant.name; // wow.
 
         /* try to store user if it not already exists */