Skip to content

Commit

Permalink
Chore: fix filter chain
Browse files Browse the repository at this point in the history
  • Loading branch information
bin-pro committed Jun 21, 2024
1 parent ced4a92 commit 2eb2772
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
name: cicd for gateway-service
on:
push:
branches: [ main, test ]
branches:
- main
- test
pull_request:
branches: [ main, test ]
branches:
- main
- test
workflow_dispatch:

env:
Expand Down Expand Up @@ -81,9 +85,9 @@ jobs:
key: ${{ secrets.PRIVATE_KEY }}
envs: GITHUB_SHA,NEXT_GATEWAY_VER
script: |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.NEXT_GATEWAY_VER }}
sudo docker stop ${{ env.IMAGE_NAME }} || true
sudo docker rm ${{ env.IMAGE_NAME }} || true
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:${{ env.NEXT_GATEWAY_VER }}
sudo docker run -d --name ${{ env.IMAGE_NAME }} --network esthete-network -p 80:80 \
-e INSTANCE_HOST='${{ secrets.HOST_TEST_DNS }}' \
-e EUREKA_HOST='${{ secrets.EUREKA_HOST }}' \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public GatewayFilter apply(Config config) {
}

if (!request.getHeaders().containsKey(HttpHeaders.AUTHORIZATION)) {
return onError(exchange, "No authorization header", HttpStatus.UNAUTHORIZED);
//return onError(exchange, "No authorization header", HttpStatus.UNAUTHORIZED);
return chain.filter(exchange);
}

String authorizationHeader = request.getHeaders().get(HttpHeaders.AUTHORIZATION).get(0);
Expand All @@ -60,11 +61,11 @@ public GatewayFilter apply(Config config) {
}

try {
String id = getId(jwt);
//String id = getId(jwt);
//Authorization Header를 유저 id 값으로 변경
exchange.getRequest().mutate().headers(h -> {h.replace(HttpHeaders.AUTHORIZATION, Collections.singletonList(id));});
//exchange.getRequest().mutate().headers(h -> {h.replace(HttpHeaders.AUTHORIZATION, Collections.singletonList(id));});
} catch (Exception e) {
return onError(exchange, "Error occurred while setting user id from token", HttpStatus.INTERNAL_SERVER_ERROR);
//return onError(exchange, "Error occurred while setting user id from token", HttpStatus.INTERNAL_SERVER_ERROR);
}

return chain.filter(exchange);
Expand Down

0 comments on commit 2eb2772

Please sign in to comment.