- Passport is a library for authentication in Nodejs.
- Passport recognizes Strategy to validate a given information.
- After the successful authentication, Passport attaches the additional user information to the request.
- Passport-local is a strategy of Passport and it uses { username, password } to authenticate the users.
- By default, variable names must be same to be readable by PassportStrategy.
- If you want to modify the above fields, use the options { usernameField, passwordField }.
Database is needed to maintain the user information for authentication.
$ npm install --save @nestjs/passport passport passport-local
$ npm install --save-dev @types/passport-local
$ npm install --save @nestjs/jwt
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
Follow below link after running to understand codes in Swagger playground.
[1] Base Repository