Giter Site home page Giter Site logo

aaronchi / auth-chat-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pubnub/auth-chat-demo

0.0 2.0 0.0 916 KB

A simple chat room demo using PubNub JavaScript pub/sub API for both client and server, combined with PubNub Access Manager APIs and OAuth.

Home Page: https://pubnub-auth-chat.herokuapp.com/

JavaScript 65.50% CSS 21.55% HTML 12.94%

auth-chat-demo's Introduction

PubNub Access Manager Chat Demo

Try the live demo! (You need a GitHub ccount to login to the chat demo!)

This simple demo is written is JavaScript for both client (JavaScript) and server (Node.js) to demonstrate how PubNub Access manager works and how you can implement in your app.

Once a user login, the user is given a auth token from OAuth. In this demo, the token is used as an auth_key that the "admin" can reference to grant a read/write permission to the user.

What is PubNub Access Manager?

PubNub Access Manager extends PubNub's existing security framework by allowing developers to create and enforce secure access to channels throughout the PubNub Real Time Network. What Access Manager does are:

  • Syndicate streams by providing authorization to users to read/write messages to one or more channels
  • Grant/revoke permissions for your real time streams at the user/device, channel or key level
  • Works with Auth tokens from any existing authentication system: Facebook Connect, Twitter, Google, LDAP, or homegrown solutions

Message Verification with ECC

Messages are encrypted with Elliptic curve cryptography (ECC) asymmetric algorithm, to avoid some trolls to spoof users.

To learn more about the digital signature, read Chat Security: User Identification with Digital Signature Message Verification on PubNub Blog.

User Database

For this demo, each user's public key (for ECC) is stored in PubNub history for its convenience, however in a real-life scenario, you probably want to store the info in your database.

Running this Demo on Your Machine Locally

If you want to run this demo on your own machine. Make sure that Node.js is installed.

  1. Fork or download this repo
  2. Install dependencies: $ npm install
  3. Set up your app on GitHub Developer applications (for OAuth)
  4. Include your own config.js file and save it at root of your app dir (See below)
  5. Run code: $ node index.js
  6. Open the web client at http://localhost:3000

config.js

Create a file with your own credintials:

module.exports = {
  auth: {
    github: {
      client_id: '614733a4294d....', // Get them from GitHub
      client_secret: '486e17d613bd...',
    }
  },
  pubnub: {
    secret_key: 'sec-c-M2U0NDI3....', // get it from PubNub Admin portal
    auth_key: '...' // any string you want
  }
};

auth-chat-demo's People

Contributors

girliemac avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.