]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check for timestamp for s3 keystone auth
authorAbhishek Lekshmanan <abhishek.lekshmanan@gmail.com>
Mon, 17 Nov 2014 12:07:00 +0000 (17:37 +0530)
committerLoic Dachary <ldachary@redhat.com>
Mon, 2 Feb 2015 15:15:32 +0000 (16:15 +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 b5a7a7266d6eea477de4d3b6e302dc0909807ea8..f9b3bc60fb9945d20a819e97657932f382dbb02a 100644 (file)
@@ -2142,7 +2142,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 */