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

@life-without-barriers/lambda-authentication

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@life-without-barriers/lambda-authentication

Custom lamdba authorizer for AWS API Gateway/Serverless

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

lambda-authentication

volkswagen status

JWT auth for API Gateway custom authorizers & Serverless

Uses HMACSHA256 with a shared secret. If you are using tokens signed using RSA, v1 might give you some ideas. Uses a cookie to roundtrip the JWT, so make sure you consider CSRF protection on your api endpoints.

requirements

This package is intended to run on node v6.10.x (the latest version of node available to lambda at the time)

usage

First, export the authorizer with the correct path:

const authorizer = require('@life-without-barriers/lambda-authentication').authorizer

exports.myAuthorizer = authorizer({
  path: '/my-cool-site', // The path to your API
  logger: bunyan.createLogger({ name: 'my-app' }), // Accepts any bunyan logger. optional
  audience: 'abc123', // The audience
  issuer: 'my-openid-org', // the issuer
  cookieName: 'foo', // the name of the cookie that contains the JWT
  secret: 'secret key for HMAC signing'
})

Then, expose the lambda in your serverless.yml and delegate authorization to it:

functions:
  myAuthorizer:
    handler: app.myAuthorizer
  app:
    handler: app.myApp
    events:
      - http:
          path: /my-cool-site
          method: get
          cors: true
          authorizer:
            name: myAuthorizer
            identitySource: method.request.header.Cookie # IMPORTANT! use cookie auth

Keywords

FAQs

Package last updated on 22 May 2017

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