]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/iam: match_policy() treats MATCH_POLICY_ARN as case-sensitive
authorCasey Bodley <cbodley@redhat.com>
Thu, 13 Mar 2025 23:48:23 +0000 (19:48 -0400)
committerCasey Bodley <cbodley@redhat.com>
Mon, 28 Apr 2025 19:00:01 +0000 (15:00 -0400)
now that the ArnLike conditions are the only user of MATCH_POLICY_ARN,
change their case-sensitivity to comply with Amazon Resource Name (ARN)
condition operators[1]

[1] https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_ARN

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit a7a63aa3ffef1db3788e90e25192a53ee323c69c)

src/rgw/rgw_common.cc
src/test/rgw/test_rgw_iam_policy.cc

index 6fa913f05d6dc4d3b19c7d160a6fbd053c5d8ed0..33b6416867772a7672d773be85753f58147bb7d6 100644 (file)
@@ -2167,7 +2167,7 @@ int rgw_parse_op_type_list(const string& str, uint32_t *perm)
 bool match_policy(const std::string& pattern, const std::string& input,
                   uint32_t flag)
 {
-  const uint32_t flag2 = flag & (MATCH_POLICY_ACTION|MATCH_POLICY_ARN) ?
+  const uint32_t flag2 = (flag & MATCH_POLICY_ACTION) ?
       MATCH_CASE_INSENSITIVE : 0;
 
   std::string_view::size_type last_pos_input = 0, last_pos_pattern = 0;
index e33f15f8223ea1e82fa376b43b9f106def0af65b..aa97fb8767243019f8ef676879d6e875c3b277fc 100644 (file)
@@ -1458,7 +1458,7 @@ TEST(MatchPolicy, ARN)
 {
   constexpr auto flag = MATCH_POLICY_ARN;
   EXPECT_TRUE(match_policy("a:b:c", "a:b:c", flag));
-  EXPECT_TRUE(match_policy("a:b:c", "A:B:C", flag)); // case insensitive
+  EXPECT_FALSE(match_policy("a:b:c", "A:B:C", flag)); // case sensitive
   EXPECT_TRUE(match_policy("a:*:e", "a:bcd:e", flag));
   EXPECT_FALSE(match_policy("a:*", "a:b:c", flag)); // cannot span segments
 }