-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from donggukthon/dev
✨ [Feat] dev 환경을 prod 환경에 적용한다.
- Loading branch information
Showing
58 changed files
with
1,722 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,3 +35,11 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
.trash/ | ||
.DS_Store | ||
|
||
application-local.yml | ||
application-dev.yml | ||
application-prod.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "volunmate_properties"] | ||
path = volunmate_properties | ||
url = https://github.com/kurtyoon/volunmate_properties.git | ||
branch = main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM gradle:8.2.1-jdk17 AS builder | ||
COPY . /usr/src | ||
WORKDIR /usr/src | ||
RUN gradle wrapper --gradle-version 8.2.1 | ||
RUN ./gradlew build | ||
|
||
FROM openjdk:17-jdk-alpine | ||
COPY --from=builder /usr/src/build/libs/volunmate-0.0.1-SNAPSHOT.jar /usr/app/app.jar | ||
ENTRYPOINT ["java","-jar","/usr/app/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# donggukthon_2023_4_B | ||
|
||
2023 Donggukthon 4팀 백엔드 레포지토리입니다. | ||
|
||
# GitHub Role | ||
|
||
해당 Repository는 다음과 같은 Convention을 따릅니다. | ||
|
||
## Commit Convention | ||
|
||
| 커밋 유형 | 설명 | | ||
| --- | --- | | ||
| Feat | 새로운 기능 추가 | | ||
| Fix | 버그 수정 | | ||
| Docs | 문서 수정 | | ||
| Style | 코드 formatting, 세미콜론 누락, 코드 자체의 변경이 없는 경우 | | ||
| Refactor | 코드 리팩토링 | | ||
| Test | 테스트 코드, 리팩토링 테스트 코드 추가 | | ||
| Chore | 패키지 매니저 수정, 그 외 기타 수정 ex) .gitignore | | ||
| Design | CSS 등 사용자 UI 디자인 변경 | | ||
| Comment | 필요한 주석 추가 및 변경 | | ||
| Rename | 파일 또는 폴더 명을 수정하거나 옮기는 작업만인 경우 | | ||
| Remove | 파일을 삭제하는 작업만 수행한 경우 | | ||
| !BREAKING CHANGE | 커다란 API 변경의 경우 | | ||
| !HOTFIX | 급하게 치명적인 버그를 고쳐야 하는 경우 | | ||
|
||
## PR Convention | ||
|
||
| 아이콘 | 코드 | 설명 | | ||
| --- | --- | --- | | ||
| 🧑🏻🎨 | :art | 코드의 구조/형태 개선 | | ||
| ⚡️ | :zap | 성능 개선 | | ||
| 🔥 | :fire | 코드/파일 삭제 | | ||
| 🐛 | :bug | 버그 수정 | | ||
| 🚑 | :ambulance | 긴급 수정 | | ||
| ✨ | :sparkles | 새 기능 | | ||
| 💄 | :lipstick | UI/스타일 파일 추가/수정 | | ||
| ⏪ | :rewind | 변경 내용 되돌리기 | | ||
| 🔀 | :twisted_rightwards_arrows | 브랜치 합병 | | ||
| 💡 | :bulb | 주석 추가/수정 | | ||
| 🗃 | :card_file_box | 데이터베이스 관련 수정 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
src/main/java/donggukthon/volunmate/VolunmateApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package donggukthon.volunmate.annotation; | ||
|
||
import java.lang.annotation.*; | ||
|
||
@Documented | ||
@Target(ElementType.PARAMETER) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface SocialId { | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/donggukthon/volunmate/config/CorsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package donggukthon.volunmate.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.cors.CorsConfiguration; | ||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | ||
import org.springframework.web.filter.CorsFilter; | ||
|
||
@Configuration | ||
public class CorsConfig { | ||
@Bean | ||
public CorsFilter corsFilter() { | ||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); | ||
CorsConfiguration configuration = new CorsConfiguration(); | ||
|
||
configuration.setAllowCredentials(true); | ||
configuration.addAllowedOriginPattern("*"); | ||
configuration.addAllowedHeader("*"); | ||
configuration.addAllowedMethod("*"); | ||
|
||
source.registerCorsConfiguration("/**", configuration); | ||
return new CorsFilter(source); | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/donggukthon/volunmate/config/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package donggukthon.volunmate.config; | ||
|
||
import donggukthon.volunmate.constant.Constants; | ||
import donggukthon.volunmate.security.filter.JwtAuthenticationFilter; | ||
import donggukthon.volunmate.security.filter.JwtExceptionFilter; | ||
import donggukthon.volunmate.security.handler.JwtAccessDeniedHandler; | ||
import donggukthon.volunmate.security.handler.JwtEntryPoint; | ||
import donggukthon.volunmate.security.service.CustomUserDetailsService; | ||
import donggukthon.volunmate.utils.JwtUtil; | ||
import lombok.RequiredArgsConstructor; | ||
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.http.SessionCreationPolicy; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
@RequiredArgsConstructor | ||
public class SecurityConfig { | ||
|
||
private final CustomUserDetailsService customUserDetailsService; | ||
private final JwtEntryPoint jwtEntryPoint; | ||
private final JwtAccessDeniedHandler jwtAccessDeniedHandler; | ||
private final JwtUtil jwtUtil; | ||
|
||
@Bean | ||
protected SecurityFilterChain securityFilterChain(final HttpSecurity httpSecurity) throws Exception { | ||
return httpSecurity | ||
.csrf(AbstractHttpConfigurer::disable) | ||
.httpBasic(AbstractHttpConfigurer::disable) | ||
.sessionManagement((sessionManagement) -> | ||
sessionManagement.sessionCreationPolicy(SessionCreationPolicy.STATELESS)) | ||
.authorizeHttpRequests(requestMatcherRegistry -> requestMatcherRegistry | ||
.requestMatchers(Constants.NO_AUTH_WHITE_LABEL.toArray(String[]::new)).permitAll() | ||
.anyRequest().authenticated() | ||
) | ||
.exceptionHandling(exceptionHandling -> exceptionHandling | ||
.authenticationEntryPoint(jwtEntryPoint) | ||
.accessDeniedHandler(jwtAccessDeniedHandler)) | ||
.addFilterBefore(new JwtAuthenticationFilter( | ||
jwtUtil, customUserDetailsService | ||
), UsernamePasswordAuthenticationFilter.class) | ||
.addFilterBefore(new JwtExceptionFilter(), JwtAuthenticationFilter.class) | ||
.getOrBuild(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/java/donggukthon/volunmate/config/SwaggerConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package donggukthon.volunmate.config; | ||
|
||
import io.swagger.v3.oas.models.OpenAPI; | ||
import io.swagger.v3.oas.models.info.Info; | ||
import org.springdoc.core.models.GroupedOpenApi; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class SwaggerConfig { | ||
@Bean | ||
public GroupedOpenApi publicApi() { | ||
return GroupedOpenApi.builder() | ||
.group("public-api") | ||
.pathsToMatch("/**") | ||
.build(); | ||
} | ||
|
||
@Bean | ||
public OpenAPI openAPI() { | ||
return new OpenAPI() | ||
.info(new Info() | ||
.title("Volunmate API") | ||
.description("Volunmate API Docs") | ||
.version("0.0.1") | ||
); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/donggukthon/volunmate/config/WebMvcConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package donggukthon.volunmate.config; | ||
|
||
import donggukthon.volunmate.interceptor.SocialIdArgumentResolver; | ||
import donggukthon.volunmate.interceptor.SocialIdInterceptor; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
||
import java.util.List; | ||
|
||
@Configuration | ||
@EnableWebMvc | ||
@RequiredArgsConstructor | ||
public class WebMvcConfig implements WebMvcConfigurer { | ||
private final SocialIdArgumentResolver socialIdArgumentResolver; | ||
|
||
@Override | ||
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) { | ||
WebMvcConfigurer.super.addArgumentResolvers(resolvers); | ||
resolvers.add(socialIdArgumentResolver); | ||
} | ||
|
||
@Override | ||
public void addInterceptors(InterceptorRegistry registry) { | ||
registry.addInterceptor(new SocialIdInterceptor()) | ||
.addPathPatterns("/api/**") | ||
.excludePathPatterns("/api/health"); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/donggukthon/volunmate/constant/Constants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package donggukthon.volunmate.constant; | ||
|
||
import java.util.List; | ||
|
||
public class Constants { | ||
public static String SOCIAL_ID_CLAIM_NAME = "socialId"; | ||
public static String USER_TYPE_CLAIM_NAME = "userType"; | ||
public static String BEARER_PREFIX = "Bearer "; | ||
public static String AUTHORIZATION = "Authorization"; | ||
public static String REAUTHORIZATION = "Reauthorization"; | ||
|
||
public static List<String> NO_AUTH_WHITE_LABEL = List.of( | ||
"/swagger-ui/index.html", | ||
"/swagger-ui/swagger-ui.css", | ||
"/swagger-ui/swagger-initializer.js", | ||
"/swagger-ui/swagger-ui-standalone-preset.js", | ||
"/swagger-ui/index.css", | ||
"/swagger-ui/swagger-ui-bundle.js", | ||
"/v3/api-docs/swagger-config", | ||
"/v3/api-docs/public-api", | ||
"/swagger-ui/favicon-32x32.png", | ||
"/api/auth/google", | ||
"/api/auth/google/callback" | ||
); | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/donggukthon/volunmate/controller/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package donggukthon.volunmate.controller; | ||
|
||
|
||
import donggukthon.volunmate.annotation.SocialId; | ||
import donggukthon.volunmate.dto.auth.AuthSignupDto; | ||
import donggukthon.volunmate.dto.exception.ResponseDto; | ||
import donggukthon.volunmate.dto.jwt.JwtTokenDto; | ||
import donggukthon.volunmate.service.OAuth2Service; | ||
import donggukthon.volunmate.type.ELoginProvider; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.io.IOException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@RestController | ||
@RequestMapping("/api/auth") | ||
@RequiredArgsConstructor | ||
public class AuthController { | ||
private final OAuth2Service oAuth2Service; | ||
|
||
@GetMapping("/google") | ||
public ResponseDto<Map<String, String>> getGoogleRedirectUrl() { | ||
Map<String, String> map = new HashMap<>(); | ||
map.put("url", oAuth2Service.getRedirectUrl(ELoginProvider.GOOGLE)); | ||
return ResponseDto.ok(map); | ||
} | ||
|
||
@GetMapping("/google/callback") | ||
public void getGoogleAccessToken(String code, HttpServletResponse response) throws IOException { | ||
String accessToken = oAuth2Service.getAccessToken(code, ELoginProvider.GOOGLE); | ||
oAuth2Service.login(response, accessToken, ELoginProvider.GOOGLE); | ||
} | ||
|
||
@PostMapping("/enroll") | ||
public ResponseDto<Boolean> enroll(@SocialId String socialId, @RequestBody AuthSignupDto authSignupDto) { | ||
return ResponseDto.ok(oAuth2Service.enroll(socialId, authSignupDto)); | ||
} | ||
|
||
@GetMapping("/logout") | ||
public ResponseDto<Boolean> logout(@SocialId String socialId) { | ||
return ResponseDto.ok(oAuth2Service.logout(socialId)); | ||
} | ||
|
||
@GetMapping("/refresh") | ||
public ResponseDto<?> updateAccessToken(HttpServletRequest request) { | ||
return ResponseDto.ok(oAuth2Service.reissueAccessToken(request)); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/donggukthon/volunmate/controller/HealthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package donggukthon.volunmate.controller; | ||
|
||
import donggukthon.volunmate.dto.exception.ResponseDto; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api") | ||
public class HealthController { | ||
@GetMapping("/health") | ||
public ResponseDto<String> health() { | ||
return ResponseDto.ok("OK"); | ||
} | ||
} |
Oops, something went wrong.