rejetto / hfs

HFS is a web file server to run on your computer. Share folders or even a single file thanks to the virtual file system.
GNU General Public License v3.0
2.29k stars 227 forks source link

"Missing permission" if allowed to see but not download #684

Closed soleofthesea closed 4 months ago

soleofthesea commented 4 months ago

In the admin panel I have set in the root 'Who can download' to "No-one" and both "Who can see" and "Who can list" to "Any account (login required)". All subfolders use inherited permissions.

However when attempting to view any file it just throws 'missing permission'.

I'm aware it's basically impossible to actually make it so one can only view but not download files, so to clarify I'm mainly using HFS to browse various PDF files in Chrome when I'm away from home, so I wish for the front end to only expose 'Open' in the menu.

rejetto commented 4 months ago

this cannot be solved with permissions. what you want is to hide the "download" menu entry. this is possible and described in https://github.com/rejetto/hfs/blob/main/dev-plugins.md you can add this in admin-panel > custom html > before header

<script>
HFS.onEvent('fileMenu', ({ entry, menu }) => {
  const index = menu.findIndex(x => x.id === 'download')
  if (index >= 0)
      menu.splice(index, 1)
})
</script>

in no way this prevents the user from saving the pdf he's viewing.