Skip to content

Commit 6ee4416

Browse files
rgw/auth: correcting the error message to indicate
clearly that a pre-signed URL has expired. Signed-off-by: Pritha Srivastava <[email protected]>
1 parent 0464512 commit 6ee4416

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/rgw/rgw_auth.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ rgw::auth::Strategy::apply(const DoutPrefixProvider *dpp, const rgw::auth::Strat
299299
* nullptr inside. */
300300
ldpp_dout(dpp, 5) << "Failed the auth strategy, reason="
301301
<< result.get_reason() << dendl;
302+
//Special handling for expired pre-signed URL
303+
if (result.get_reason() == ERR_PRESIGNED_URL_EXPIRED) {
304+
result = result_t::deny(-EPERM);
305+
set_req_state_err(s, -EPERM, "The pre-signed URL has expired");
306+
}
302307
return result.get_reason();
303308
}
304309

src/rgw/rgw_auth_s3.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,15 +298,15 @@ static inline int parse_v4_query_string(const req_info& info, /* in
298298
you can set is 1, and the maximum is 604800 (seven days) */
299299
time_t exp = atoll(expires.data());
300300
if ((exp < 1) || (exp > 7*24*60*60)) {
301-
dout(10) << "NOTICE: exp out of range, exp = " << exp << dendl;
301+
dout(10) << "ERROR: exp out of range, exp = " << exp << dendl;
302302
return -EPERM;
303303
}
304304
/* handle expiration in epoch time */
305305
uint64_t req_sec = (uint64_t)internal_timegm(&date_t);
306306
uint64_t now = ceph_clock_now();
307307
if (now >= req_sec + exp) {
308-
dout(10) << "NOTICE: now = " << now << ", req_sec = " << req_sec << ", exp = " << exp << dendl;
309-
return -EPERM;
308+
dout(10) << "ERROR: presigned URL has expired, now = " << now << ", req_sec = " << req_sec << ", exp = " << exp << dendl;
309+
return -ERR_PRESIGNED_URL_EXPIRED;
310310
}
311311

312312
signedheaders = info.args.get("x-amz-signedheaders");

src/rgw/rgw_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ static inline const char* to_mime_type(const RGWFormat f)
306306
#define ERR_OBJECT_NOT_APPENDABLE 2220
307307
#define ERR_INVALID_BUCKET_STATE 2221
308308
#define ERR_INVALID_OBJECT_STATE 2222
309+
#define ERR_PRESIGNED_URL_EXPIRED 2223
309310

310311
#define ERR_BUSY_RESHARDING 2300
311312
#define ERR_NO_SUCH_ENTITY 2301

0 commit comments

Comments
 (0)