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

[Region] 지역 API 작업 완료 #4

Merged
merged 23 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
903fc0d
Feat: Region 엔티티 구성
onetuks Oct 31, 2023
6064c3b
chore: gitignore yaml 파일 무시 설정
onetuks Nov 1, 2023
f1c6686
Refactor: 필요 없는 테스트 클래스 제거
onetuks Nov 1, 2023
40aab75
Refactor: Region 엔티티 변경
onetuks Nov 1, 2023
1b32260
Feat: 시도 이용하여 시군구 검색 API 구현
onetuks Nov 1, 2023
7e196e7
refactor: 시군구 검색 시그니처 변경
onetuks Nov 1, 2023
3a6853b
Feat: 시도구군으로 읍면동 조회 API 구현
onetuks Nov 1, 2023
f7a9097
Feat: 조회 가능한 시도 조회 API 구현
onetuks Nov 1, 2023
3fdc275
Merge branch 'develop' into region
onetuks Nov 1, 2023
7da4746
Chore: 머지된 코드 리포매팅
onetuks Nov 1, 2023
ac6a085
Chore: 메인 패키지 변경 대응
onetuks Nov 1, 2023
a4bcce5
Test: 스프링 세큐리티 테스트 대응
onetuks Nov 1, 2023
a72f617
Feat: 지역 정보로 위경도 값 조회 기능 구현
onetuks Nov 1, 2023
05cc19f
Fix: 컬럼명 수정
onetuks Nov 1, 2023
7439616
Chore: CI 시 설정 문제 해결
onetuks Nov 1, 2023
67e0c83
Refactor: 컨트롤러 produces 속성 메소드 레벨로 이동
onetuks Nov 2, 2023
d95aef2
Feat: Region 테스트 가능하도록 수정
onetuks Nov 2, 2023
665b4f9
Chore: 테스트 불통 대응
onetuks Nov 2, 2023
4cb39da
Chore: CI 설정 오류 수정
onetuks Nov 2, 2023
a93c68a
Chore: CI 설정 오류 수정
onetuks Nov 2, 2023
02d64e1
Refactor: 지역 접두사 정보를 지역 엔티티로 이전
onetuks Nov 2, 2023
80e2ec8
Feat: 지역 예외 추가
onetuks Nov 2, 2023
fbab695
Feat: 시도, 시군구, 읍면동 유효성 어노테이션 구현
onetuks Nov 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 21 additions & 10 deletions .github/workflows/ci-develop.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,50 @@
name: Build and Deploy to EC2

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

workflow_dispatch:

env:
BUCKET_NAME: team09-cicd-bucket
PROJECT_NAME: studay
DEPLOYMENT_GROUP_NAME: studay_cicd
CODE_DEPLOY_APP_NAME: studay_cicd

jobs:
# 작업의 이름
build_and_test:
# GitHub Actions 러너의 운영 체제
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0.21
env:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: test
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10
redis:
image: redis
ports:
- 6379:6379
options: --entrypoint redis-server
# 순차적으로 실행될 단계들을 정의하는 섹션
steps:
- name: Checkout code
uses: actions/[email protected]

- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'corretto'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

- name: Create application.yml
run: |
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML_CONTENT }}" > src/main/resources/application.yml
echo "${{ secrets.APPLICATION_DEV_YML_CONTENT }}" > src/main/resources/application-dev.yml
echo "${{ secrets.APPLICATION_OAUTH_YML_CONTENT }}" > src/main/resources/application-oauth.yml
- name: Build with gradle
run: ./gradlew build

run: ./gradlew build
14 changes: 7 additions & 7 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ jobs:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_PRIVATE_ACCESS_KEY }}
aws-region: ap-northeast-1
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_PRIVATE_ACCESS_KEY }}
aws-region: ap-northeast-1

- name: Upload to S3
run: aws s3 cp --region ap-northeast-1 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip

- name: Code Deploy To EC2 instance
run: aws deploy create-deployment
--application-name $CODE_DEPLOY_APP_NAME
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name $DEPLOYMENT_GROUP_NAME
--s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip
--application-name $CODE_DEPLOY_APP_NAME
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name $DEPLOYMENT_GROUP_NAME
--s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ HELP.md
.gradle/
build/
studay_server.iml
src/main/resources/application.yaml
*.yaml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉.. 저도 설정했는데 나중에 conflict 처리해야겠군요 ㅠㅠ

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅠㅠ 컨플릭트 싫은뎅 ㅠㅠ


### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.guzzing.studayserver.domain.auth.client;

