Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@amsame/kinde-auth-nestjs

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amsame/kinde-auth-nestjs

Kinde Auth module for NestJS framework

  • 1.0.14
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
39
increased by39.29%
Maintainers
1
Weekly downloads
 
Created
Source

Nest Logo

Kinde Auth NestJs

A NestJs Module to validate your Kinde JSON Web Tokens

node-current MIT License npm version

Usage

If you are using a mobile or front-end Kinde SDK and want to protect your NestJs back-end APIs, this Module is relevant for you.

  • Install the module

npm i @amsame/kinde-auth-nestjs
  • Set the environments

    kinde supports multi-domain authentication where the primary domain is the same, but there are different NestJs services running in different subdomains. For example. service1.yourdomain.com, service2.yourdomain.com, so make sure to set this environment in your kinde SDK
KINDE_COOKIE_DOMAIN=.yourdomain.com

To run this module, you will need to add the following environment variables to your NestJs .env file

KINDE_DOMAIN=https://<your-subdomain>.kinde.com
KINDE_AUDIENCE=https://<your-audience>

make sure you set the audience in your kinde SDK, see here

  • Load the module

import { Module } from '@nestjs/common';
import { KindeModule } from '@amsame/kinde-auth-nestjs';

@Module({
  imports: [..., ..., KindeModule],
  controllers: [...],
  providers: [...],
})
export class AppModule {}
  • Protect your endpoints

import { Controller, Get } from '@nestjs/common';
import { KindeIsAuth } from '@amsame/kinde-auth-nestjs';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @KindeIsAuth()
  hello() {
      ...
  }
}
import { Controller, Get } from '@nestjs/common';
import { KindeRoles } from '@amsame/kinde-auth-nestjs';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @KindeRoles(['admin'])
  hello() {
      ...
  }
}
import { Controller, Get } from '@nestjs/common';
import { KindePermissions } from '@amsame/kinde-auth-nestjs';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @KindePermissions(['...', '...'])
  hello() {
      ...
  }
}
  • Get user details

import { Controller, Get } from '@nestjs/common';
import { IKindeUser, KindeIsAuth, KindeUser } from '@amsame/kinde-auth-nestjs';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  @KindeIsAuth()
  hello(@KindeUser() user: IKindeUser) {
      ...
  }
}

License

MIT

Keywords

FAQs

Package last updated on 11 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc