Skip to content
Snippets Groups Projects
Commit 7bf60528 authored by Daniel Göbel's avatar Daniel Göbel
Browse files

Fix wrong tenat and resource in bucket policy

parent 016f5045
No related branches found
No related tags found
2 merge requests!7Fix wrong tenat and resource in bucket policy,!6First working version
......@@ -99,24 +99,6 @@ async def create_bucket(
)
s3_bucket = s3.Bucket(db_bucket.name)
s3_bucket.create()
acls = s3.BucketAcl(db_bucket.name)
# Add user to ACL with READ permission for the bucket to enable listing of objects in the bucket.
acls.put(
AccessControlPolicy={
"Grants": acls.grants
+ [
{
"Grantee": {
"DisplayName": user.display_name if user.display_name else "",
"ID": user.username,
"Type": "CanonicalUser",
},
"Permission": "READ",
}
],
"Owner": acls.owner, # type: ignore
}
)
# Add basic permission to the user for getting, creating and deleting objects in the bucket.
bucket_policy = json.dumps(
{
......@@ -125,9 +107,9 @@ async def create_bucket(
{
"Sid": "PseudoOwnerPerm",
"Effect": "Allow",
"Principal": {"AWS": [f"arn:aws:iam::usfolks:user/{user.username}"]},
"Action": ["s3:GetObject", "s3:DeleteObject", "s3:PutObject"],
"Resource": f"arn:aws:s3:::{db_bucket.name}/*",
"Principal": {"AWS": [f"arn:aws:iam:::user/{user.username}"]},
"Action": ["s3:GetObject", "s3:DeleteObject", "s3:PutObject", "s3:ListBucket"],
"Resource": [f"arn:aws:s3:::{db_bucket.name}/*", f"arn:aws:s3:::{db_bucket.name}"],
}
],
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment