barryvdh / laravel-elfinder

elFinder bundle for Laravel
739 stars 171 forks source link

Passing visibility = public to vendor/league/flysystem-aws-s3-v3/src/AwsS3Adapter.php #187

Open odinns opened 7 years ago

odinns commented 7 years ago

I have config/elfinder.php with an s3 disk:

'disks' => [ // 'uploads', 's3', ],

Also set 'visibility' => 'public' on the disk in config/filesystems.php

But uploaded files are still made private. How to I make them visible (ACL = public-read)?

Tried all kinds of ways in config/elfinder.php, but no joy.

rollingbox commented 6 years ago

Any solution?

noogen commented 5 years ago

I wasn't having issue before because my old bucket was EVERYONE/WORLD/PUBLIC readable. I ran into this issue on a new bucket without any permission. It seem to be a problem in the driver here: https://github.com/barryvdh/elfinder-flysystem-driver/blob/master/src/Driver.php#L534

From line 529 to 534, I don't see any code that set permission config['visibility'] anywhere in accordance with doc: http://flysystem.thephpleague.com/docs/usage/filesystem-api/

The result is that, all files uploaded to bucket, is private.

Alternatively, this issue does not affect me because I set my bucket publicly available to everyone. I know this is a bad practice, according to everyone, include AWS. But it's not a problem for me because the entire bucket is primarily use for web hosting. Below is my bucket policy, for reference.

WARNING: DO NOT DO this unless you really want EVERYONE/WORLD/PUBLIC READABLE

{
    "Version": "2008-10-17",
    "Id": "HelloEveryone",
    "Statement": [
        {
            "Sid": "DenyAccidentalDeleteOfThisBucket",
            "Effect": "Deny",
            "Principal": "*",
            "Action": "s3:DeleteBucket",
            "Resource": "arn:aws:s3:::bucket-name"
        },
        {
            "Sid": "PublicReadGetObject",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::bucket-name/*"
        }
    ]
}

I posted another alternative solution. If you are ok with things being private inside of s3, then you can generate a signed URL: https://github.com/barryvdh/laravel-elfinder/issues/236#issuecomment-422964351