Skip to content

Commit

Permalink
Add support for local custom authorizers
Browse files Browse the repository at this point in the history
BuiltinAuthorizer will now work in local mode. Authorizer types that
cannot be run locally will now simply allow the requests to proceed as
if there were no authorizer to allow for local testing.
  • Loading branch information
stealthycoin committed Aug 28, 2017
1 parent 3c75891 commit e006290
Show file tree
Hide file tree
Showing 7 changed files with 1,028 additions and 170 deletions.
5 changes: 2 additions & 3 deletions chalice/app.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Dict, List, Any, Callable, Union, Optional
from chalice.local import LambdaContext

__version__ = ... # type: str

Expand Down Expand Up @@ -109,9 +110,7 @@ class Chalice(object):
api = ... # type: APIGateway
routes = ... # type: Dict[str, Dict[str, RouteEntry]]
current_request = ... # type: Request
# TODO: Change lambda_context to a real type once we have one for local
# API Gateway
lambda_context = ... # type: Any
lambda_context = ... # type: LambdaContext
debug = ... # type: bool
authorizers = ... # type: Dict[str, Dict[str, Any]]
builtin_auth_handlers = ... # type: List[BuiltinAuthConfig]
Expand Down
2 changes: 1 addition & 1 deletion chalice/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def run_local_server(factory, port, env):
# The app-specific logger (app.log) will still continue
# to work.
logging.basicConfig(stream=sys.stdout)
server = factory.create_local_server(app_obj, port)
server = factory.create_local_server(app_obj, config, port)
server.serve_forever()


Expand Down
6 changes: 3 additions & 3 deletions chalice/cli/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,6 @@ def load_project_config(self):
with open(config_file) as f:
return json.loads(f.read())

def create_local_server(self, app_obj, port):
# type: (Chalice, int) -> local.LocalDevServer
return local.create_local_server(app_obj, port)
def create_local_server(self, app_obj, config, port):
# type: (Chalice, Config, int) -> local.LocalDevServer
return local.create_local_server(app_obj, config, port)
Loading

0 comments on commit e006290

Please sign in to comment.