Skip to content

Commit

Permalink
feat(Granting channel group manage permission to the server)
Browse files Browse the repository at this point in the history
  • Loading branch information
supertinou committed Jun 16, 2016
1 parent 2c9074e commit 202f5b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions server/.sample.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
PUBNUB_SUBSCRIBE_KEY=...
PUBNUB_PUBLISH_KEY=...
PUBNUB_SECRET_KEY=...
SERVER_PUBNUB_AUTH_KEY=......
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
GITHUB_REDIRECT_URI=...
Expand Down
21 changes: 18 additions & 3 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,30 @@ db.users = new Datastore({ filename: 'db/users.db', autoload: true });
| Setting up PubNub
|--------------------------------------------------------------------------
*/


console.log('------------ Initing PubNub ----------------')
pubnub = pubnub.init({
subscribe_key: process.env.PUBNUB_SUBSCRIBE_KEY,
publish_key: process.env.PUBNUB_PUBLISH_KEY,
secret_key: process.env.PUBNUB_SECRET_KEY,
auth_key: 'NodeJS-Server',
ssl: true
auth_key: process.env.SERVER_PUBNUB_AUTH_KEY,
ssl: true,
error: function(err){ console.log(err) }
});

// Grant to the SERVER_AUTH_KEY the manage permission in order to beeing able to add/remove channels to any channel group.
console.log('------------ Granting channel group manage permission to the server ----------------')
pubnub.grant({
channel_group: ':', // The wildcard ':' will grant access to any channel group
auth_key: process.env.SERVER_PUBNUB_AUTH_KEY,
manage: true,
read: true,
write: true,
ttl: 0,
callback: function(res){ console.log(res) },
error: function(err){ console.log(err) }
});


/*
|--------------------------------------------------------------------------
Expand Down

0 comments on commit 202f5b5

Please sign in to comment.