Skip to content

Commit

Permalink
Merge pull request #294 from ColRad/master
Browse files Browse the repository at this point in the history
Added --noAuth CLI option to disable Authorizer
  • Loading branch information
dherault authored Sep 18, 2017
2 parents 1fe35d4 + 0d3caa9 commit d1f168c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ All CLI options are optional:
--corsAllowHeaders Used as default Access-Control-Allow-Headers header value for responses. Delimit multiple values with commas. Default: 'accept,content-type,x-api-key'
--corsDisallowCredentials When provided, the default Access-Control-Allow-Credentials header value will be passed as 'false'. Default: true
--exec "<script>" When provided, a shell script is executed when the server starts up, and the server will shut domn after handling this command.
--noAuth Turns off all authorizers
```

Any of the CLI options can be added to your `serverless.yml`. For example:
Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ class Offline {
exec: {
usage: 'When provided, a shell script is executed when the server starts up, and the server will shut domn after handling this command.',
},
noAuth: {
usage: 'Turns off all authorizers',
}
},
},
};
Expand Down Expand Up @@ -220,6 +223,7 @@ class Offline {
dontPrintOutput: false,
httpsProtocol: '',
skipCacheInvalidation: false,
noAuth: false,
corsAllowOrigin: '*',
corsAllowHeaders: 'accept,content-type,x-api-key',
corsAllowCredentials: true,
Expand Down Expand Up @@ -371,7 +375,7 @@ class Offline {
this.serverlessLog(`${method} ${fullPath}`);

// If the endpoint has an authorization function, create an authStrategy for the route
const authStrategyName = this._configureAuthorization(endpoint, funName, method, epath, servicePath);
const authStrategyName = this.options.noAuth ? null : this._configureAuthorization(endpoint, funName, method, epath, servicePath);

let cors = null;
if (endpoint.cors) {
Expand Down

0 comments on commit d1f168c

Please sign in to comment.