]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check for timestamp for s3 keystone auth 2993/head
authorAbhishek Lekshmanan <abhishek.lekshmanan@gmail.com>
Mon, 17 Nov 2014 12:07:00 +0000 (17:37 +0530)
committerAbhishek Lekshmanan <abhishek.lekshmanan@gmail.com>
Mon, 24 Nov 2014 13:32:37 +0000 (19:02 +0530)
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>
src/rgw/rgw_rest_s3.cc

index 446a9e4732f0f39fe28fe3231a111362429d1a30..7668d111a1b6068ca9b1314645c24c07f1951bd7 100644 (file)
@@ -2137,7 +2137,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 */