sls-helper-plugin-janis
Advanced tools
Comparing version 1.3.4 to 2.0.0
@@ -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 |
'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', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
33119
768
184
0