Skip to content

erwinknoop/nest-jwt-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

npm npm

Nest JWT authentication

This package is meant to simplify adding JWT authentication to your Nest application. The package exposes a module which mounts an authentication endpoint at the /auth/token url.

Usage

Using this module is really simple, all you need to do is create a user implements the provided User and create a service that implements the provided UsersService and register the module in your application.

The recommended way to register the module is to inject your own UsersService implementation by using registerAsync but the module is flexible enough to support other solutions as long as the interface is implemented.

AuthModule.registerAsync({
  imports: [UsersModule],
  inject: [UsersService],
  useFactory: async (usersService: UsersService) => ({
    secretOrPrivateKey: "secretOrPrivateKey",
    usersService,
  }),
}),

Besides the users service it is possible to pass arguments for handling JWT, these arguments are the same as the arguments that you would use to register the JwtModule if you would implement JWT yourself.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published