Jump to content

Specific permissions to access files


Shinori

Recommended Posts

Hello,

I'm trying to develop my own cloud storage system. 

Currently having trouble with permissions of certain files.
I need a specific client to have access to file located in user specific directory such as "/cloud/files/members/N10000/".
But I dont want the file to be accessable via url or by any other client.

The file could be an png, txt, mp4, etc.

No I dont want to use an opne source cloud software. I want to create my own one.

Is this possible with PHP. Do I need further software?

Using Debian 9 and PLESK 17.8

Thanks in advance.

Link to comment
Share on other sites

One option is to route all requests for those files to a PHP script that authorizes people before sending the file content, and having the actual files stored outside of the web server root.  You could also use a custom web server module to do authorization.

Link to comment
Share on other sites

49 minutes ago, justsomeguy said:

One option is to route all requests for those files to a PHP script that authorizes people before sending the file content, and having the actual files stored outside of the web server root.  You could also use a custom web server module to do authorization.

What exactly is a custom webserver module?

Sorry im not teh best in terms of configuring optional software for webservers 😕

 

Link to comment
Share on other sites

Apache, for example, has modules that change its behavior.  Some well-known ones are things like mod_rewrite or mod_expires.  One option would be a custom module like that which would handle the authentication and authorization so that the web server could still do its job serving the actual files.

Link to comment
Share on other sites

Wouldn't it be possible to "try'n'catch" a piece of code to temporarely use chmod and the file / directory just to show the content of the file?
I tried it but it didnt seem to work. Not sure if its my code or a generel problem. 🤔

Greetings

Link to comment
Share on other sites

Could I establish a SSH connection via PHP and create a new user on my Debian 9 system which only has access and permission to specific directories? 

I'd probably have to establish a new ssh connection each time i try to reach any data, would I ?

 

Link to comment
Share on other sites

You'd have to do the same thing every time, and it doesn't seem like it would much of an effect because anyone who pulls up the URL in a web browser would be running with the same permissions, whatever user the web server is running as.  You can't use that for authentication and authorization if you need different people to be able to access different files.  You need a way to authenticate who the user is, and a way to authorize that the user can access the file.  That's what usernames and passwords are for, that's authentication.  Once they authenticate themselves then you need a database or folder structure or something to tell you which user can access which file, so you need to check that also.  That's authorization.  If either of those fail then you need to show an error message.  All of that is done on the server with a language like PHP, or with a custom web server module.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...