Skip to content

Commit

Permalink
[fix] 에러 처리 위치 바꿈
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryeolee committed Oct 27, 2023
1 parent 515d39f commit 4290f53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name: Java CI with Gradle

on:
push:
branches: [ "main" ]
branches: [ "feature_4/에러-수정" ]
pull_request:
branches: [ "dev" ]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ public GatewayFilter apply(Config config) {
String jwt = authorizationHeader.replace("Bearer ", "");
log.info("jwt : {}", jwt);

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

if(!isJwtValid(jwt, exchange)) {
return onError(exchange, "JWT token is not valid", HttpStatus.UNAUTHORIZED);
}

// 헤더 출력
request.getHeaders().forEach((k, v) -> {
log.info("{} : {}", k, v);
});

String subject = decode(jwt);
request.mutate()
.header("user", subject)
Expand All @@ -58,18 +71,7 @@ public GatewayFilter apply(Config config) {
return chain.filter(exchange);
}

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

if(!isJwtValid(jwt, exchange)) {
return onError(exchange, "JWT token is not valid", HttpStatus.UNAUTHORIZED);
}

// 헤더 출력
request.getHeaders().forEach((k, v) -> {
log.info("{} : {}", k, v);
});

// Custom Post Filter
return chain.filter(exchange);
Expand Down

0 comments on commit 4290f53

Please sign in to comment.