chenjunkai 6 years ago
parent
commit
04f80a97e5
1 changed files with 23 additions and 1 deletions
  1. 23 1
      Controller/StsOssController.py

+ 23 - 1
Controller/StsOssController.py

@@ -66,12 +66,14 @@ class StsOssView(View):
         req.set_DurationSeconds(3600)
         Resource_access = "acs:oss:*:*:{bucket_name}/{userID}*".format(bucket_name=bucket_name,
                                                                             userID=userID)
+        Resource_access_root = "acs:oss:*:*:{bucket_name}".format(bucket_name=bucket_name)
+        # Resource_access_root = "acs:oss:*:*:{bucket_name}".format(bucket_name=bucket_name)
         print(Resource_access)
         policys = {
             "Version": "1",
             "Statement": [
                 {
-                    "Action": ["oss:PutObject", "oss:DeleteObject", "oss:GetObject","oss:ListObjects"],
+                    "Action": ["oss:PutObject", "oss:DeleteObject", "oss:GetObject"],
                     # "Action": ["*"],
                     "Resource": [Resource_access],
                     # "Resource": ["*"],
@@ -81,6 +83,26 @@ class StsOssView(View):
                         # "IpAddress": {"acs:SourceIp": "120.237.157.184"}
                         # "IpAddress": {"acs:SourceIp": "*"}
                     }
+                },
+                #######
+                {
+                    "Effect": "Allow",
+                    "Action": [
+                        "oss:ListObjects"
+                    ],
+                    "Resource": [
+                        "acs:oss:*:*:{userID}".format(userID=userID)
+                    ],
+                    "Condition": {
+                        "StringLike": {
+                            "oss:Prefix": [
+                                ""
+                            ]
+                        },
+                        "StringEquals": {
+                            "oss:Delimiter": "/"
+                        }
+                    }
                 }
             ]
         }