项目作者: musobarlab
项目描述 :
oauth2 server example with Node Js
高级语言: JavaScript
项目地址: git://github.com/musobarlab/nodejs-oauth2-jwt.git
The OAuth 2.0 Authorization Framework
Node JS Json Web Token using Passport Js for securing api example
Getting started
- cd /your/root/project
- npm install
- npm start
Using Docker
- go to your root project run:
$ docker build -t node-oauth2-jwt .
$ docker images
$ docker run -it -p 3000:9000 --name [NEW-NAME-FOR-node-oauth2-jwt] [YOUR-DOCKER-IMAGE]
- OR Remove Previous Container first
$ docker rm PREVIOUS-NAME-node-oauth2-jwt
RUN
first inspect docker’s VM IP
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' [YOUR CONTAINER ID]
then you can visit eg: http://172.17.0.2:3000/
Endpoint
- POST
- localhost:3000/register_client
- POST
- localhost:3000/token?grant_type=client_credentials
- require Authorization Basic:
- username, eg: wuriyanto
- password, eg: xxxx-xxx-xxx-xxxx
- 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
- 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
- GET
- localhost:3000/profile_test
- require authorization header (your username_password access token):
- access token, eg: ‘Bearer eyJhbGc.iOiJIUzI.1NiIsInR’
- GET
- localhost:3000/client_test
- require authorization header (your client access token):
- access token, eg: ‘Bearer eyJhbGc.iOiJIUzI.1NiIsInR’