From cf81a579a59b43d9f3a11b8339319090f9ee960a Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Mon, 23 Nov 2015 19:57:18 -0430 Subject: [PATCH 01/21] Create README.md --- example/README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 example/README.md diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..e9a6ce2 --- /dev/null +++ b/example/README.md @@ -0,0 +1,22 @@ +# Auth0 + Socket.io + +This is the seed project you need to use if you're going to create a Socket.io single page app that will use Auth0. + +## Running the example + +In order to run the example, you need to have `node` installed. + +You also need to set the ClientSecret, ClientId and Domain for your Auth0 app as variables with the following names respectively: `AUTH0_CLIENT_SECRET`, `AUTH0_CLIENT_ID` and `AUTH0_DOMAIN`. + +````bash +# auth0-variables.js file +AUTH0_CLIENT_SECRET=myCoolSecret +AUTH0_CLIENT_ID=myCoolClientId +AUTH0_DOMAIN=samples.auth0.com +```` +On your application in Auth0 you need to set http://localhost:3001 as an Allowed Origin (CORS) in the application settings page. + +1. run npm install +1. run node index.js in the directory of this project. + +Go to [http://localhost:3001](http://localhost:3001) and you'll see the app running :). From 4dd06a28ceed56f1bb2d850ca3427e5cc88d6380 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Mon, 23 Nov 2015 19:58:04 -0430 Subject: [PATCH 02/21] Update README.md --- example/README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/example/README.md b/example/README.md index e9a6ce2..533d4a1 100644 --- a/example/README.md +++ b/example/README.md @@ -14,8 +14,6 @@ AUTH0_CLIENT_SECRET=myCoolSecret AUTH0_CLIENT_ID=myCoolClientId AUTH0_DOMAIN=samples.auth0.com ```` -On your application in Auth0 you need to set http://localhost:3001 as an Allowed Origin (CORS) in the application settings page. - 1. run npm install 1. run node index.js in the directory of this project. From eae6966dfd1f0295574f527bb2ba48c44ad8c0da Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Mon, 23 Nov 2015 20:00:28 -0430 Subject: [PATCH 03/21] Update README.md --- example/README.md | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/example/README.md b/example/README.md index 533d4a1..35fb1c4 100644 --- a/example/README.md +++ b/example/README.md @@ -6,15 +6,7 @@ This is the seed project you need to use if you're going to create a Socket.io s In order to run the example, you need to have `node` installed. -You also need to set the ClientSecret, ClientId and Domain for your Auth0 app as variables with the following names respectively: `AUTH0_CLIENT_SECRET`, `AUTH0_CLIENT_ID` and `AUTH0_DOMAIN`. - -````bash -# auth0-variables.js file -AUTH0_CLIENT_SECRET=myCoolSecret -AUTH0_CLIENT_ID=myCoolClientId -AUTH0_DOMAIN=samples.auth0.com -```` -1. run npm install -1. run node index.js in the directory of this project. +1. run `npm install` +1. run `node index.js` in the directory of this project. Go to [http://localhost:3001](http://localhost:3001) and you'll see the app running :). From 37bb5bbc09e04d2c0199cd1f6a77aa95d02f6dfd Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Mon, 23 Nov 2015 20:17:16 -0430 Subject: [PATCH 04/21] Update index.js Updated console log to show the JWT --- example/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/example/index.js b/example/index.js index 9c7e337..bf9ac6c 100644 --- a/example/index.js +++ b/example/index.js @@ -13,7 +13,7 @@ io timeout: 15000 // 15 seconds to send the authentication message })) .on('authenticated', function(socket){ - console.log('connected & authenticated: ' + socket.decoded_token.toString()); + console.log('connected & authenticated: ' + JSON.stringify(socket.decoded_token)); socket.on('chat message', function(msg){ debugger; io.emit('chat message', msg); From f9d1c10783e7c263c5d7231beb47ea311918a9de Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Mon, 23 Nov 2015 20:18:26 -0430 Subject: [PATCH 05/21] Updated Lock Updated version of Lock --- example/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/index.html b/example/index.html index 4a7ac34..ef95266 100644 --- a/example/index.html +++ b/example/index.html @@ -15,7 +15,7 @@ #login button { width: 10%; padding: 8px; border: none; background: rgb(130, 255, 130);} - + @@ -85,4 +85,4 @@ }); - \ No newline at end of file + From a33bdfd730f3e72f20921e818b46520531c5648c Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Tue, 24 Nov 2015 14:03:25 -0430 Subject: [PATCH 06/21] Create auth0-variables.js --- example/auth0-variables.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 example/auth0-variables.js diff --git a/example/auth0-variables.js b/example/auth0-variables.js new file mode 100644 index 0000000..ce56020 --- /dev/null +++ b/example/auth0-variables.js @@ -0,0 +1,3 @@ +var AUTH0_CLIENT_ID='BUIJSW9x60sIHBw8Kd9EmCbj8eDIFxDC'; +var AUTH0_CLIENT_SECRET=''; +var AUTH0_DOMAIN='samples.auth0.com'; From 575269eaf6bcb602285d197a9a8a95e2df1df304 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:06:04 -0430 Subject: [PATCH 07/21] Update auth0-variables --- example/auth0-variables.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/example/auth0-variables.js b/example/auth0-variables.js index ce56020..b55e87d 100644 --- a/example/auth0-variables.js +++ b/example/auth0-variables.js @@ -1,3 +1,5 @@ -var AUTH0_CLIENT_ID='BUIJSW9x60sIHBw8Kd9EmCbj8eDIFxDC'; -var AUTH0_CLIENT_SECRET=''; -var AUTH0_DOMAIN='samples.auth0.com'; +(function (exports){ + exports.AUTH0_DOMAIN = 'Your_Auth0_Domain'; + exports.AUTH0_CLIENT_ID = 'Your_Auth0_Client_Id'; + exports.AUTH0_CLIENT_SECRET = 'Your_Auth0_Client_Secret'; +})(typeof exports === 'undefined' ? this['auth0Variables']={}: exports); From 4a905bdcfc02711f0a9321fe74c2955722dd44aa Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:09:05 -0430 Subject: [PATCH 08/21] Update index.html --- example/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/example/index.html b/example/index.html index ef95266..8d61c02 100644 --- a/example/index.html +++ b/example/index.html @@ -19,6 +19,7 @@ +
@@ -81,7 +82,8 @@ var lock = null; $(document).ready(function() { - lock = new Auth0Lock('YOUR_CLIENT_ID', 'YOUR_NAMESPACE'); + //These are set in auth0-variables.js + lock = new Auth0Lock(auth0Variables.AUTH0_CLIENT_ID, auth0Variables.AUTH0_DOMAIN); }); From 47da4c6855ddd0f8cde0bf4a7ba03c968aabeb47 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:10:15 -0430 Subject: [PATCH 09/21] Update index.js --- example/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/example/index.js b/example/index.js index bf9ac6c..a85192c 100644 --- a/example/index.js +++ b/example/index.js @@ -2,14 +2,19 @@ var app = require('express')(); var http = require('http').Server(app); var io = require('socket.io')(http); var socketioJwt = require('socketio-jwt'); +var auth0Variables = require('./auth0-variables'); app.get('/', function(req, res){ res.sendFile(__dirname + '/index.html'); }); +app.get('/auth0-variables.js', function(req, res){ + res.sendFile(__dirname + '/auth0-variables.js'); +}); + io .on('connection', socketioJwt.authorize({ - secret: Buffer('YOUR_CLIENT_SECRET', 'base64'), + secret: Buffer(auth0Variables.AUTH0_CLIENT_SECRET, 'base64'), timeout: 15000 // 15 seconds to send the authentication message })) .on('authenticated', function(socket){ From eea88d51c2cd9cb4b0a4813ad4a0706e8cd4a7a5 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:15:52 -0430 Subject: [PATCH 10/21] Update README.md --- example/README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/example/README.md b/example/README.md index 35fb1c4..cb9ed21 100644 --- a/example/README.md +++ b/example/README.md @@ -4,9 +4,12 @@ This is the seed project you need to use if you're going to create a Socket.io s ## Running the example +First, you need to put your `AUTH0_DOMAIN` (example.auth0.com), your `AUTH0_CLIENT_ID` and your `AUTH0_CLIENT_SECRET` on the `auth0-variables.js` file . You can find this information in the Application Settings on your Auth0.com dashboard. + In order to run the example, you need to have `node` installed. 1. run `npm install` 1. run `node index.js` in the directory of this project. + Go to [http://localhost:3001](http://localhost:3001) and you'll see the app running :). From 4afc4bd2f02d16d6ba9536f3577c61aca6138df9 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:22:38 -0430 Subject: [PATCH 11/21] Create README.md --- example/socketsio-auth0-sample/README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 example/socketsio-auth0-sample/README.md diff --git a/example/socketsio-auth0-sample/README.md b/example/socketsio-auth0-sample/README.md new file mode 100644 index 0000000..cb9ed21 --- /dev/null +++ b/example/socketsio-auth0-sample/README.md @@ -0,0 +1,15 @@ +# Auth0 + Socket.io + +This is the seed project you need to use if you're going to create a Socket.io single page app that will use Auth0. + +## Running the example + +First, you need to put your `AUTH0_DOMAIN` (example.auth0.com), your `AUTH0_CLIENT_ID` and your `AUTH0_CLIENT_SECRET` on the `auth0-variables.js` file . You can find this information in the Application Settings on your Auth0.com dashboard. + +In order to run the example, you need to have `node` installed. + +1. run `npm install` +1. run `node index.js` in the directory of this project. + + +Go to [http://localhost:3001](http://localhost:3001) and you'll see the app running :). From 2f4dbf0f5c3fd201d951a8d0218b11dfa30377b5 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:23:42 -0430 Subject: [PATCH 12/21] Create auth0-variables --- example/socketsio-auth0-sample/auth0-variables.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 example/socketsio-auth0-sample/auth0-variables.js diff --git a/example/socketsio-auth0-sample/auth0-variables.js b/example/socketsio-auth0-sample/auth0-variables.js new file mode 100644 index 0000000..b55e87d --- /dev/null +++ b/example/socketsio-auth0-sample/auth0-variables.js @@ -0,0 +1,5 @@ +(function (exports){ + exports.AUTH0_DOMAIN = 'Your_Auth0_Domain'; + exports.AUTH0_CLIENT_ID = 'Your_Auth0_Client_Id'; + exports.AUTH0_CLIENT_SECRET = 'Your_Auth0_Client_Secret'; +})(typeof exports === 'undefined' ? this['auth0Variables']={}: exports); From fa617d796dddab1b325a2e82c33cca3b30d05889 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:24:37 -0430 Subject: [PATCH 13/21] Create index.html --- example/socketsio-auth0-sample/index.html | 90 +++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 example/socketsio-auth0-sample/index.html diff --git a/example/socketsio-auth0-sample/index.html b/example/socketsio-auth0-sample/index.html new file mode 100644 index 0000000..8d61c02 --- /dev/null +++ b/example/socketsio-auth0-sample/index.html @@ -0,0 +1,90 @@ + + + + Socket.IO chat + + + + + + + + + +
+ +
+
+
    +
    + +
    +
    + + + + + From 598558beba54e91178d3698f40afcd38cd7f5836 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:25:27 -0430 Subject: [PATCH 14/21] Create index.js --- example/socketsio-auth0-sample/index.js | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 example/socketsio-auth0-sample/index.js diff --git a/example/socketsio-auth0-sample/index.js b/example/socketsio-auth0-sample/index.js new file mode 100644 index 0000000..a85192c --- /dev/null +++ b/example/socketsio-auth0-sample/index.js @@ -0,0 +1,30 @@ +var app = require('express')(); +var http = require('http').Server(app); +var io = require('socket.io')(http); +var socketioJwt = require('socketio-jwt'); +var auth0Variables = require('./auth0-variables'); + +app.get('/', function(req, res){ + res.sendFile(__dirname + '/index.html'); +}); + +app.get('/auth0-variables.js', function(req, res){ + res.sendFile(__dirname + '/auth0-variables.js'); +}); + +io + .on('connection', socketioJwt.authorize({ + secret: Buffer(auth0Variables.AUTH0_CLIENT_SECRET, 'base64'), + timeout: 15000 // 15 seconds to send the authentication message + })) + .on('authenticated', function(socket){ + console.log('connected & authenticated: ' + JSON.stringify(socket.decoded_token)); + socket.on('chat message', function(msg){ + debugger; + io.emit('chat message', msg); + }); + }); + +http.listen(3001, function(){ + console.log('listening on *:3001'); +}); From d34ee09ccd4e8131cc1693acd1a8c6f450987d78 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:26:08 -0430 Subject: [PATCH 15/21] Create package.json --- example/socketsio-auth0-sample/package.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 example/socketsio-auth0-sample/package.json diff --git a/example/socketsio-auth0-sample/package.json b/example/socketsio-auth0-sample/package.json new file mode 100644 index 0000000..f4ab4e8 --- /dev/null +++ b/example/socketsio-auth0-sample/package.json @@ -0,0 +1,10 @@ +{ + "name": "socket-chat-example", + "version": "0.0.1", + "description": "my first socket.io app", + "dependencies": { + "express": "^4.10.2", + "socket.io": "^1.3.6", + "socketio-jwt": "^4.3.1" + } +} From a89279bd42137f95914ed6d96e0e6573a4499501 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:26:30 -0430 Subject: [PATCH 16/21] Delete package.json --- example/package.json | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 example/package.json diff --git a/example/package.json b/example/package.json deleted file mode 100644 index f4ab4e8..0000000 --- a/example/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "socket-chat-example", - "version": "0.0.1", - "description": "my first socket.io app", - "dependencies": { - "express": "^4.10.2", - "socket.io": "^1.3.6", - "socketio-jwt": "^4.3.1" - } -} From 52c879507ec2bcf52f1be0552bfe086bc102e029 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:26:47 -0430 Subject: [PATCH 17/21] Delete README.md --- example/README.md | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 example/README.md diff --git a/example/README.md b/example/README.md deleted file mode 100644 index cb9ed21..0000000 --- a/example/README.md +++ /dev/null @@ -1,15 +0,0 @@ -# Auth0 + Socket.io - -This is the seed project you need to use if you're going to create a Socket.io single page app that will use Auth0. - -## Running the example - -First, you need to put your `AUTH0_DOMAIN` (example.auth0.com), your `AUTH0_CLIENT_ID` and your `AUTH0_CLIENT_SECRET` on the `auth0-variables.js` file . You can find this information in the Application Settings on your Auth0.com dashboard. - -In order to run the example, you need to have `node` installed. - -1. run `npm install` -1. run `node index.js` in the directory of this project. - - -Go to [http://localhost:3001](http://localhost:3001) and you'll see the app running :). From b560968eb1bb74af699e586040a40a6e555411bb Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:26:56 -0430 Subject: [PATCH 18/21] Delete auth0-variables.js --- example/auth0-variables.js | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 example/auth0-variables.js diff --git a/example/auth0-variables.js b/example/auth0-variables.js deleted file mode 100644 index b55e87d..0000000 --- a/example/auth0-variables.js +++ /dev/null @@ -1,5 +0,0 @@ -(function (exports){ - exports.AUTH0_DOMAIN = 'Your_Auth0_Domain'; - exports.AUTH0_CLIENT_ID = 'Your_Auth0_Client_Id'; - exports.AUTH0_CLIENT_SECRET = 'Your_Auth0_Client_Secret'; -})(typeof exports === 'undefined' ? this['auth0Variables']={}: exports); From b870e4d5b15a155dba2486025f64813edba8cc36 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:27:08 -0430 Subject: [PATCH 19/21] Delete index.html --- example/index.html | 90 ---------------------------------------------- 1 file changed, 90 deletions(-) delete mode 100644 example/index.html diff --git a/example/index.html b/example/index.html deleted file mode 100644 index 8d61c02..0000000 --- a/example/index.html +++ /dev/null @@ -1,90 +0,0 @@ - - - - Socket.IO chat - - - - - - - - - -
    - -
    -
    -
      -
      - -
      -
      - - - - - From eab3771d3bd9b0b04c7aab10a1cff2b85a84eed8 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Wed, 25 Nov 2015 19:27:16 -0430 Subject: [PATCH 20/21] Delete index.js --- example/index.js | 30 ------------------------------ 1 file changed, 30 deletions(-) delete mode 100644 example/index.js diff --git a/example/index.js b/example/index.js deleted file mode 100644 index a85192c..0000000 --- a/example/index.js +++ /dev/null @@ -1,30 +0,0 @@ -var app = require('express')(); -var http = require('http').Server(app); -var io = require('socket.io')(http); -var socketioJwt = require('socketio-jwt'); -var auth0Variables = require('./auth0-variables'); - -app.get('/', function(req, res){ - res.sendFile(__dirname + '/index.html'); -}); - -app.get('/auth0-variables.js', function(req, res){ - res.sendFile(__dirname + '/auth0-variables.js'); -}); - -io - .on('connection', socketioJwt.authorize({ - secret: Buffer(auth0Variables.AUTH0_CLIENT_SECRET, 'base64'), - timeout: 15000 // 15 seconds to send the authentication message - })) - .on('authenticated', function(socket){ - console.log('connected & authenticated: ' + JSON.stringify(socket.decoded_token)); - socket.on('chat message', function(msg){ - debugger; - io.emit('chat message', msg); - }); - }); - -http.listen(3001, function(){ - console.log('listening on *:3001'); -}); From 46ed7a662846889d2687192a47cb3dcbb63c0fd0 Mon Sep 17 00:00:00 2001 From: Annyv2 Date: Thu, 26 Nov 2015 09:49:32 -0430 Subject: [PATCH 21/21] Update README.md --- example/socketsio-auth0-sample/README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/example/socketsio-auth0-sample/README.md b/example/socketsio-auth0-sample/README.md index cb9ed21..a8467fc 100644 --- a/example/socketsio-auth0-sample/README.md +++ b/example/socketsio-auth0-sample/README.md @@ -2,10 +2,16 @@ This is the seed project you need to use if you're going to create a Socket.io single page app that will use Auth0. -## Running the example +### Configure your Auth0 credentials First, you need to put your `AUTH0_DOMAIN` (example.auth0.com), your `AUTH0_CLIENT_ID` and your `AUTH0_CLIENT_SECRET` on the `auth0-variables.js` file . You can find this information in the Application Settings on your Auth0.com dashboard. +### Set up the Allowed Origin (CORS) in Auth0 + +Then, you need to put `http://localhost:3001` as an Allowed Origin (CORS) in the Application Settings on your Auth0.com dashboard. + +### Running the example + In order to run the example, you need to have `node` installed. 1. run `npm install`