Skip to content

Commit

Permalink
check for http event with private: true
Browse files Browse the repository at this point in the history
fixes #832
  • Loading branch information
christophgysin authored and dnalborczyk committed Nov 30, 2019
1 parent 879b38b commit 0894fce
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/ServerlessOffline.js
Expand Up @@ -357,7 +357,7 @@ module.exports = class ServerlessOffline {
_setupEvents() {
let serviceRuntime = this.service.provider.runtime;
const defaultContentType = 'application/json';
const { apiKeys } = this.service.provider;
const { functions } = this.service.provider;
const protectedRoutes = [];

if (!serviceRuntime) {
Expand Down Expand Up @@ -396,8 +396,15 @@ module.exports = class ServerlessOffline {
return;
}

const hasPrivateHttpEvent = Object.values(functions || [])
.some(func => (func.events || [])
.filter(e => e.http)
.map(e => e.http)
.some(e => e.private)
);

// for simple API Key authentication model
if (apiKeys) {
if (hasPrivateHttpEvent) {
this.serverlessLog(`Key with token: ${this.options.apiKey}`);

if (this.options.noAuth) {
Expand Down

0 comments on commit 0894fce

Please sign in to comment.