# nestjs-auth0

> nestjs-auth0

Latest version **1.3.1** (published 2022-04-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install nestjs-auth0
pnpm add nestjs-auth0
yarn add nestjs-auth0
bun add nestjs-auth0
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.1 |
| Published | 2022-04-10 |
| First published | 2022-04-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 98.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | hoangnguyen1247 |
| Keywords | nestjs, auth0 authentication client |

## Links

- npm: https://www.npmjs.com/package/nestjs-auth0
- Repository: https://github.com/hoangnguyen1247/nestjs-auth0
- Homepage: https://github.com/hoangnguyen1247/nestjs-auth0#readme
- Issues: https://github.com/hoangnguyen1247/nestjs-auth0/issues
- npm.io page: https://npm.io/package/nestjs-auth0

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.3.1 (latest) — 2022-04-10
- 1.0.0-develop.10 (develop) — 2022-04-10
- 1.3.0 — 2022-04-10
- 1.0.0-develop.9 — 2022-04-10
- 1.2.0 — 2022-04-09
- 1.0.0-develop.8 — 2022-04-09
- 1.1.0 — 2022-04-09
- 1.0.0-develop.7 — 2022-04-09
- 1.0.0-develop.6 — 2022-04-09
- 1.0.0-develop.5 — 2022-04-09
- 1.0.0-develop.4 — 2022-04-09
- 1.0.0-develop.3 — 2022-04-09

## README

<p align="center">
  <h3 align="center">
    nestjs-auth0
  </h3>

  <p align="center">
    Injectable Auth0 Authentication client for your nestjs projects
  </p>
  <p align="center">
    Using Auth0 Management, please see <a href="https://github.com/hoangnguyen1247/nestjs-auth0-management">nestjs-auth0-management</a>
  </p>

</p>

## Table Of Contents

- [Table Of Contents](#table-of-contents)
- [About](#about)
- [Installation](#installation)
- [Getting Started](#getting-started)
- [Example](#example)
- [Contributing](#contributing)
- [License](#license)
- [Acknowledgements](#acknowledgements)

## About

`nestjs-auth0` implements a module, `Auth0AuthenticationModule`, which when imported into
your nestjs project provides a Auth0 AuthenticationClient to any class that injects it. This
lets Auth0 be worked into your dependency injection workflow without having to
do any extra work outside of the initial setup.

## Installation

```bash
npm install --save auth0 nestjs-auth0
```

## Getting Started

The simplest way to use `nestjs-auth0` is to use `Auth0AuthenticationModule.forRoot`

```typescript
import { Module } from '@nestjs-common';
import { Auth0AuthenticationModule } from 'nestjs-auth0';

@Module({
  imports: [
    Auth0AuthenticationModule.forRoot({
      domain: '',
      clientId: '',
      clientSecret: '',
    }),
  ],
})
export class AppModule {}
```

You can then inject the Auth0 AuthenticationClient into any of your injectables by using a
custom decorator

```typescript
import { Injectable } from '@nestjs/common';
import { InjectAuthenticationClient } from 'nestjs-auth0';
import { AuthenticationClient } from 'auth0';

@Injectable()
export class AppService {
  public constructor(@InjectAuthenticationClient() private readonly authenticationClient: AuthenticationClient) {}
}
```

Asynchronous setup is also supported

```typescript
import { Module } from '@nestjs-common';
import { Auth0AuthenticationModule } from 'nestjs-auth0';

@Module({
  imports: [
    Auth0AuthenticationModule.forRootAsync({
      inject: [ConfigService],
      useFactory: (configService: ConfigService) => ({
        domain: configService.get('auth0_domain'),
        clientId: configService.get('auth0_client_id'),
        clientSecret: configService.get('auth0_client_secret'),
      }),
    }),
  ],
})
export class AppModule {}
```

## Example

In order to run the example run the following commands in your terminal. The
expected output of the example is to show that the Auth0 AuthenticationClient was
successfully injected into the `AppService`.

```bash
cd example
npm install
npm run start
```

## Contributing

I would greatly appreciate any contributions to make this project better. Please
make sure to follow the below guidelines before getting your hands dirty.

1. Fork the repository
2. Create your branch (`git checkout -b my-branch`)
3. Commit any changes to your branch
4. Push your changes to your remote branch
5. Open a pull request

## License

Distributed under the MIT License. See `LICENSE` for more information.

## Acknowledgements

- [nestjs](https://nestjs.com)
- [node-auth0](https://github.com/auth0/node-auth0)

Copyright &copy; 2022 Hoàng Nguyễn

---
_Source: https://npm.io/package/nestjs-auth0 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
