Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
lambda-custom-authorizer-middleware
Advanced tools
Adds support of custom lambda authorizers for local offline usage, e.g. with serverless-offlin
Lambda Custom Authorizer Middleware for using with AWS Serverless Express and Serverless Offline plugins
Let's say you are using aws-serverless-express. Cool, you can write lambdas responding to API Gateway using favorite express.
Let's say you are using serverless-offline to simulate API Gateway for local development. Cool, now you can invoke your lambdas locally.
Let's say you have custom lambda authorizers defined in your serverless.yml
file like that:
restAP:
handler: lib/handlers/rest-api.handler
events:
- http:
path: v1/{id}/create
method: put
integration: lambda-proxy
authorizer:
arn: arn:aws:lambda:us-east-1:123456789:function:myAuthorizerFunction
resultTtlInSeconds: 0
Pretty soon you find this issue saying you cannot use custom non-local authorizers.
And here it comes. With this package you can provide path on local file system to your custom authorizer function which isn't required to be inside the project.
Note, it's installed not in dev deps.
$ yarn add lambda-custom-authorizer-middleware
Due to the fact this package is meant to be used with serverless-offline
it relies on its environment variable IS_OFFLINE
to switch on using local Lambda function.
And as for now, it's limited to 1 kind of authorizer function per project.
Express middleware function constructor to execute local lambda function
as a custom authorizer and attach request context to req
object
as req.apiGateway.event.requestContext.authorizer
(as for usage with aws-serverless-exporess
npm package)
Parameters
options
Object Configuration object (optional, default {}
)
Examples
import express from 'express';
import awsSlsExpressMiddleware from 'aws-serverless-express/middleware';
import {customLocalLambdaAuthorizer} from 'lambda-custom-authorizer-middleware';
const app = express();
app.use(awsSlsExpressMiddleware.eventContext());
app.use(customLocalLambdaAuthorizer({ // Make sure to add after 'awsSlsExpressMiddleware'
localAuthorizer: {
handlerPath: '../../../../other-project/lambda/auth', // NOTE: path is relative to the package inside node_modules/
handlerName: 'handler'
}
}));
app.get('/', (req, res) => res.json(req.apiGateway.event.requestContext.authorizer));
Returns Function Express middleware function. Works only when IS_OFFLINE env var is set.
This package uses debug library, so set environment variable like that to see the logs.
DEBUG=lambda-custom-authorizer-middleware sls offline start
$ yarn lint
$ yarn build
$ yarn docs
$ yarn test
$ yarn coverage
FAQs
Adds support of custom lambda authorizers for local offline usage, e.g. with serverless-offlin
The npm package lambda-custom-authorizer-middleware receives a total of 3 weekly downloads. As such, lambda-custom-authorizer-middleware popularity was classified as not popular.
We found that lambda-custom-authorizer-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.