All Projects → mjangir → nestjs-hybrid-auth

mjangir / nestjs-hybrid-auth

Licence: MIT license
Open source social sign in NestJS. NestJS HybridAuth works with various identities providers such as Facebook, Twitter, Google and many more. It use passport authentication under the hood.

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects
shell
77523 projects

Projects that are alternatives of or similar to nestjs-hybrid-auth

nestjs-prisma-starter
Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker
Stars: ✭ 1,107 (+2975%)
Mutual labels:  passportjs, nestjs
react-node-twitter-login
Demo application that shows how to enable Twitter login with React on frontend and Node.js/Express on backend
Stars: ✭ 34 (-5.56%)
Mutual labels:  passportjs, passport-twitter
Nestjs Email Authentication
Nestjs Starter using Mongodb and Passportjs
Stars: ✭ 222 (+516.67%)
Mutual labels:  passportjs, nestjs
Nestjs-Typeorm-Auth
NestJS + Typeorm codebase containing a full authentification system with roles, sessions and email verification.
Stars: ✭ 37 (+2.78%)
Mutual labels:  passportjs, nestjs
Nestjs Prisma Starter
Starter template for NestJS 😻 includes GraphQL with Prisma Client, Passport-JWT authentication, Swagger Api and Docker
Stars: ✭ 547 (+1419.44%)
Mutual labels:  passportjs, nestjs
Nest User Auth
A starter build for a back end which implements managing users with MongoDB, Mongoose, NestJS, Passport-JWT, and GraphQL.
Stars: ✭ 145 (+302.78%)
Mutual labels:  passportjs, nestjs
chanyeong
👨‍💻 chanyeong's portfolio and blog webpage
Stars: ✭ 39 (+8.33%)
Mutual labels:  passportjs, nestjs
ExpressJS-SocketIO-Boilerplate
📦 Simple Express.js & Socket.io Boilerplate
Stars: ✭ 31 (-13.89%)
Mutual labels:  passportjs
next-api-decorators
Collection of decorators to create typed Next.js API routes, with easy request validation and transformation.
Stars: ✭ 187 (+419.44%)
Mutual labels:  nestjs
nest-sendgrid
No description or website provided.
Stars: ✭ 24 (-33.33%)
Mutual labels:  nestjs
renestql
React, NestJS & GraphQL monorepo boilerplate managed with nx
Stars: ✭ 25 (-30.56%)
Mutual labels:  nestjs
nest-todo
🐱 使用 React.js + Nest.js 实现一个简单的 Todo App。
Stars: ✭ 205 (+469.44%)
Mutual labels:  nestjs
necord
🤖 A module for creating Discord bots using NestJS, based on Discord.js
Stars: ✭ 77 (+113.89%)
Mutual labels:  nestjs
mini-express-boilerplate
A minimal Express boilerplate with passport user authentication, mongoose and some security setup configured
Stars: ✭ 15 (-58.33%)
Mutual labels:  passportjs
azure-storage
Azure Storage module for Nest framework (node.js) ☁️
Stars: ✭ 71 (+97.22%)
Mutual labels:  nestjs
nest-bull
No description or website provided.
Stars: ✭ 22 (-38.89%)
Mutual labels:  nestjs
Expenses
Keep track of your expenses the smart way 💰
Stars: ✭ 15 (-58.33%)
Mutual labels:  passportjs
event-emitter
Event Emitter module for Nest framework (node.js) 🦋
Stars: ✭ 102 (+183.33%)
Mutual labels:  nestjs
aws-nestjs-starter
Serverless, AWS, NestJS, GraphQL and DynamoDB starter
Stars: ✭ 200 (+455.56%)
Mutual labels:  nestjs
nestjs-asyncapi
Async API module for Nestjs that provides documentation generation using your existing code (similar to Nestjs swagger module)
Stars: ✭ 22 (-38.89%)
Mutual labels:  nestjs

NestJS Hybrid Auth

NestJS Hybrid Auth

npm type definitions npm compressed size GitHub

NestJS hybrid auth is a dynamic nestjs module or assembling of individual modules written over passport authentication library which enables you to integrate social login in your nestjs application for various identity providers such as Facebook, Google, Instagram and many more.

Please visit https://nestjs-hybrid-auth.manishjangir.com for complete documentation

Prerequisites

The library requires you to install few peer dependencies

npm install @nestjs/passport passport reflect-metadata --save

OR

yarn add @nestjs/passport passport reflect-metadata

Install Hybrid Auth

You can install the library for all providers or install it separately for each identity provider.

For All Providers

npm install @nestjs-hybrid-auth/all --save
yarn add @nestjs-hybrid-auth/all

For Individual Identity

npm install @nestjs-hybrid-auth/google --save
yarn add @nestjs-hybrid-auth/google

How To Use?

Every individual package or the global all-in-one hybrid auth package exports a dynamic nestjs module and nest Guard (controller method decorator) which sets up the login and callback workflow.

Note: This is just a usage snippet. Please read the actual documentation of an identity provider for its peer dependencies.

In *.module.ts file

If you are using individual package

import { GoogleAuthModule } from '@nestjs-hybrid-auth/google';

@Module({
  import: [
    GoogleAuthModule.forRoot({
      clientID: 'xxxxxxxxxxxx',
      clientSecret: 'xxxxxxxxxx',
      requestCallbackURL: 'xxxxxxxxx',
    }),
  ],
})
class AppModule {}

Or if you are using all-in-one package

import { HybridAuthModule } from '@nestjs-hybrid-auth/all';

@Module({
  import: [
    HybridAuthModule.forRoot({
      google: {
        clientID: 'xxxxxxxxxxxx',
        clientSecret: 'xxxxxxxxxx',
        requestCallbackURL: 'xxxxxxxxx',
      },
    }),
  ],
})
class AppModule {}

In *.controller.ts file

import { UseGoogleAuth } from '@nestjs-hybrid-auth/google';
// OR
import { UseGoogleAuth } from '@nestjs-hybrid-auth/all';

@Controller
class AuthController {
  @UseGoogleAuth()
  @Get('auth/google')
  googleLogin() {}

  @UseGoogleAuth()
  @Get('auth/google-callback') // This is the route configured in your Google oauth app
  googleLoginCallback(req: Request) {
    console.log(req.hybridAuthResult.user | accessToken | refreshToken);
  }
}

Note:

  1. As passport uses express under the hood, fastify applications may not work with this package.
  2. Please read the full documentation for an identity provider before using it because some providers may require few additional dependencies to be installed to work properly.

Supported Identity Providers (Many more are yet to come)

Related

Maintainers & Contributors

Manish Jangir

Credits

Gopendra Jangir (Banner Image)

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].