All Projects → jajaperson → nestjs-auth0

jajaperson / nestjs-auth0

Licence: MIT License
An example NestJS application that uses Auth0 via Passport for authentication.

Programming Languages

typescript
32286 projects
shell
77523 projects

Projects that are alternatives of or similar to nestjs-auth0

nestjs-auth0
Nestjs + Auth0
Stars: ✭ 80 (-45.95%)
Mutual labels:  auth0, passport, nestjs
nestjs-auth-starter-kit
NestJS Auth Starter Kit (typescript / typeorm / swagger / passport / bcrypt)
Stars: ✭ 37 (-75%)
Mutual labels:  passport, nestjs
nest-js-boilerplate
Nest.js boilerplate
Stars: ✭ 79 (-46.62%)
Mutual labels:  passport, nestjs
Nest Angular
NestJS, Angular 6, Server Side Rendering (Angular Universal), GraphQL, JWT (JSON Web Tokens) and Facebook/Twitter/Google Authentication, Mongoose, MongoDB, Webpack, TypeScript
Stars: ✭ 307 (+107.43%)
Mutual labels:  passport, nestjs
Core Nestjs
A simple application demonstrating the basic usage of permissions with NestJS (JWT, Passport, Facebook, Google+, User, Group, Permission)
Stars: ✭ 347 (+134.46%)
Mutual labels:  passport, nestjs
ng-nest-cnode
Angular 10 Front-End and Nestjs 7 framework Back-End build Fullstack CNode
Stars: ✭ 17 (-88.51%)
Mutual labels:  passport, nestjs
Jianshu
仿简书nx+nodejs+nestjs6+express+mongodb+angular8+爬虫
Stars: ✭ 296 (+100%)
Mutual labels:  passport, nestjs
Passport
Passport module for Nest framework (node.js) 🔑
Stars: ✭ 211 (+42.57%)
Mutual labels:  passport, nestjs
Nest Passport
Nest authentication example using passport strategies
Stars: ✭ 44 (-70.27%)
Mutual labels:  passport, nestjs
nest-auth-example
Nest.js authentication with Passport. Realworld example
Stars: ✭ 186 (+25.68%)
Mutual labels:  passport, nestjs
teanjs
🔥 TypeORM - Express - Angular 8 - NestJS Server Side Rendering (SSR) 😺
Stars: ✭ 62 (-58.11%)
Mutual labels:  passport, nestjs
nestjs-stripe
Provides an injectable Stripe client to nestjs modules
Stars: ✭ 126 (-14.86%)
Mutual labels:  nestjs
QKMRZScanner
Scan MRZ (Machine Readable Zone) from identity documents (passport, id, visa) using iPhone/iPad (iOS)
Stars: ✭ 81 (-45.27%)
Mutual labels:  passport
filimo-plus
FilimoPlus: browse, search, play or download filimo items
Stars: ✭ 23 (-84.46%)
Mutual labels:  nestjs
nestjs-prisma-starter
Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker
Stars: ✭ 1,107 (+647.97%)
Mutual labels:  nestjs
auth0-django-web-app
Auth0 Integration Samples for Django Web Applications
Stars: ✭ 33 (-77.7%)
Mutual labels:  auth0
node-express-mongo-passport-jwt-typescript
A Node.js back end web application with REST API, user JWT authentication and MongoDB data storage using TypeScript
Stars: ✭ 51 (-65.54%)
Mutual labels:  passport
Clean-Laravel-Api
⭐️ Build APIs You Won't Hate In Laravel.
Stars: ✭ 85 (-42.57%)
Mutual labels:  passport
passport-line-auth
Line authentication strategy for Passport and Node.js.
Stars: ✭ 31 (-79.05%)
Mutual labels:  passport
blog3.0
博客V3.0 目前使用的技术(Nuxtjs + Nestjs + Vue + Element ui + vuetify),存储(MongoDB + Redis + COS)
Stars: ✭ 37 (-75%)
Mutual labels:  nestjs

Nest Logo

NestJS + Auth0 = ❤️

Description

A template for using Auth0 with the Nest framework. To start, either fork this repository or run

$ git clone --depth 1 https://github.com/jajaperson/nestjs-auth0.git

Setup

You'll need to populate a .env file with Auth0 configuration environemt details. This file should never be committed for obvious reasons (hence the reason it's .gitignore-d).

AUTH0_DOMAIN={your Auth0 domain}
AUTH0_CLIENT_ID={the Auth0 client ID for your app}
AUTH0_CLIENT_SECRET={the Auth0 client secret for your app}
AUTH0_AUDIENCE={http://localhost:3000 or your production domain accordingly}

A template .env file can be found at .env.example.

You may also like to remove all the irrelevant metadata from the package.json, suck as the repository, homepage, bugs, and description fields.

Installation

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run test:cov

Explanation

Authentication logic

This template nest app uses the jwks-rsa package along with passport-jwt and @nestjs/passport for authentication. All authentication logic is in the /src/auth/ submodule.

src/auth/
├── auth.module.ts
├── interfaces
│   └── jwt-payload.interface.ts
├── jwt.strategy.spec.ts
└── jwt.strategy.ts

The JwtStrategy injectable contains all the core functionality, where the constructor sets up core token validation using the jwks-rsa library. All the Auth0 configuration for this is done in the .env file using @nestjs/config (see above). On any request with authentication, the decoded JSON web token (which should follow JwtPayload) is passed to the validate, which checks the token for the required scopes.

The AuthModule itself exports both PassportModule and the JwtStrategy injectable, and registers JwtStrategy as default.

AuthModule is imported by AppModule, and protected routes are decorated with @UseGuards(AuthGuard()) in AppController.

More info

See the Nest documentation.

License

This project is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].