Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Visibility Issue , All files are public #239

Closed
ravdeepsingh22 opened this issue Dec 12, 2020 · 8 comments
Closed

File Visibility Issue , All files are public #239

ravdeepsingh22 opened this issue Dec 12, 2020 · 8 comments
Labels

Comments

@ravdeepsingh22
Copy link

Have set the visibility as 'visibility' => 'private' in filesystem.php , But the uploaded file is always Public

@frasmage
Copy link
Collaborator

can you provide the entire disk config that you are using and a stat of the file?

From your other question, I'm assuming you are using the 'public' disk. For local filesystem, file visibility is equivalent to the unix permission level of the file (see Laravel docs). However, if you are using a disk within the webroot, it is still being read by the apache/nginx user when accessed via URL so will still be returned.

For disks not in the webroot, you could apply your own logic to determine which files to expose from a controller (relevant docs).

@ravdeepsingh22
Copy link
Author

ravdeepsingh22 commented Dec 13, 2020

I am referring to S3 storage on dreamhost here

's3dream' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID_D', ""), 'secret' => env('AWS_SECRET_ACCESS_KEY_D', ""), 'region' => env('AWS_DEFAULT_REGION_D', "us-east-1"), 'bucket' => env('AWS_BUCKET_D', 'mybucket'), 'url' => 'https://mybucket.objects-us-east-1.dream.io', 'endpoint' => 'https://objects-us-east-1.dream.io', 'visibility' => 'private', ],

@frasmage
Copy link
Collaborator

For cloud disks, you should double check the permissions of the bucket itself in AWS (or dreamhost?). You might have the bucket set to have all files be publicly accessible.

@ravdeepsingh22
Copy link
Author

Using Dreamhost : DreamObjects Double checked the Bucket is private + Object permissions default to private in DreamObjects

@frasmage
Copy link
Collaborator

frasmage commented Dec 13, 2020

Can you clarify what you mean by the objects being public? Is the object directly accessible via URL? Does $media->isVisible() return true? Does $media->getUrl() return a URL when you don't expect it to?

@ravdeepsingh22
Copy link
Author

ravdeepsingh22 commented Dec 14, 2020

Is the object directly accessible via URL? Yes
Does $media->isVisible() return true? Yes

Does $media->getUrl() return a URL when you don't expect it to? It returns the correct url to correct Bucket Resource , but that url is supposed to be private

QuickNote : If i use ->makePrivate() while uploading the file , it is working fine and making the file private .
The only issue is that it is not using the 'visibility' => 'private' when specified in filesystem.php , in that case , if we donot specify '->makePrivate() ' , It should be automatically making the file private

@frasmage
Copy link
Collaborator

ok, I see the issue. The uploader is defaulting to public. Use makePrivate() for now, I will adjust the behaviour when I get a chance

@ravdeepsingh22
Copy link
Author

Looks like this messed up the Variant Generation .
The uploaded image is public , but the generated variants are now Private

karmendra pushed a commit to karmendra/laravel-mediable that referenced this issue Feb 29, 2024
Take visibility value from filesystem config, if defined, if not default to public.

A fix for plank#239 (comment)

This was also the reason for issue reported in plank#173 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants