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

Master key is invalid, you should only use master key to send push #601

Closed
topwebtek7 opened this issue Feb 23, 2016 · 3 comments
Closed

Comments

@topwebtek7
Copy link

Hello,
To fix this issue, I have checked #575, #564, #401 and #396, but I could not find the resolution.

Here is my code:

main.js

Parse.Cloud.define("SendPush", function(request, response) {

    console.log(request.params);

    var receiveUser = new Parse.User();
    receiveUser.id = request.params.receiveUserId

    var query = new Parse.Query(Parse.Installation);
    query.equalTo('user', receiveUser);

    Parse.Push.send({

        where: query,
        data: {

            alert: request.params.alert,
            user_id: request.params.user_id,
            type: request.params.type
        }
    }, {
        success: function() {
            console.log('##### PUSH OK');
            response.success("Push Sent");
        },
        error: function(error) {
            console.log('##### PUSH ERROR: ' + error.message);
            response.error("Push Failed");
        },
        userMasterKey: true

    });
});

index.js

var api = new ParseServer({

  databaseURI: databaseUri || 'mongodb://...',

  cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',

  appId: process.env.APP_ID || '',      

  masterKey: process.env.MASTER_KEY || '',

  fileKey: process.env.FILE_KEY || '',

  serverURL: 'http://localhost:1337/parse',

  filesAdapter: new S3Adapter(
    ...
  ),

  push: {

    android: {

      senderId: '',
      apiKey: ''
    },

    ios: [
      {
        pfx: __dirname + '/Certificates/Push_Sandbox.p12',
        bundleId: '',
        production: false
      },
      {
        pfx: __dirname + '/Certificates/Push_Production.p12',
        bundleId: '',
        production: true
      }
    ]
  }

});

When calling this on client app(iOS version), I get error message on my terminal.
##### PUSH ERROR: Master key is invalid, you should only use master key to send push
I am testing on my mac.

If you have the another resolution, please let me know about it.

Thanks,

Martin

@flovilmart
Copy link
Contributor

Push is disabled by default on the client IHMO, as it's unsafe to open the push API to the clients. Maybe we could lift that restriction but I would not encourage it. @drew-gross what do you think?

@drew-gross
Copy link
Contributor

I generally would like to prioritize compatibility with Parse.com, despite the security issues. It is possible (although difficult) to securely enable client push if your other security settings are on-point, not to mention the many clients already in the wild that rely on client push. I certainly wouldn't recommend new apps use client push, and I'd probably make sure there are lots of warnings if client push is enabled. At any rate, nobody is currently implementing it.

@otto1020 your issue is that you misspelled useMasterKey (you have use*r*MasterKey)

@topwebtek7
Copy link
Author

Thanks a lot. :)

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

No branches or pull requests

3 participants