Skip to content

Commit

Permalink
Merge branch 'develop' into feature/96
Browse files Browse the repository at this point in the history
  • Loading branch information
Programmer-may authored Jan 20, 2024
2 parents 640c23a + 4b99acd commit 0b83457
Show file tree
Hide file tree
Showing 120 changed files with 2,510 additions and 525 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ dependencies {

//email
implementation 'org.springframework.boot:spring-boot-starter-mail:3.0.5'

//fcm
implementation 'com.google.firebase:firebase-admin:9.1.1'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public class EmailConfig {
public JavaMailSender mailSender() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(host);
mailSender.setPort(port); //todo: 상수 분리
mailSender.setUsername(user); //todo: 상수 분리
mailSender.setPort(port);
mailSender.setUsername(user);
mailSender.setPassword(password);

Properties javaMailProperties = getMailProperties();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package kr.co.fastcampus.yanabada.common.config;

import static org.springframework.http.HttpMethod.GET;
import static org.springframework.http.HttpMethod.POST;

import java.util.List;
import kr.co.fastcampus.yanabada.common.jwt.filter.JwtAuthFilter;
import kr.co.fastcampus.yanabada.common.jwt.filter.JwtExceptionFilter;
Expand All @@ -11,6 +14,7 @@
import org.springframework.boot.autoconfigure.security.servlet.PathRequest;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
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.configuration.WebSecurityCustomizer;
Expand All @@ -34,8 +38,15 @@ public class SecurityConfig {
private final Oauth2LoginFailureHandler oauth2LoginFailureHandler;

private static final String[] PERMIT_PATHS = {
"/",
"/**"
"/auth", "/auth/**"
};

private static final String[] PERMIT_PATHS_POST_METHOD = {
"/accommodations/**", "/orders"
};

private static final String[] PERMIT_PATHS_GET_METHOD = {
"/products", "/products/**"
};

@Bean
Expand All @@ -49,8 +60,11 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
);

http.authorizeHttpRequests(authorize -> authorize
.requestMatchers(PERMIT_PATHS).permitAll()
.anyRequest().authenticated()
.requestMatchers(PERMIT_PATHS).permitAll()
.requestMatchers(POST, PERMIT_PATHS_POST_METHOD).permitAll()
.requestMatchers(GET, PERMIT_PATHS_GET_METHOD).permitAll()
.requestMatchers("/products/own").denyAll()
.anyRequest().authenticated()
);

http.oauth2Login(oauth2 -> oauth2
Expand All @@ -73,7 +87,7 @@ CorsConfigurationSource corsConfigurationSource() {
configuration.setAllowedMethods(List.of("*"));
configuration.setAllowedHeaders(List.of("*"));
configuration.addExposedHeader("Authorization");
configuration.setAllowCredentials(true); //todo : 쿠키를 포함한 크로스 도메인 요청을 허용? 확인필요
configuration.setAllowCredentials(true); //쿠키를 포함한 크로스 도메인 요청을 허용
configuration.setMaxAge(3600L);

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
Expand All @@ -83,7 +97,7 @@ CorsConfigurationSource corsConfigurationSource() {

@Bean
@ConditionalOnProperty(name = "spring.h2.console.enabled", havingValue = "true")
public WebSecurityCustomizer configureH2ConsoleEnable() { // h2-console 화면설정
public WebSecurityCustomizer configureH2ConsoleEnable() {
return web -> web.ignoring()
.requestMatchers(PathRequest.toH2Console());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.ADMIN_PAYMENT_NOT_FOUND;

public class AdminPaymentNotFoundException extends BaseException {
public AdminPaymentNotFoundException() {
super(ADMIN_PAYMENT_NOT_FOUND.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.DUPLICATE_YANOLJAPAY;

public class DuplicateYanoljaPayException extends BaseException {
public DuplicateYanoljaPayException() {
super(DUPLICATE_YANOLJAPAY.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.FCM_ACCESS_TOKEN_GET_FAILED;

public class FcmAccessTokenGetFailedException extends BaseException {
public FcmAccessTokenGetFailedException() {
super(FCM_ACCESS_TOKEN_GET_FAILED.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.FCM_MESSAGE_SEND_FAILED;

public class FcmMessageSendFailedException extends BaseException {
public FcmMessageSendFailedException() {
super(FCM_MESSAGE_SEND_FAILED.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.INCORRECT_YANOLJAPAY_PASSWORD;

public class IncorrectYanoljaPayPasswordException extends BaseException {
public IncorrectYanoljaPayPasswordException() {
super(INCORRECT_YANOLJAPAY_PASSWORD.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.JSON_PROCESS_FAILED;

public class JsonProcessFailedException extends BaseException {
public JsonProcessFailedException() {
super(JSON_PROCESS_FAILED.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.NOT_ENOUGH_POINT;

public class NotEnoughPointException extends BaseException {
public NotEnoughPointException() {
super(NOT_ENOUGH_POINT.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.NOT_ENOUGH_YANOLJAPAY_BALANCE;

public class NotEnoughYanoljaPayBalanceException extends BaseException {
public NotEnoughYanoljaPayBalanceException() {
super(NOT_ENOUGH_YANOLJAPAY_BALANCE.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.NOT_MATCHED_PROVIDER_NAME;

public class NotMatchedProviderNameException extends BaseException {
public NotMatchedProviderNameException() {
super(NOT_MATCHED_PROVIDER_NAME.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.OKHTTP3_REQUEST_FAILED;

public class OkHttp3RequestFailedException extends BaseException {
public OkHttp3RequestFailedException() {
super(OKHTTP3_REQUEST_FAILED.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.UNAVAILABLE_STATUS_QUERY;

public class UnavailableStatusQueryException extends BaseException {
public UnavailableStatusQueryException() {
super(UNAVAILABLE_STATUS_QUERY.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.YANOLJAPAY_HISTORY_NOT_FOUND;

public class YanoljaPayHistoryNotFoundException extends BaseException {

public YanoljaPayHistoryNotFoundException() {
super(YANOLJAPAY_HISTORY_NOT_FOUND.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package kr.co.fastcampus.yanabada.common.exception;

import static kr.co.fastcampus.yanabada.common.response.ErrorCode.PAY_NOT_FOUND;
import static kr.co.fastcampus.yanabada.common.response.ErrorCode.YANOLJAPAY_NOT_FOUND;

public class YanoljaPayNotFoundException extends BaseException {

public YanoljaPayNotFoundException() {
super(PAY_NOT_FOUND.getMessage());
super(YANOLJAPAY_NOT_FOUND.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
import kr.co.fastcampus.yanabada.common.exception.BaseException;
import kr.co.fastcampus.yanabada.common.exception.EmailDuplicatedException;
import kr.co.fastcampus.yanabada.common.exception.EmailSendFailedException;
import kr.co.fastcampus.yanabada.common.exception.FcmAccessTokenGetFailedException;
import kr.co.fastcampus.yanabada.common.exception.FcmMessageSendFailedException;
import kr.co.fastcampus.yanabada.common.exception.JsonProcessFailedException;
import kr.co.fastcampus.yanabada.common.exception.NotMatchedProviderNameException;
import kr.co.fastcampus.yanabada.common.exception.OkHttp3RequestFailedException;
import kr.co.fastcampus.yanabada.common.exception.TokenExpiredException;
import kr.co.fastcampus.yanabada.common.jwt.dto.TokenExpiredResponse;
import kr.co.fastcampus.yanabada.common.response.ResponseBody;
Expand Down Expand Up @@ -137,4 +142,49 @@ public ResponseBody<Void> emailDuplicatedException(
return ResponseBody.fail(e.getMessage());
}

@ExceptionHandler(JsonProcessFailedException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseBody<Void> jsonProcessFailedException(
JsonProcessFailedException e
) {
log.error("[JsonProcessFailedException] Message = {}", e.getMessage());
return ResponseBody.fail(e.getMessage());
}

@ExceptionHandler(OkHttp3RequestFailedException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseBody<Void> okHttp3RequestFailedException(
OkHttp3RequestFailedException e
) {
log.error("[OkHttp3RequestFailedException] Message = {}", e.getMessage());
return ResponseBody.fail(e.getMessage());
}

@ExceptionHandler(FcmMessageSendFailedException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseBody<Void> fcmMessageSendFailedException(
FcmMessageSendFailedException e
) {
log.error("[FcmMessageSendFailedException] Message = {}", e.getMessage());
return ResponseBody.fail(e.getMessage());
}

@ExceptionHandler(FcmAccessTokenGetFailedException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseBody<Void> fcmAccessTokenGetFailedException(
FcmAccessTokenGetFailedException e
) {
log.error("[FcmAccessTokenGetFailedException] Message = {}", e.getMessage());
return ResponseBody.fail(e.getMessage());
}

@ExceptionHandler(NotMatchedProviderNameException.class)
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public ResponseBody<Void> notMatchedProviderNameException(
NotMatchedProviderNameException e
) {
log.error("[NotMatchedProviderNameException] Message = {}", e.getMessage());
return ResponseBody.fail(e.getMessage());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package kr.co.fastcampus.yanabada.common.firebase.dto.request;

import lombok.Builder;

@Builder
public record FcmMessageRequest(
Boolean validateOnly,
Message message

) {
@Builder
public record Message(
Notification notification,
Data data,
String token
) {
}

@Builder
public record Notification(
String title,
String body,
String image
) {
}

@Builder
public record Data(
String notificationType
) {
}

}

Loading

0 comments on commit 0b83457

Please sign in to comment.