Also adds unit tests for:
1. empty output from from_base64 (turns out to be harmless)
2. random and specific non-base64 and sort strings
(modified from upstream to avoid alteration of src/test/test_rgw_token.cc)
Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
(cherry picked from commit
0a4c91ec7652d02673a9b156cd16144d778a3844)
Fixes: http://tracker.ceph.com/issues/17324
} else {
/* try external authenticators (ldap for now) */
rgw::LDAPHelper* ldh = rgwlib.get_ldh(); /* !nullptr */
- RGWToken token{from_base64(key.id)};
+ RGWToken token;
+ /* boost filters and/or string_ref may throw on invalid input */
+ try {
+ token = rgw::from_base64(key.id);
+ } catch(...) {
+ token = std::string("");
+ }
if (token.valid() && (ldh->auth(token.id, token.key) == 0)) {
/* try to store user if it doesn't already exist */
if (rgw_get_user_info_by_uid(store, token.id, user) < 0) {
<< store->ctx()->_conf->rgw_ldap_uri
<< dendl;
- RGWToken token{from_base64(s3_access_key)};
+ RGWToken token;
+ /* boost filters and/or string_ref may throw on invalid input */
+ try {
+ token = rgw::from_base64(s3_access_key);
+ } catch(...) {
+ token = std::string("");
+ }
if (! token.valid())
return -EACCES;