New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@edirect/auth

Package Overview
Dependencies
Maintainers
22
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edirect/auth

Authorization Module

  • 2.0.5
  • npm
  • Socket score

Version published
Weekly downloads
155
increased by66.67%
Maintainers
22
Weekly downloads
 
Created
Source

@edirect/auth

The EDirectInsure Authentication module.

Installation

$ npm i --save @edirect/auth

Usage

Import and register AuthModule on AppModule (app.module.ts):

imports: [

  AuthModule.register({
    jwksUrl: "https://url.to.jkws.com",
    tokenUrl: "https://url.to.token.com"
  }),

  OR

  AuthModule.registerAsync({
    imports: [ConfigModule],
    useFactory: async (configService: ConfigService) => ({
      jwksUrl: configService.get<string>(Variables.AUTH_SERVICE_JWKS),
      tokenUrl: configService.get<string>(Variables.AUTH_SERVICE_TOKEN),
    }),
    inject: [ConfigService],
  }),

  ...
]

Use the exported decorators to secure paths:

// Adds Bearer Token validation and, optionally, User Roles and Permissions validation.
// Loads the user information into the context, if valid.
@Auth({ roles: [RolesEnum.ROLE_ADMIN], permissions: [PermissionsEnum.ENTITY_CREATE] })

// Adds only Roles or Permissions validation. Use after @Token() decorator.
// For example, use the @Token() decorator at the controller level and the @Roles() or @Permission()
// decorator at the operatopn level.
@Roles([RolesEnum.ROLE_ADMIN])
@Permissions([PermissionsEnum.ENTITY_CREATE])

// Adds only Bearer Token validation. Loads the user information into the context, if valid.
@Token()

You can access the user information after authentication using the @Usr() decorator:

@Get('/:id')
@Token()
async findOne(@Param('sid') sid: string, @Usr() userInfo: UserInfo): Promise<GetEventReportDto> {}

FAQs

Package last updated on 08 Oct 2021

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