Authentication

The act of identifying oneself to the system.

Now we can delve into the core of this module. To have authentication, we'll use the Passport library. Nest offers integration with it, which eases our lives. The Local strategy will be used for the user to log in with credentials, and the JWT strategy, for him to identify himself to the routes after the previous step. Don't worry, everything will become clearer as the module progresses.

The first step is to install all the necessary dependencies.

yarn add @nestjs/passport passport passport-local @nestjs/jwt passport-jwt
yarn add -D @types/passport-local @types/passport-jwt

Then, let's begin by allowing the user to log in.

Last updated