Skip to content

Commit 3cf6449

Browse files
committed
fix(AWS ALB): Ensure to log deprecation at initialization stage
1 parent 8b914e5 commit 3cf6449

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/plugins/aws/package/compile/events/alb/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const BbPromise = require('bluebird');
4+
const _ = require('lodash');
45

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

3132
// TODO: Complete schema, see https://github.com/serverless/serverless/issues/8020
3233
this.serverless.configSchemaHandler.defineFunctionEvent('aws', 'alb', { type: 'object' });
34+
35+
if (
36+
this.serverless.service.provider.name === 'aws' &&
37+
_.values(_.get(this.serverless.service.provider.alb, 'authorizers') || {}).some(
38+
({ allowUnauthenticated }) => allowUnauthenticated != null
39+
)
40+
) {
41+
this.serverless._logDeprecation(
42+
'AWS_ALB_ALLOW_UNAUTHENTICATED',
43+
'allowUnauthenticated is deprecated, use onUnauthenticatedRequest instead'
44+
);
45+
}
3346
}
3447
}
3548

lib/plugins/aws/package/compile/events/alb/lib/validate.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,6 @@ module.exports = {
209209
const hasAllowUnauthenticated = auth.allowUnauthenticated != null;
210210
const hasOnUnauthenticatedRequest = auth.onUnauthenticatedRequest != null;
211211

212-
if (hasAllowUnauthenticated) {
213-
this.serverless._logDeprecation(
214-
'AWS_ALB_ALLOW_UNAUTHENTICATED',
215-
'allowUnauthenticated is deprecated, use onUnauthenticatedRequest instead'
216-
);
217-
}
218-
219212
if (hasAllowUnauthenticated && !hasOnUnauthenticatedRequest) {
220213
auth.onUnauthenticatedRequest = auth.allowUnauthenticated ? 'allow' : 'deny';
221214
} else {

0 commit comments

Comments
 (0)