This repo contains 2 small projects that serve as examples on how to make Laravel Passport Authentication be accepted in NestJs with the Passport Js library.
At work we are migrating a Laravel Monolith App to Microservices, and we needed a way to transition users to the NestJs microservices using the same Jwt Token.
I made my best to generate a fully functional VS Devcontainer environment,so you can run it right after cloning the repo, sadly I wasn't able to install NodeJs from the Dockerfile, so here are the instructions.
git clone <repo>
Open the code in your favorite editor, if you are using devcontainers, you can run it as docker.
Install Nodejs with NVM already installed in the Dockerfile.
nvm install lts/hydrogen
cd laravel-auth
composer install
The devcontainer workspace already has Mysql 5.7, so you can ahead and use the built in credentials
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=laraveldb
DB_USERNAME=root
DB_PASSWORD=secret
php artisan migrate
php artisan passport:install
The NestJs project already has all the libraries needed, so you can go ahead and just install with NPM
cd nest-passport
npm install
The Project already has harcoded connection to the Database, inside the src/app.module.ts
and whenever I needed to reference the keys using the fs
package.
Ideally those should be on a .env
file.