Gathering detailed insights and metrics for @jhonpedro/serverless-offline-local-authorizers-plugin
Gathering detailed insights and metrics for @jhonpedro/serverless-offline-local-authorizers-plugin
Gathering detailed insights and metrics for @jhonpedro/serverless-offline-local-authorizers-plugin
Gathering detailed insights and metrics for @jhonpedro/serverless-offline-local-authorizers-plugin
Plugin for adding local authorizers when developing locally with serverless-offline
npm install @jhonpedro/serverless-offline-local-authorizers-plugin
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
16 Stars
48 Commits
22 Forks
3 Branches
4 Contributors
Updated on Dec 08, 2023
Latest Version
1.0.0
Package Id
@jhonpedro/serverless-offline-local-authorizers-plugin@1.0.0
Unpacked Size
14.70 kB
Size
5.18 kB
File Count
9
NPM Version
8.5.0
Node Version
14.19.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
Serverless plugin for adding authorizers when developing and testing functions locally with serverless-offline.
This plugin allows you to add local authorizer functions to your serverless projects. These authorizers
are added dynamically in a way they can be called by serverless-offline
but don't interfer with your
deployment and your shared authorizer functions. This helps when you have shared API Gateway authorizers
and developing and testing locally with serverless-offline
.
:warning: If you are using this plugin and get schema validation errors: Please check indentation of
localAuthorizer:
config property! See example below...
Installing using npm:
npm i serverless-offline-local-authorizers-plugin --save-dev
Step 1: Define your authorizer functions in a file called local-authorizers.js
and put it into your
project root (that's where your serverless.yml
lives).
If you want the local function to call your deployed shared authorizer it could look something like this:
1const AWS = require("aws-sdk"); 2const mylocalAuthProxyFn = async (event, context) => { 3 4 const lambda = new AWS.Lambda(); 5 const result = await lambda.invoke({ 6 FunctionName: "my-shared-lambda-authorizer", 7 InvocationType: "RequestResponse", 8 Payload: JSON.stringify(event), 9 }).promise(); 10 11 if (result.StatusCode === 200) { 12 return JSON.parse(result.Payload); 13 } 14 15 throw Error("Authorizer error"); 16}; 17 18module.exports = { mylocalAuthProxyFn }; 19
Of course you could also just return a mocked response, call Cognito to mock your Cognito Authorizer or whatever suits your needs. You can also define multiple authorizer functions if you need to.
Step 2: In your serverless.yml
, add the localAuthorizer
property to your http events. This will not interfere
with your "real" authorizers and will be ignored upon deployment.
1functions: 2 myFunction: 3 handler: myFunction.handler 4 events: 5 - http: 6 path: /my/api/path 7 method: GET 8 authorizer: 9 type: CUSTOM 10 authorizerId: abcjfk 11 localAuthorizer: 12 name: "mylocalAuthProxyFn" 13 type: "request" 14
Step 3: Add the plugin to the plugins sections in serverless.yml
:
1plugins: 2 - serverless-offline-local-authorizers-plugin 3 - serverless-offline
Step 4: Fire up serverless offline with the local-authorizers
option:
1$ sls offline local-authorizers --stage dev --region eu-central-1
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/10 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
27 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More