The MIT License (MIT)
Introduction
Practical information
Files tree
Installation
Nodejs api documentation
Acknowledgement
Other project
This repository is intended introduce you to JWT via this presentation, JWT you will love it more than your parents
and with a working nodejs example based on jsonwebtoken
npm package.
You must be familiar with :
.
├── app // folder containing nodejs App example
│ ├── server
│ │ ├── db
│ │ │ ├── conf.js
│ │ │ ├── dbConnection.js
│ │ │ └── wtfKeyJwt.js
│ │ ├── env.js
│ │ ├── handlers.js
│ │ ├── index.js
│ │ ├── npm-debug.log
│ │ └── router
│ │ └── routes.js
│ └── vendors
├── package.json // npm install file
└── sql_request
└── testDb // Db postgresql export
$ git clone git@github.com:benjaminW78/json-web-token-introduction.git
// Go inside the new folder
$ npm i
// connect to postgres via shell
$ sudo -u postgres psql
// create Db for futur import
postgres=# CREATE DATABASE test;
// Import postgresql Db stored inside sql_request folder
postgres=# test < 'path_to_this_repo/json-web-token-introduction/sql_request/testDb';
// set your user to use this table.
postgres=# \connect test;
postgres=# GRANT ALL PRIVILEGES ON TABLE users TO yourUserPostGres;
postgres=# \q;
// start nodejs Server with nodemon instance.
$ npm run start
This section show you which paths of your nodejs server are availble.
// GET METHOD
http://localhost:8080/api/createToken
// request body: JSON OBJECT
{
"fsn":"toto@gmail.com", // db valid user email
"jwt_duration":1 , // JWT valid duration in minutes
"iss":"whatYouWant" // remove this key/value if you want your server to create jwt with his
// own issuer value, because
// when you will verify your previously created jwt, the server will test it with
// its own issuer value not the one you created your jwt
}
// GET METHOD
http://localhost:8080/api/verifyToken
// request body
T = yourTokenToTest
// request body: empty {}
Thanks to @Companeo for making me work on this problem.
You may also like those projects: