Skip to content
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

Multiple claims for authorizer break body mapping template #3088

Closed
pisaacs opened this issue Jan 12, 2017 · 5 comments · Fixed by #3187
Closed

Multiple claims for authorizer break body mapping template #3088

pisaacs opened this issue Jan 12, 2017 · 5 comments · Fixed by #3187
Labels

Comments

@pisaacs
Copy link

pisaacs commented Jan 12, 2017

This is a Bug Report

Description

Setting multiple claims for an authorizer breaks the body mapping template.

For bug reports:

  • What went wrong?
    Received the following error from API Gateway: {"message": "Could not parse request body into json: Unexpected character (\',\' (code 44)): was expecting double-quote to start field name\n at...

  • What did you expect should have happened?
    Body mapping template to correctly parse claim fields.

  • What was the config you used?
    The below:

...
    events:
      - http:
          path: person
          method: post
          cors: true
          integration: lambda
          authorizer:
            arn: ${self:custom.apiGatewayUserPoolAuthorization}
            claims:
              - email
              - name
....
  • What stacktrace or error message from your provider did you see?
    Received the following from API gateway: {"message": "Could not parse request body into json: Unexpected character (\',\' (code 44)): was expecting double-quote to start field name\n at...

Additional Data

With two claims, the body mapping template for application/x-www-form-urlencoded gets configured as the below. Two commas appear between the fields.

.....   
 "cognitoPoolClaims" : {
       "email": "$context.authorizer.claims.email",,"name": "$context.authorizer.claims.name",
       "sub": "$context.authorizer.claims.sub"
    },
.....
  • Serverless Framework Version you're using: 1.5.0
  • Operating System: darwin
@pisaacs pisaacs changed the title Multiple claims for authorizer breaks body mapping template Multiple claims for authorizer break body mapping template Jan 12, 2017
@pmuens pmuens added the bug label Jan 12, 2017
@kidsil
Copy link

kidsil commented Jan 27, 2017

Temporary Fix: when the second claim is removed (- name) it works fine.

@pisaacs
Copy link
Author

pisaacs commented Jan 28, 2017

It's not a fix if you have to remove something you need 😉. The temporary fix is to update the body mapping template after a deploy (which would then enable access to all claim fields).

@kidsil
Copy link

kidsil commented Jan 28, 2017 via email

@shasti421
Copy link

shasti421 commented Feb 20, 2017

We are also running into this. Is the fix available in a release ?

@pmuens
Copy link
Contributor

pmuens commented Feb 22, 2017

Hey @shasti421 we need to review and test the provided fix in order to include it in a release.

Have you had the time to test it? If so, does it resolve the issue for you?

eahefnawy added a commit that referenced this issue Mar 13, 2017
Fix for authorizer claims: multiple claims and custom property claims  (#3088)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants