Skip to content

Commit

Permalink
[python] Document 'context' map in authResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrk authored Nov 30, 2016
1 parent 7875499 commit 48831f8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions blueprints/python/api-gateway-authorizer-python.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,23 @@ def lambda_handler(event, context):
policy.denyAllMethods()
"""policy.allowMethod(HttpVerb.GET, "/pets/*")"""

"""finally, build the policy and exit the function using return"""
return policy.build()
# Finally, build the policy
authResponse = policy.build()

# new! -- add additional key-value pairs associated with the authenticated principal
# these are made available by APIGW like so: $context.authorizer.<key>
# additional context is cached
context = {
'key': 'value', # $context.authorizer.key -> value
'number' : 1,
'bool' : True
}
# context['arr'] = ['foo'] <- this is invalid, APIGW will not accept it
# context['obj'] = {'foo':'bar'} <- also invalid

authResponse['context'] = context

return authResponse

class HttpVerb:
GET = "GET"
Expand Down

0 comments on commit 48831f8

Please sign in to comment.