diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..9157c92 --- /dev/null +++ b/example/README.md @@ -0,0 +1,3 @@ +# Deprecation Notice + +This sample has been deprecated. Please see the [auth0-samples](https://github.com/auth0-samples) org for the latest Auth0 samples. \ No newline at end of file diff --git a/example/socketsio-auth0-sample/README.md b/example/socketsio-auth0-sample/README.md deleted file mode 100644 index ccc146e..0000000 --- a/example/socketsio-auth0-sample/README.md +++ /dev/null @@ -1,30 +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. - -### Configure your Auth0 credentials - -First, you need to set the ClientSecret, ClientId and Domain for your Auth0 app as environment variables with the following names respectively: `AUTH0_CLIENT_SECRET`, `AUTH0_CLIENT_ID` and `AUTH0_DOMAIN`. You can find this information in your Auth0 Dashboard. - -So, create a file named `.env` in the directory and set the values like the following: - -````bash -# .env file -AUTH0_CLIENT_SECRET=myCoolSecret -AUTH0_CLIENT_ID=myCoolClientId -AUTH0_DOMAIN=myCoolDomain -```` - -### 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` -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 :). diff --git a/example/socketsio-auth0-sample/index.js b/example/socketsio-auth0-sample/index.js deleted file mode 100644 index aba5f43..0000000 --- a/example/socketsio-auth0-sample/index.js +++ /dev/null @@ -1,41 +0,0 @@ -var express = require('express'); -var app = express(); -var http = require('http').Server(app); -var io = require('socket.io')(http); -var socketioJwt = require('socketio-jwt'); -var dotenv = require('dotenv'); - -dotenv.load(); - -var env = { - AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID, - AUTH0_DOMAIN: process.env.AUTH0_DOMAIN -}; -var port = process.env.PORT || 3001; - -app.set('views', __dirname + '/views'); -app.set('view engine', 'pug'); - -io - .on('connection', socketioJwt.authorize({ - secret: Buffer(JSON.stringify(process.env.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); - }); - }); - -app.use(express.static(__dirname + '/public')); - -app.get('/', function (req, res) { - res.render('index', { env: env }); -}); - -http.listen(port, function(){ - console.log('listening on *:' + port); -}); - diff --git a/example/socketsio-auth0-sample/package.json b/example/socketsio-auth0-sample/package.json deleted file mode 100644 index 79381ce..0000000 --- a/example/socketsio-auth0-sample/package.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "socket-auth0-chat-example", - "version": "1.0.0", - "description": "Auth0 + Socket.io seed", - "repository": { - "type": "git", - "url": "git://github.com/auth0/socketio-jwt.git" - }, - "author": "Auth0", - "license": "MIT", - "dependencies": { - "dotenv": "^2.0.0", - "express": "^4.13.4", - "pug": "^2.0.0-beta2", - "socket.io": "^1.4.6", - "socketio-jwt": "^4.3.4" - }, - "bugs": { - "url": "https://github.com/auth0/socketio-jwt/issues" - }, - "homepage": "https://github.com/auth0/socketio-jwt#readme", - "devDependencies": {}, - "scripts": { - "start": "node index.js", - "test": "echo \"Error: no test specified\" && exit 1" - } - -} diff --git a/example/socketsio-auth0-sample/public/stylesheets/style.css b/example/socketsio-auth0-sample/public/stylesheets/style.css deleted file mode 100644 index 2e749fe..0000000 --- a/example/socketsio-auth0-sample/public/stylesheets/style.css +++ /dev/null @@ -1,10 +0,0 @@ -* { margin: 0; padding: 0; box-sizing: border-box; } -body { font: 13px Helvetica, Arial; } -#chatForm { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; } -#chatForm input { border: 0; padding: 10px; width: 90%; margin-right: .5%; } -#chatForm button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; } -#messages { list-style-type: none; margin: 0; padding: 0; } -#messages li { padding: 5px 10px; } -#messages li:nth-child(odd) { background: #eee; } -#login { width: 100%; padding: 10px } -#login button { width: 10%; padding: 8px; border: none; background: rgb(130, 255, 130);} diff --git a/example/socketsio-auth0-sample/views/index.pug b/example/socketsio-auth0-sample/views/index.pug deleted file mode 100644 index 3175adc..0000000 --- a/example/socketsio-auth0-sample/views/index.pug +++ /dev/null @@ -1,78 +0,0 @@ -extends layout - -block content - script(src="https://cdn.auth0.com/js/lock/10.0/lock.min.js") - script(src="/socket.io/socket.io.js") - script(src="http://code.jquery.com/jquery-1.12.4.js") - - - div#login - button.btn Login - div#chat - ul#messages - form(id="chatForm" action="") - input(id="m" autocomplete="off") - button.btn Send - - script. - var userProfile; - var userToken; - var lock = new Auth0Lock('#{env.AUTH0_CLIENT_ID}', '#{env.AUTH0_DOMAIN}'); - var id_token = localStorage.getItem('id_token'); - $('#chat').hide(); - $('#login button').click(function (e) { - e.preventDefault(); - lock.show(); - }); - - lock.on('authenticated', function(authResult) { - lock.getProfile(authResult.idToken, function(error, profile) { - if (error) { - // Handle error - return; - } - console.log('connected and authenticated'); - localStorage.setItem('id_token', authResult.idToken); - localStorage.setItem('profile', JSON.stringify(profile)); - userProfile = profile; - id_token = authResult.idToken; - openChat(); - }); - }); - - if (id_token) { - lock.getProfile(id_token, function (err, profile) { - if (err) { - return alert('There was an error getting the profile: ' + err.message); - } - userProfile = profile; - openChat(); - }); - } - - function openChat() { - var socket = io(); - socket - .on('connect', function (msg) { - console.log("connected"); - socket.emit('authenticate', {token: id_token}); // send the jwt - }) - .on('authenticated', function () { - //Do - $('#login').hide(); - $('#chat').show(); - $('form').submit(function (event) { - socket.emit('chat message', $('#m').val()); - $('#m').val(''); - return false; - }); - }) - .on('unauthorized', function(msg){ - console.log("unauthorized: " + JSON.stringify(msg.data)); - throw new Error(msg.data.type); - }) - .on('chat message', function (msg) { - console.log("msg"); - $('#messages').append($('
  • ').text(msg)); - }); - }; diff --git a/example/socketsio-auth0-sample/views/layout.pug b/example/socketsio-auth0-sample/views/layout.pug deleted file mode 100644 index 5941a37..0000000 --- a/example/socketsio-auth0-sample/views/layout.pug +++ /dev/null @@ -1,7 +0,0 @@ -doctype html -html - head - - link(rel='stylesheet', href='/stylesheets/style.css') - body - block content