This is a code sample for my article
This example shows how to setup Nest.js authorization various 3rd party providers
- facebood
- onelogin
you have to have them configured in advance only local provider works out of the box
I assume you have node, yarn/npm, postgres, redis
First of all you have to download dependencies
npm i
Then check config in
nano .env
and start in watch mode
npm run start
or in production mode
npm run build
npm run prod
Otherwise you can use docker
docker-compose up --build
You can log in to the application using trejgun@gmail.com/My5up3r5tr0ngP@55w0rd by executing this CURL request
curl -v \
-X POST http://localhost:3000/auth/login \
-d '{"email": "trejgun@gmail.com", "password": "My5up3r5tr0ngP@55w0rd"}' \
-H "Content-Type: application/json"
Or asymmetric key
curl -v \
-X POST http://localhost:3000/auth/biometric \
-d '{"email": "trejgun@gmail.com", "signature": "lHBr/oUxp8LYUojNLbTWQ3z3T5Lb2J2fAbgcfyD0PGzlE8Wm3ZQaMyzA3AHgMlHEqnqUKOaRCXGLi6DJkERL2PKDJh3SIWxZujR0gP28rTX+kUJaKAysLRZVqWESXBsnkszSIVYeQH7Y9y9aocGOgye+8HsIgFRz8d5ttF579YUIqs26vhPKLgYiWKUQ4kqAhUhbNQgsuUaBEm9APYDdtb8872mPWX06k52Ig4IAM3dSKi5HGXutY9Ks88Gp69HV0zBHvjrIqHqxF1gUn0GMqDdZQHw/YwVPJAPNo8fPVEpjrasp2pLO5f5g5a2GG/nvDUJPmbuB0TNrcGS4pLwfAA=="}' \
-H "Content-Type: application/json"
Also you can login with provider of your choice on http://localhost:3000/auth/login
This will return your profile
{"id":1,"email":"trejgun@gmail.com","roles":["admin"]}
This will return a list of users
{"list":[{"id":1,"email":"trejgun@gmail.com","roles":["admin"]}],"count":1}
RPs, especially with new providers, are welcome