Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mjangir/nestjs-hybrid-auth
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.
https://github.com/mjangir/nestjs-hybrid-auth
hectoberfest hectoberfest2021 nestjs nestjs-auth nestjs-google passport-google passport-twitter passportjs
Last synced: 15 days ago
JSON representation
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.
- Host: GitHub
- URL: https://github.com/mjangir/nestjs-hybrid-auth
- Owner: mjangir
- License: mit
- Created: 2021-09-28T16:22:42.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-02T12:31:42.000Z (7 months ago)
- Last Synced: 2024-10-26T00:55:52.965Z (19 days ago)
- Topics: hectoberfest, hectoberfest2021, nestjs, nestjs-auth, nestjs-google, passport-google, passport-twitter, passportjs
- Language: MDX
- Homepage: https://nestjs-hybrid-auth.manishjangir.com/
- Size: 684 KB
- Stars: 65
- Watchers: 2
- Forks: 12
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# NestJS Hybrid Auth
![npm type definitions](https://img.shields.io/npm/types/typescript)
![npm](https://img.shields.io/npm/v/@nestjs-hybrid-auth/all)
[![compressed size](https://github.com/mjangir/nestjs-hybrid-auth/actions/workflows/size.yml/badge.svg)](https://github.com/mjangir/nestjs-hybrid-auth/actions/workflows/size.yml)
![GitHub](https://img.shields.io/github/license/mjangir/nestjs-hybrid-auth?label=license)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
```bash
npm install @nestjs/passport passport reflect-metadata --save
```OR
```bash
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
```bash
npm install @nestjs-hybrid-auth/all --save
``````bash
yarn add @nestjs-hybrid-auth/all
```### For Individual Identity
```bash
npm install @nestjs-hybrid-auth/google --save
``````bash
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**
```javascript
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**
```javascript
import { HybridAuthModule } from '@nestjs-hybrid-auth/all';@Module({
import: [
HybridAuthModule.forRoot({
google: {
clientID: 'xxxxxxxxxxxx',
clientSecret: 'xxxxxxxxxx',
requestCallbackURL: 'xxxxxxxxx',
},
}),
],
})
class AppModule {}
```### In \*.controller.ts file
```javascript
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)
- [Google](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/google)
- [Facebook](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/facebook)
- [LinkedIn](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/linkedin)
- [Twitter](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/twitter)
- [GitHub](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/github)
- [Instagram](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/instagram)
- [Twitch](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/twitch)
- [Shopify](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/shopify)
- [Okta](https://nestjs-hybrid-auth.manishjangir.com/docs/providers/okta)## Related
- [NestJS](https://nestjs.com)
- [Passport](http://www.passportjs.org)## Maintainers & Contributors
[Manish Jangir](https://github.com/mjangir)
## Credits
[Gopendra Jangir](https://github.com/gopendrajangir) (Banner Image)