Say I have a simple php file that handles the uploading of data to a webserver using a JSON string.
Let’s say it’s a POST request to /upload.php
The web server does not have user/ any kind of login credentials.
In order to prevent any random person from uploading data if they happen to stumble upon this url, would it be bad practice to have a simple pass phrase check hardcoded in the php code?
Imagine including in the json string {“passcode”:”123abc”}
Where the server determines whether or not this pass phrase is present, or correct. And if it is not, it simply does nothing.
Pseudo code would be something like.
If (json[“passcode”] == “123abc”)
{
Upload
}
Else
{
Throw404
}
The passcode will have to be entered in a text box or something of the sort whenever a person wants to upload.
Like entering a password to log into a social network.
If this is bad practice, is there another alternative that doesn’t require users and various authentications?