12월, 2018의 게시물 표시

[AWS] API Gateway Authorizer에서 Custom Header 추가하기

이미지
- Objective jwt validation을 위해서 api gateway authorizer를 사용 중이다. jwt validation 후 jwt 특정 필드들을 request header에 추가해서 web server에 제공하고 싶다. (web server는 jwt를 사용하는지 모르게) 아래 코드는 AWS에서 제공하는 샘플 코드이다. 코드중 authResponse.context로 context 설정을 하는 부분이 있다. 이렇게 context에 설정을 하게되면 api gateway integration request에서 context.authorize. PARM_NAME  으로 값에 접근이 가능해 진다. ex) context.authorizer.key context.authorizer.number 코드출처:  https://github.com/awslabs/aws-apigateway-lambda-authorizer-blueprints/blob/master/blueprints/nodejs/index.js /* * Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at * * http://aws.amazon.com/apache2.0/ * * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K