项目作者: musobarlab

项目描述 :
oauth2 server example with Node Js
高级语言: JavaScript
项目地址: git://github.com/musobarlab/nodejs-oauth2-jwt.git
创建时间: 2017-02-16T06:55:18Z
项目社区:https://github.com/musobarlab/nodejs-oauth2-jwt

开源协议:

下载


The OAuth 2.0 Authorization Framework

Node JS Json Web Token using Passport Js for securing api example

Getting started

  1. - cd /your/root/project
  2. - npm install
  3. - npm start

Using Docker

  • go to your root project run:
  1. $ docker build -t node-oauth2-jwt .
  • Check your list images :
  1. $ docker images
  • Run your image
  1. $ docker run -it -p 3000:9000 --name [NEW-NAME-FOR-node-oauth2-jwt] [YOUR-DOCKER-IMAGE]
  • OR Remove Previous Container first
  1. $ docker rm PREVIOUS-NAME-node-oauth2-jwt
  • RUN

    • first inspect docker’s VM IP

      1. $ docker inspect --format '{{ .NetworkSettings.IPAddress }}' [YOUR CONTAINER ID]
    • then you can visit eg: http://172.17.0.2:3000/

Endpoint

  1. - POST
  • localhost:3000/register_client
    • require body :
      • username, eg: wuriyanto
  1. - POST
  • localhost:3000/token?grant_type=client_credentials
    • require Authorization Basic:
      • username, eg: wuriyanto
      • password, eg: xxxx-xxx-xxx-xxxx
  1. - POST
  • localhost:3000/token?grant_type=password
    • require Authorization Basic:
      • username, eg: valid_client_id
      • password, eg: 123456
    • require body :
      • username, eg: wuriyanto
      • password, eg: 12345
  1. - POST
  • localhost:3000/token?grant_type=refresh_token
    • require Authorization Basic:
      • username, eg: valid_client_id
      • password, eg: 123456
    • require body :
      • refresh_token, eg: 27d0a468-3125-4b58-b505-969c3d18bdd1
  1. - GET
  • localhost:3000/profile_test
    • require authorization header (your username_password access token):
      • access token, eg: ‘Bearer eyJhbGc.iOiJIUzI.1NiIsInR’
  1. - GET
  • localhost:3000/client_test
    • require authorization header (your client access token):
      • access token, eg: ‘Bearer eyJhbGc.iOiJIUzI.1NiIsInR’