const std::string& string_to_sign,
const std::string_view& signature,
const signature_factory_t& signature_factory,
+ bool ignore_signature,
optional_yield y) const
-> access_token_result
{
/* Check that credentials can correctly be used to sign data */
if (t) {
- std::string sig(signature);
- server_signature_t server_signature = signature_factory(cct, t->get<1>(), string_to_sign);
- if (sig.compare(server_signature) == 0) {
+ /* We should ignore checking signature in cache if caller tells us to which
+ * means we're handling a HTTP OPTIONS call. */
+ if (ignore_signature) {
+ ldpp_dout(dpp, 20) << "ignore_signature set and found in cache" << dendl;
return {t->get<0>(), t->get<1>(), 0};
} else {
- ldpp_dout(dpp, 0) << "Secret string does not correctly sign payload, cache miss" << dendl;
+ std::string sig(signature);
+ server_signature_t server_signature = signature_factory(cct, t->get<1>(), string_to_sign);
+ if (sig.compare(server_signature) == 0) {
+ return {t->get<0>(), t->get<1>(), 0};
+ } else {
+ ldpp_dout(dpp, 0) << "Secret string does not correctly sign payload, cache miss" << dendl;
+ }
}
} else {
ldpp_dout(dpp, 0) << "No stored secret string, cache miss" << dendl;
const string_to_sign_t& string_to_sign,
const signature_factory_t& signature_factory,
const completer_factory_t& completer_factory,
- /* Passthrough only! */
const req_state* s,
optional_yield y) const
{
std::vector<std::string> admin;
} accepted_roles(cct);
+ /* When we handle a HTTP OPTIONS call we must ignore the signature */
+ bool ignore_signature = (s->op_type == RGW_OP_OPTIONS_CORS);
+
auto [t, secret_key, failure_reason] =
get_access_token(dpp, access_key_id, string_to_sign,
- signature, signature_factory, y);
+ signature, signature_factory, ignore_signature, y);
if (! t) {
if (failure_reason == -ERR_SIGNATURE_NO_MATCH) {
// we looked up a secret but it didn't generate the same signature as
}
const RGWAccessKey& k = iter->second;
+ /* Ignore signature for HTTP OPTIONS */
+ if (s->op_type == RGW_OP_OPTIONS_CORS) {
+ auto apl = apl_factory->create_apl_local(cct, s, user->get_info(),
+ k.subuser, std::nullopt, access_key_id);
+ return result_t::grant(std::move(apl), completer_factory(k.key));
+ }
+
const VersionAbstractor::server_signature_t server_signature = \
signature_factory(cct, k.key, string_to_sign);
auto compare = signature.compare(server_signature);