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

sls-helper-plugin-janis

Package Overview
Dependencies
Maintainers
2
Versions
147
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sls-helper-plugin-janis - npm Package Compare versions

Comparing version 1.3.4 to 2.0.0

5

CHANGELOG.md

@@ -9,2 +9,7 @@ # Changelog

## [2.0.0] - 2020-02-10
### Added
- `authorizers` now have require the Account ID as a configuration option
- Added the `@janiscommerce/serverless-plugin-remove-authorizer-permissions` serverless plugin to allow cross-account deployments
## [1.3.4] - 2020-02-05

@@ -11,0 +16,0 @@ ### Fixed

30

lib/service/authorizers.js
'use strict';
const { inspect } = require('util');
const AUTHORIZERS = {

@@ -47,5 +49,5 @@ FullAuthorizer: [

const authorizerBuilder = (name, headers) => ({
const authorizerBuilder = (name, headers, accountId) => ({
name,
arn: `arn:aws:lambda:us-east-1:026813942644:function:JanisIdService-\${self:custom.stage}-${authorizersNameToFunctionMapping[name] || name}`,
arn: `arn:aws:lambda:us-east-1:${accountId}:function:JanisIdService-\${self:custom.stage}-${authorizersNameToFunctionMapping[name] || name}`,
resultTtlInSeconds: 300,

@@ -56,7 +58,7 @@ identitySource: headers.map(header => `method.request.header.${header}`).join(','),

const buildAuthorizers = () => {
const buildAuthorizers = accountId => {
return Object.entries(AUTHORIZERS).reduce((acum, [authorizer, headers]) => {
return {
...acum,
[authorizer]: authorizerBuilder(authorizer, headers)
[authorizer]: authorizerBuilder(authorizer, headers, accountId)
};

@@ -66,8 +68,14 @@ }, {});

module.exports = ({ custom, ...serviceConfig }) => ({
...serviceConfig,
custom: {
...(custom || {}),
authorizers: buildAuthorizers()
}
});
module.exports = ({ custom, ...serviceConfig }, { accountId }) => {
if(!accountId || typeof accountId !== 'string')
throw new Error(`Missing or invalid accountId in janis.authorizers hook: ${inspect(accountId)}`);
return {
...serviceConfig,
custom: {
...(custom || {}),
authorizers: buildAuthorizers(accountId)
}
};
};

@@ -142,5 +142,6 @@ 'use strict';

'serverless-plugin-reducer',
'serverless-plugin-split-stacks',
'serverless-prune-plugin',
'serverless-plugin-stage-variables'
'serverless-plugin-stage-variables',
'@janiscommerce/serverless-plugin-remove-authorizer-permissions',
'serverless-plugin-split-stacks'
],

@@ -147,0 +148,0 @@ resources: [

{
"name": "sls-helper-plugin-janis",
"version": "1.3.4",
"version": "2.0.0",
"description": "A Serverless Helper plugin to add custom helpers for JANIS Commerce",

@@ -5,0 +5,0 @@ "main": "lib/plugin.js",

@@ -13,4 +13,4 @@ # Serverless Helper Plugin JANIS

|--------|------|-------------|------------|---------------|
| serviceCode | string | The service name in lowercase dash separated | **Required** | |
| servicePort | number | The service port | **Required** | |
| serviceCode | string | The service name in lowercase dash separated | **Required** | |
| servicePort | number | The service port | **Required** | |
| apiSecrets | Object | A mapping of stages to Service API Secret | | `undefined` |

@@ -28,3 +28,5 @@

_No options_
| Option | Type | Description | Attributes | Default value |
|--------|------|-------------|------------|---------------|
| accountId | string | Indicates the AWS account ID where the authorizers are deployed | **Required** | |

@@ -139,3 +141,5 @@ ### cors

'janis.authorizers',
['janis.authorizers', {
accountId: '012345678910'
}],

@@ -142,0 +146,0 @@ 'janis.cors',

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