Update docs to indicate you can use cognito pool authoriser and claims with lambda-proxy

This commit is contained in:
John Ferlito 2017-06-25 19:15:21 +10:00
parent 66ef02495e
commit f01ca2dbf7
No known key found for this signature in database
GPG Key ID: 4FFB060C9EC70B95
2 changed files with 7 additions and 4 deletions

View File

@ -265,7 +265,12 @@ functions:
arn: arn:aws:cognito-idp:us-east-1:xxx:userpool/us-east-1_ZZZ
```
By default the `sub` claim will be exposed in `events.cognitoPoolClaims`, you can add extra claims like so:
If you are using the default `lambda-proxy` integration, your attributes will be
exposed at `event.requestContext.authorizer.claims`.
If you want control more control over which attributes are exposed as claims you
can switch to `integration: lambda` and add the following configuration. The
claims will be exposed at `events.cognitoPoolClaims`.
```yml
functions:
@ -283,8 +288,6 @@ functions:
- nickname
```
Note: Since claims must be explicitly listed to be exposed, you must use `integration: lambda` integration type to access any claims.
### Catching Exceptions In Your Lambda Function
In case an exception is thrown in your lambda function AWS will send an error message with `Process exited before completing request`. This will be caught by the regular expression for the 500 HTTP status and the 500 status will be returned.

View File

@ -247,7 +247,7 @@ module.exports = {
if (integration === 'AWS_PROXY'
&& typeof arn === 'string' && arn.match(/^arn:aws:cognito-idp/) && authorizer.claims) {
const errorMessage = [
'Cognito claims can\'t be retrieved when using lambda-proxy as the integration type',
'Cognito claims can only be filtered when using the lambda integration type',
];
throw new this.serverless.classes.Error(errorMessage);
}