import org.guzzing.studayserver.global.error.response.ErrorCode;
import org.guzzing.studayserver.domain.auth.dto.GoogleUserResponse;
import org.guzzing.studayserver.domain.auth.exception.TokenValidFailedException;
import org.guzzing.studayserver.domain.member.model.Member;
import org.guzzing.studayserver.domain.member.model.vo.MemberProvider;
import org.guzzing.studayserver.domain.member.model.vo.RoleType;
import org.guzzing.studayserver.global.error.response.ErrorCode;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
Expand All @@ -26,8 +26,10 @@ public Member getUserData(String accessToken) {
.uri("https://www.googleapis.com/oauth2/v3/userinfo")
.headers(h -> h.set("Authorization", accessToken))
.retrieve()
.onStatus(status -> status.is4xxClientError(), response -> Mono.error(new TokenValidFailedException(ErrorCode.UNAUTHORIZED_TOKEN)))
.onStatus(status -> status.is5xxServerError(), response -> Mono.error(new TokenValidFailedException(ErrorCode.OAUTH_CLIENT_SERVER_ERROR)))
.onStatus(status -> status.is4xxClientError(),
response -> Mono.error(new TokenValidFailedException(ErrorCode.UNAUTHORIZED_TOKEN)))
.onStatus(status -> status.is5xxServerError(),
response -> Mono.error(new TokenValidFailedException(ErrorCode.OAUTH_CLIENT_SERVER_ERROR)))
.bodyToMono(GoogleUserResponse.class)
.block();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.guzzing.studayserver.domain.auth.client;

import org.guzzing.studayserver.global.error.response.ErrorCode;
import org.guzzing.studayserver.domain.auth.dto.KakaoUserResponse;
import org.guzzing.studayserver.domain.auth.exception.TokenValidFailedException;
import org.guzzing.studayserver.domain.member.model.Member;
import org.guzzing.studayserver.domain.member.model.vo.MemberProvider;
import org.guzzing.studayserver.domain.member.model.vo.RoleType;
import org.guzzing.studayserver.global.error.response.ErrorCode;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;
Expand All @@ -26,8 +26,10 @@ public Member getUserData(String accessToken) {
.uri("https://kapi.kakao.com/v2/user/me")
.headers(h -> h.set("Authorization", accessToken))
.retrieve()
.onStatus(status -> status.is4xxClientError(), response -> Mono.error(new TokenValidFailedException(ErrorCode.UNAUTHORIZED_TOKEN)))
.onStatus(status -> status.is5xxServerError(), response -> Mono.error(new TokenValidFailedException(ErrorCode.OAUTH_CLIENT_SERVER_ERROR)))
.onStatus(status -> status.is4xxClientError(),
response -> Mono.error(new TokenValidFailedException(ErrorCode.UNAUTHORIZED_TOKEN)))
.onStatus(status -> status.is5xxServerError(),
response -> Mono.error(new TokenValidFailedException(ErrorCode.OAUTH_CLIENT_SERVER_ERROR)))
.bodyToMono(KakaoUserResponse.class)
.block();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package org.guzzing.studayserver.domain.auth.client;

import java.util.HashMap;
import java.util.Map;
import org.guzzing.studayserver.domain.member.model.vo.MemberProvider;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient;

import java.util.HashMap;
import java.util.Map;

@Component
public class ClientStrategy {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ public class Constants {

/**
* 권한제외 대상
*
* @see SecurityConfig
*/
public static final String[] permitAllArray = new String[] {
public static final String[] permitAllArray = new String[]{
"/",
"/auth/**",

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package org.guzzing.studayserver.domain.auth.config;

import java.util.stream.Stream;
import org.guzzing.studayserver.domain.auth.jwt.AuthTokenProvider;
import org.guzzing.studayserver.domain.auth.jwt.JwtAuthenticationFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.HttpBasicConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
import org.springframework.security.config.annotation.web.configurers.HttpBasicConfigurer;
import java.util.stream.Stream;

@Configuration
@EnableWebSecurity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.netty.channel.ChannelOption;
import io.netty.handler.timeout.ReadTimeoutHandler;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -14,8 +15,6 @@
import reactor.netty.http.client.HttpClient;
import reactor.netty.tcp.TcpClient;

import java.util.concurrent.TimeUnit;

@Configuration
@Slf4j
public class WebClientConfig {
Expand All @@ -24,12 +23,12 @@ public class WebClientConfig {
public WebClient webClient() {

ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder()
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(1024*1024*50))
.codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(1024 * 1024 * 50))
.build();
exchangeStrategies
.messageWriters().stream()
.filter(LoggingCodecSupport.class::isInstance)
.forEach(writer -> ((LoggingCodecSupport)writer).setEnableLoggingRequestDetails(true));
.forEach(writer -> ((LoggingCodecSupport) writer).setEnableLoggingRequestDetails(true));

return WebClient.builder()
.clientConnector(
Expand All @@ -38,24 +37,28 @@ public WebClient webClient() {
TcpClient
.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 3000)
.doOnConnected(conn -> conn.addHandler(new ReadTimeoutHandler(3000, TimeUnit.MILLISECONDS)))
.doOnConnected(conn -> conn.addHandler(
new ReadTimeoutHandler(3000, TimeUnit.MILLISECONDS)))
)
))
.exchangeStrategies(exchangeStrategies)
.filter(ExchangeFilterFunction.ofRequestProcessor(
clientRequest -> {
log.debug("Request: {} {}", clientRequest.method(), clientRequest.url());
clientRequest.headers().forEach((name, values) -> values.forEach(value -> log.debug("{} : {}", name, value)));
clientRequest.headers().forEach(
(name, values) -> values.forEach(value -> log.debug("{} : {}", name, value)));
return Mono.just(clientRequest);
}
))
.filter(ExchangeFilterFunction.ofResponseProcessor(
clientResponse -> {
clientResponse.headers().asHttpHeaders().forEach((name, values) -> values.forEach(value -> log.debug("{} : {}", name, value)));
clientResponse.headers().asHttpHeaders().forEach(
(name, values) -> values.forEach(value -> log.debug("{} : {}", name, value)));
return Mono.just(clientResponse);
}
))
.defaultHeader("user-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.3")
.defaultHeader("user-agent",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.3")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public ResponseEntity<AuthResponse> googleAuthRequest(HttpServletRequest request
}

@GetMapping("/refresh")
public ResponseEntity<AuthResponse> refreshToken( HttpServletRequest request) {
public ResponseEntity<AuthResponse> refreshToken(HttpServletRequest request) {

String appToken = JwtHeaderUtil.getAccessToken(request);
AuthToken authToken = authTokenProvider.convertAuthToken(appToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public KakaoUserResponse(Long id, Properties properties, KakaoAccount kakaoAccou
@NoArgsConstructor
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
public static class Properties {

private NickName nickname;

public Properties(NickName nickname) {
Expand All @@ -36,6 +37,7 @@ public Properties(NickName nickname) {
@Getter
@NoArgsConstructor
public static class KakaoAccount {

private String email;

public KakaoAccount(String email) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.guzzing.studayserver.domain.auth.exception;

import org.guzzing.studayserver.global.error.response.ErrorCode;
import lombok.Getter;
import org.guzzing.studayserver.global.error.response.ErrorCode;

@Getter
public class TokenValidFailedException extends IllegalStateException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
package org.guzzing.studayserver.domain.auth.jwt;

import io.jsonwebtoken.*;
import lombok.Builder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.ExpiredJwtException;
import io.jsonwebtoken.JwtParser;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.MalformedJwtException;
import io.jsonwebtoken.SignatureAlgorithm;
import io.jsonwebtoken.UnsupportedJwtException;
import java.security.Key;
import java.util.Date;
import java.util.Optional;
import lombok.Builder;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AuthToken {
Expand Down Expand Up @@ -61,7 +66,7 @@ public String createRefreshToken(Date expiry) {
public boolean isValidTokenClaims() {
Optional<Object> claims = Optional.empty();
try {
claims= Optional.ofNullable(getTokenClaims());
claims = Optional.ofNullable(getTokenClaims());
} catch (SecurityException e) {
log.info("Invalid JWT signature.");
} catch (MalformedJwtException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.security.Keys;
import java.security.Key;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand All @@ -10,12 +15,6 @@
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

import java.security.Key;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Slf4j
@Component
public class AuthTokenProvider {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package org.guzzing.studayserver.domain.auth.jwt;

import lombok.Builder;
import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serial;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import lombok.Builder;
import lombok.Getter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

@Getter
public class CustomUser implements UserDetails {
Expand All @@ -29,8 +28,12 @@ public CustomUser(Long memberId, String socialId, List<? extends GrantedAuthorit

@Override
public boolean equals(Object obj) {
if (obj == this) return true;
if (obj == null || obj.getClass() != this.getClass()) return false;
if (obj == this) {
return true;
}
if (obj == null || obj.getClass() != this.getClass()) {
return false;
}
var that = (CustomUser) obj;
return Objects.equals(this.memberId, that.memberId) &&
Objects.equals(this.socialId, that.socialId) &&
Expand Down
Loading