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

Added chmod perm, modal to change, api with local/ftp/sftp #399

Merged

Conversation

AndreiTelteu
Copy link
Contributor

@AndreiTelteu AndreiTelteu commented May 28, 2023

I started implementing the long-requested chmod functionality. #112

Feedback is welcomed

image

image

Progress:

  • ✅ Save permissions for local driver - done and tested
  • ✅ Save for FTP - done and tested
  • ✅ Save for SFTP - done and tested
  • ✅ Read for local driver - done and tested
  • ✅ Read for FTP driver - done and tested
  • ✅ Read for SFTP driver - done and tested
  • ✅ Hide the permissions button when driver does not support it
  • ✅ Make a custom FilegatorFtp that extends the original - done and tested
  • ✅ Add a recursive option (all / only files / only dirs) - done and tested

@codecov-commenter
Copy link

Codecov Report

Merging #399 (dc48119) into master (7582204) will decrease coverage by 2.02%.
The diff coverage is 0.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@             Coverage Diff              @@
##             master     #399      +/-   ##
============================================
- Coverage     99.89%   97.87%   -2.02%     
- Complexity      379      385       +6     
============================================
  Files            25       25              
  Lines           970      990      +20     
============================================
  Hits            969      969              
- Misses            1       21      +20     
Impacted Files Coverage Δ
backend/Controllers/FileController.php 93.47% <0.00%> (-6.53%) ⬇️
backend/Controllers/routes.php 100.00% <ø> (ø)
backend/Services/Auth/User.php 100.00% <ø> (ø)
backend/Services/Storage/Filesystem.php 91.02% <0.00%> (-8.98%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@AndreiTelteu
Copy link
Contributor Author

AndreiTelteu commented May 29, 2023

I finished reading permissions from ftp adapter. It's very ugly. I had to copy-paste a bunch of functions from the Ftp and AbstractFtpAdapter to make it work.

Possible better option is to create FilegatorFtpAdapter that extends Adapter/Ftp and only overwrite the normalizeUnixObject function. The only downside is that everyone has to switch from the original adapter to this modified one to make use of permissions.
Any thoughts on this?

@alcalbg
Copy link
Member

alcalbg commented May 30, 2023

Thanks for this!

I agree, this is very awkward and ugly solution.

I would rather have a brand new FilegatorFtpAdapter adapter with this functionality. Those who need this feature can look into it and make a switch.

However, the storage service needs to be adjusted first with permissions parameters and some defaults to maintain compatibility.

I also see that flysystem has added some support for file permissions, and the upgrade of this library is already overdue.

@AndreiTelteu
Copy link
Contributor Author

@alcalbg should we proceed with this current ugly ftp solution for now ? Only the recursive function remains to be developed for this PR to be complete.

Maybe I'll have time for a filesystem upgrade in a separate pr.

@AndreiTelteu
Copy link
Contributor Author

I also see that flysystem has added some support for file permissions, and the upgrade of this library is already overdue.

Actually it still does not expose raw permissions. When we switch to v3 we still don't know the exact permissions of a file, and we can't change them individually. Only a visibility parameter is present, the same as now on v1.

That function only does permission matching and conversion for visibility == public ? 0644 : 0600.

@AndreiTelteu
Copy link
Contributor Author

AndreiTelteu commented Jun 2, 2023

This PR it's done. I accomplished that I think it's needed.
PHPUnit and e2e cypress tests passed on my local machine.

@alcalbg I am trying to run vendor/bin/phpstan analyse ./backend but I get errors on existing files that I didn't modify, and then it stops ([ERROR] Found 12 errors)
WPAuth.php => wp_get_current_user not found... etc
Vuejs.php => Access to an undefined property ...rs\Vuejs::$add_to_head

Do I need to install something additional for this?

@AndreiTelteu AndreiTelteu changed the title [WIP] Added chmod perm, modal to change, api with local/ftp/sftp Added chmod perm, modal to change, api with local/ftp/sftp Jun 2, 2023
@AndreiTelteu
Copy link
Contributor Author

@alcalbg Did you have any chance to look at the final version?

@alcalbg
Copy link
Member

alcalbg commented Aug 7, 2023

No, not yet, sorry, I have other work to finish atm

@zoot
Copy link

zoot commented Aug 17, 2023

@AndreiTelteu your additions look ideal, since I've been eyeing out FileGator, but not proceeding, because of the inability to set UNIX file permissions.

It's unclear (to me) whether or not your PR does in fact implement what your screen shot implies, or whether the visibility layer of FlySystem is blocking this. Please clarify? Thanks.

My understanding is that you've avoided the visibility abstraction and have added the ability to set real UNIX permissions. Is this accurate. Sorry, I haven't downloaded and applied your code yet.

@AndreiTelteu
Copy link
Contributor Author

AndreiTelteu commented Aug 17, 2023

@zoot I implemented full custom UNIX permissions for the drivers: local, FTP, SFTP, and I tested them, verifying the results both in the new interface after a full page refresh, and on the server with ls -al. I tested the recursive function as well.

FlySystem's visibility features only have a configurable unix permission for public and private, and allows you to set a file to public or private, allowing you to switch only between those 2 configurable unix permissions. It does now allow you to change custom unix permission, or to see the existing permissions.

Note: for the FTP driver to work you have to use the custom driver that I made, I changed the documentation page to reflect this change.

https://github.com/filegator/filegator/blob/4e3b5615499325ded4ef44e18635f38080256dd5/docs/configuration/storage.md?plain=1#L46C67-L46C79

                'adapter' => function () {
-                  return new \League\Flysystem\Adapter\Ftp([
+                  return new \Filegator\Services\Storage\Adapters\FilegatorFtp([
                      'host' => 'example.com',
                      'username' => 'demo',

@zoot
Copy link

zoot commented Aug 17, 2023

Thanks for the prompt reply @AndreiTelteu and the good news :)

I'll set some time aside to apply your patch to the master branch and test with the local filesystem driver.

@jaapmarcus
Copy link

Any news regarding this PR?

Would love to see it merged...

@Nils98Ar
Copy link

@AndreiTelteu Any news on this?

@Bortus-AI
Copy link

Any news on this?

@ponasromas
Copy link

Why this is not merged?

@tlcd96
Copy link

tlcd96 commented Mar 21, 2024

@zoot weren't you going to test and merge this into filegator? The users are getting to the point of searching for another file manager because of this BASIC feature...

@zoot
Copy link

zoot commented Mar 21, 2024

@tlcd96 please review the above thread. I am neither a developer on this project, nor do I have time to contribute. Merely a possible and grateful end-user who has not yet had the time to attempt to apply the available patch for my own testing.

@tlcd96
Copy link

tlcd96 commented Mar 21, 2024

Sorry @zoot, I thought you where a developer for this project. My mistake, and I apologize.

@tlcd96
Copy link

tlcd96 commented Mar 21, 2024

@alcalbg are you one of the developers? if yes, can you, for god’s sake, see the patch and apply accordingly? we are waiting for this since 2023. also, i see that @AJBassa has committed some changes, we really need this on the filegator repo. please apply the patch and change what is needed since this changes where made in 2023

Read a fill current permissions for local driver

Finished permissions for ftp driver, read and change

Read permissions for sftp adapter

Created FilegatorFtp for a cleaner permissions integration

Implemented recursive chmod options for files/folders

Modified tests to cover permissions

Lint frontend permissions component
@AndreiTelteu
Copy link
Contributor Author

AndreiTelteu commented Apr 17, 2024

Hi @alcalbg
I merged with the latest version of master and squoshed all my commits.
Can you please take a look ?
What else is needed for this pr to be merged ?

@alcalbg
Copy link
Member

alcalbg commented Apr 17, 2024

Thanks @AndreiTelteu

@alcalbg alcalbg merged commit 27310f9 into filegator:master Apr 17, 2024
9 checks passed
@alcalbg
Copy link
Member

alcalbg commented Apr 17, 2024

This is now merged and released as v7.10.0

@AndreiTelteu AndreiTelteu deleted the feature/add-chmod-permissions branch April 18, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants