PFFile upload via Dashboard fails with 403
After a recent update to Parse-Server 2.2.24 running Parse-dashboard 1.1.19, we are having issues with PFFile uploads via the dashboard to S3 server via the filesAdapter config.
Environment Setup
Config
...
filesAdapter: new S3Adapter(
"Accesskey", //AccessKey
"SuperSecret", //Secret
"some-bucketname", //Bucket
{
directAccess: true,
bucketPrefix: "user_uploads/"
}
)
...
Server
var api = new ParseServer({
databaseURI: databaseURI,
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: buildVariables.appId,
masterKey: buildVariables.masterKey,
serverURL: buildVariables.serverURL,
publicServerURL : buildVariables.publicServerURL,
clientKey: buildVariables.clientKey,
javascriptKey: buildVariables.javascriptKey,
appName: buildVariables.appName,
filesAdapter: buildVariables.filesAdapter,
});
Steps to reproduce
We have been able to replicate the issue by calling the upload mechanism directly in cloud code using only AppId and Masterkey- this results in a 403 error. If we include the ClientKey in the cloud code request, the request is successful as expected (200).
Rolling Parse-Server back to 2.2.23 allows the file upload to work as expected, with unchanged config settings. It appears that additional key requirements on the server need to be supported by the dashboard- ie, we need to supply the Clientkey to the dashboard config for the upload to succeed.
You can add any kind of key to the dashboard config - e.g. I needed to add javascriptKey for stuff to work :)
@mario Sigh, thanks. Such an obvious solution escaped me.
FYI, for anyone else with the issue, adding clientKey to Parse-Dashboard config solves the problem.
"apps": [
{
"serverURL": buildVariables.serverURL,
"appId": buildVariables.appId,
"masterKey": buildVariables.masterKey,
"appName": buildVariables.appName,
"clientKey": buildVariables.clientKey
}
],
@Roost it happens to the best of us - let me know if I can help you in any other way :)
What is happening is that you do not specify all 4 auth keys (dotnet, js, rest, client) on parse-server and prior to 2.2.24 this would mean no keys being checked.
In 2.2.24 if the master key is not supplied then at least one auth key must match. It seems file upload is not using the master key so I think this is worth investigating or at least updating the docs if clientKey is required now.