Authorizer handler incorrect
- Dominant language
- Python
- Stars
- 11.1k
- Forks
- 1k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 2
Description
If a custom authorizer is defined outside of app.py (in chalicelib for instance) then the lambda handler is incorrectly set to app.auth-function-name however it works correctly in the local environment. This is very misleading.
Here's an example project layout that works in the local server, but not when deployed:
```
.
├── app.py
├── chalicelib
│ ├── __init__.py
│ └── app.py
└── requirements.txt
```
Where the top level app.py contains:
```
import chalicelib
app = chalicelib.app
```
and chalicelib/app.py contains the actual entrypoint:
```
from chalice import Chalice, AuthResponse
app = Chalice(app_name='chalice-fml')
@app.authorizer()
def auth(auth_request):
app.log.info('auth_request: %s', auth_request)
return AuthResponse(routes=['/'], principal_id='user')
@app.route('/', authorizer=auth)
def index():
return {'hello': 'world'}
```
Are custom authorizers required to reside within the top level app.py? Reconfiguring the lambda to use chalicelib.auth-function-name fixes the issue, but of course that requires additional deployment steps.
Contributor guide
Research direction
Start with the top-level app.py and chalicelib/app.py example, then trace how Chalice determines the deployed Lambda handler for a custom authorizer versus the local server. Verify the generated handler for an authorizer defined outside app.py and compare it with the working chalicelib.auth-function-name configuration. Done means deployment selects the authorizer in chalicelib without manual reconfiguration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, python
- Domain
- backend, cloud
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100