Skip to content

Commit

Permalink
fix(AWS ALB): Ensure to log deprecation at initialization stage
Browse files Browse the repository at this point in the history
  • Loading branch information
medikoo committed Nov 3, 2020
1 parent 8b914e5 commit 3cf6449
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
13 changes: 13 additions & 0 deletions lib/plugins/aws/package/compile/events/alb/index.js
@@ -1,6 +1,7 @@
'use strict';

const BbPromise = require('bluebird');
const _ = require('lodash');

const validate = require('./lib/validate');
const compileTargetGroups = require('./lib/targetGroups');
Expand Down Expand Up @@ -30,6 +31,18 @@ class AwsCompileAlbEvents {

// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8020
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'alb', { type: 'object' });

if (
this.serverless.service.provider.name === 'aws' &&
_.values(_.get(this.serverless.service.provider.alb, 'authorizers') || {}).some(
({ allowUnauthenticated }) => allowUnauthenticated != null
)
) {
this.serverless._logDeprecation(
'AWS_ALB_ALLOW_UNAUTHENTICATED',
'allowUnauthenticated is deprecated, use onUnauthenticatedRequest instead'
);
}
}
}

Expand Down
7 changes: 0 additions & 7 deletions lib/plugins/aws/package/compile/events/alb/lib/validate.js
Expand Up @@ -209,13 +209,6 @@ module.exports = {
const hasAllowUnauthenticated = auth.allowUnauthenticated != null;
const hasOnUnauthenticatedRequest = auth.onUnauthenticatedRequest != null;

if (hasAllowUnauthenticated) {
this.serverless._logDeprecation(
'AWS_ALB_ALLOW_UNAUTHENTICATED',
'allowUnauthenticated is deprecated, use onUnauthenticatedRequest instead'
);
}

if (hasAllowUnauthenticated && !hasOnUnauthenticatedRequest) {
auth.onUnauthenticatedRequest = auth.allowUnauthenticated ? 'allow' : 'deny';
} else {
Expand Down

0 comments on commit 3cf6449

Please sign in to comment.