-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add back custom auth #322
Add back custom auth #322
Conversation
This needs to go through the `define_authorizer` in order to work with the swagger generation.
Codecov Report
@@ Coverage Diff @@
## master #322 +/- ##
==========================================
+ Coverage 88.95% 89.13% +0.17%
==========================================
Files 18 18
Lines 1865 1905 +40
Branches 225 231 +6
==========================================
+ Hits 1659 1698 +39
Misses 152 152
- Partials 54 55 +1
Continue to review full report at Codecov.
|
chalice/deploy/swagger.py
Outdated
auth_config = { | ||
'type': auth_type, | ||
'authorizerUri': authorizer_config['authorizer_uri'], | ||
'authorizerResultTtlInSeconds': 300, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason not to expose authorizerResultTtlInSeconds
in the config?
Ok, after chatting about this, I'd like to propose some changes here. First, we should have a consistent pattern for configuring advanced resources. I like the pattern used with the from chalice.app import CustomAuthorizer
from chalice.app import CognitoUserPoolsAuthorizer
from chalice import Chalice
app = Chalice(app_name='testauth')
custom = CustomAuthorizer('MyAuth', header='Authorization', provider_uri='...')
cognito_auth = CognitoUserPoolsAuthorizer(
'MyUserPool', header='Authorization', provider_arns=['myarn...'],
)
@app.route('/auth1', authorizer=custom)
def custom_auth(): ...
@app.route('/cognito-auth', authorizer=cognito_auth)
def cognito_auth(): ... To help transition, we should keep Let me know if anyone has concerns about this. |
README.rst
Outdated
) | ||
'function:FunctionName/invocations')) | ||
|
||
@app.route('/user-pools', methods=['GET'], authorizer=authorizer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a different route name here since the other example was for user pools
chalice/app.py
Outdated
raise NotImplementedError("to_swagger") | ||
|
||
|
||
class CognitoUserPoolAuthorizer(object): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing you meant to inherit from Authorizer
here.
Also added extra validation to help users.
@stealthycoin Feedback incorporated, ready for another look. |
These aren't intended to be tested.
This needs to go through the
define_authorizer
in order to workwith the swagger generation.