Skip to content

MiscMag101/PassportJS_PrototypeLevel6_TokenJWT_Blacklist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to test it

Download prototype

$ git clone https://github.com/MiscMag101/PassportJS_PrototypeLevel6_TokenJWT_Blacklist.git
  • Install NPM Packages
$ npm install

Create a self-signed certificat

$ mkdir tls
$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout tls/key.pem \
-out tls/cert.pem

For this certificat, a hostname will be required (such as app.example.com).

/!\ This self-signed certificat should be used only for testing purpose.

Register your app

Register your application on GitHub (Developers Settings) with the following parameters:

And get your client Id and secret.

Register hostname

If you don't have a local DNS, edit your host file to add static entry for "app.example.com"

Start MongoDB

$ systemctl start mongodb

Don't forget to enable authentication and create a user.

Redis

  • Start Redis
$ systemctl start redis

Start Application

$ PORT=3000 HOST=app.example.com CLIENT_ID=xxxxxxxxxxxxxxxx CLIENT_SECRET=yyyyyyyyyyyyyyyyyyyyy \
MONGOURI=mongodb://username:password@hostname:27017/DatabaseName JWT_SECRET=Secret npm start

Test

Open https://app.example.com:3000 and clic on "Signin with github" Accept the authorization request on GitHub, then you will be redirected automatically to the private page.

Clic on "Sign Out" then check your Redis server to see blacklisted token:

$ redis-cli
> KEYS *
> TTL key

About

This application is a demonstration prototype just to show how to use PassportJS and Passport GitHub Strategy. This prototype is the sixth level that implements JWT revocation in Redis database.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors