This is an authentication and authorization Nestjs module. It implements JWT access and refresh tokens in the safest way using HTTPOnly cookies and Redis for token invalidation. It also implements user roles and permissions for authorization using Nestjs guards. The database used for storing user, role, and permission entities is MongoDB.
In addition to these features, this template provides Two Factor Authentication and Google OAuth2 authentication functionalities.
- Clone the repository: Use git clone command to clone the repository to your local machine.
git clone --depth 1 https://github.com/valtervalik/Nestjs-Mongoose-Auth-Template.git my-app
- Enter the project folder and copy .env.example as .env:
cd my-app
cp .env.example .env
- Install dependencies: Run any of the following commands to install all the necessary dependencies.
npm install
yarn install
pnpm install
- Run docker-compose: Use the following command to start the Docker containers.
docker-compose up -d
- Run the application in development mode: Use any of the following commands to start the application in development mode.
npm run start:dev
yarn start:dev
pnpm start:dev