Registry / devops / serverless-offline-local-auth-plugin

serverless-offline-local-auth-plugin

JSON →
library1.2.9jsnpmunverified

A Serverless Framework plugin that adds local authorizer support for serverless-offline development. Version 1.2.9 helps developers test Lambda authorizers locally without deploying shared API Gateway authorizers. It allows defining custom authorizer functions in a local file that get called by serverless-offline instead of the real authorizer. The plugin supports explicit authorizer handlers or auto-proxied generation. It's a fork of serverless-offline-auth-plugin with fixes. Active maintenance, no major updates since initial release.

npm install serverless-offline-local-auth-plugin
INSTALL
IMPORT
SIG · SERVERLESS-OFFLINE
S
serverless-offline-local-auth-plugin
devopsjavascriptv1.2.9
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

serverless-offline-local-auth-plugin
plugins: - serverless-offline-local-auth-plugin
plugins: - serverless-offline - serverless-offline-local-auth-plugin
Plugin must be listed before serverless-offline in the plugins array so it can register its hooks properly.
localAuthorizer
localAuthorizer: name: myAuthorizerFn type: request
localAuthorizer: name: myAuthorizerFn type: REQUEST
type value is case-sensitive; must be lowercase 'request' or 'token'.
LocalAuthProxyFn
const { myProxyFn } = require('./local-authorizers');
import { myProxyFn } from './local-authorizers'
The required file is CommonJS (JavaScript); ESM import will fail if not configured for ESM.

Creates a local-authorizers.js file with a proxy function that invokes the real Lambda authorizer for local testing.

// file: local-authorizers.js const AWS = require('aws-sdk'); module.exports = { myLocalAuth: async (event, context) => { // Proxy to real authorizer or return mock const lambda = new AWS.Lambda(); const result = await lambda.invoke({ FunctionName: 'my-shared-authorizer', InvocationType: 'RequestResponse', Payload: JSON.stringify(event), }).promise(); if (result.StatusCode === 200) { return JSON.parse(result.Payload); } throw new Error('Authorizer error'); }, };
Debug
Known issues
gotchaPlugin order matters: serverless-offline-local-auth-plugin must be listed before serverless-offline in serverless.yml plugins array.
fix
Place serverless-offline-local-auth-plugin above serverless-offline in the plugins list.
affects: >=1.0.0
breakingThe local-authorizers.js filename is hardcoded. If you rename or place it elsewhere, the plugin cannot find it.
fix
Create local-authorizers.js in the same directory as serverless.yml.
affects: >=1.0.0
deprecatedOriginal plugin was deprecated; this fork may not receive further updates.
fix
Consider migrating to a more actively maintained solution if issues arise.
affects: >=1.0.0
Errors
Common errors & fixes
Schema validation error: localAuthorizer is not allowed
Misindented localAuthorizer property under the http event.
fix
Ensure localAuthorizer is indented at the same level as authorizer under the http event.
Cannot find module './local-authorizers'
Missing local-authorizers.js file or wrong path.
fix
Create local-authorizers.js in the project root (same directory as serverless.yml).
TypeError: myLocalAuth is not a function
The exported function name in local-authorizers.js does not match the name property in localAuthorizer.
fix
Ensure module.exports contains a function with the exact name specified in localAuthorizer.name.
Upgrade
Version history
1.2.9latest on npm
Audit
Dependencies
serverlessrequiredPeer dependency required for Serverless Framework plugin
serverless-offlinerequiredPeer dependency; plugin hooks into serverless-offline lifecycle
Agent activity
4 hits · last 30 days
node
4
Resources
serverless-offline-local-auth-plugin — npm install serverless-offline-local-auth-plugin · libregistry