Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ TIME_NOW=$(date +%c)
echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG
cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE

# jar 파일 실행
# jar 파일 실행 (prod 프로필 적용)
echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG
nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG &
nohup java -jar $JAR_FILE --spring.profiles.active=prod > $APP_LOG 2> $ERROR_LOG &
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void logAfterThrowing(JoinPoint joinPoint, GeneralException exception) {
ErrorStatus errorStatus = exception.getErrorStatus();
MDC.put("httpStatus", String.valueOf(errorStatus.getHttpStatus()));

log.error("[ERROR] POINT : {} || EXCEPTION : {} || ARGUMENTS : {}",
log.error("[ERROR] POINT : {} || ERROR CODE : {} || ARGUMENTS : {}",
className, errorStatus.getCode(), parameterMessage
);
log.error("[ERROR] FINAL POINT : {}", exception.getStackTrace()[0]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@Aspect
@RequiredArgsConstructor
@Component
public class UnintendedExceptionLoggingAspect {
public class UndefinedExceptionLoggingAspect {

private final DiscordWebhookSender discordWebhookSender;

Expand Down
54 changes: 29 additions & 25 deletions src/main/java/com/pitchain/common/config/SecurityConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.pitchain.common.filter.JwtAuthenticationFilter;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
Expand Down Expand Up @@ -36,10 +37,28 @@ public class SecurityConfig {
private final JwtAuthenticationFilter jwtAuthenticationFilter;
private final RoleRequestCollector roleRequestCollector;

@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
@Value("#{'${spring.cors.allowed-origins}'.replaceAll(' ', '').split(',')}")
private List<String> allowedOrigins;

private static final String[] SWAGGER_PATTERNS = {
"/swagger-ui/**",
"/v3/api-docs/**",
};

private static final String[] STATIC_RESOURCES_PATTERNS = {
"/img/**",
"/css/**",
"/js/**",
"/favicon.ico",
};

private static final String[] PUBLIC_ENDPOINTS = {
"/health-check", // health check
"/oauth**",
"/members/tokens", "/members/emails", // 공통 유저
"/companies", "/companies/login", // 회사
"/dev/**", // 개발용
};

@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
Expand Down Expand Up @@ -68,31 +87,11 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.build();
}

private static final String[] SWAGGER_PATTERNS = {
"/swagger-ui/**",
"/v3/api-docs/**",
};

private static final String[] STATIC_RESOURCES_PATTERNS = {
"/img/**",
"/css/**",
"/js/**",
"/favicon.ico",
};

private static final String[] PUBLIC_ENDPOINTS = {
"/health-check", // health check
"/oauth**",
"/members/tokens", "/members/emails", // 공통 유저
"/companies", "/companies/login", // 회사
"/dev/**", // 개발용
};

@Bean
public CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration config = new CorsConfiguration();
config.setAllowCredentials(true);
config.setAllowedOrigins(List.of("http://localhost:5173"));
config.setAllowedOrigins(allowedOrigins);
config.setAllowedMethods(List.of("GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"));
config.setAllowedHeaders(List.of("*"));
config.setExposedHeaders(Arrays.asList("Authorization", "Authorization-Refresh"));
Expand Down Expand Up @@ -127,4 +126,9 @@ private static void writeErrorResponse(HttpServletResponse response, String mess
response.setCharacterEncoding("UTF-8");
response.getWriter().write(new ObjectMapper().writeValueAsString(customResponse));
}

@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}
}
3 changes: 2 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ spring:
fallback-to-system-locale: false
encoding: UTF-8
cache-duration: 3600
cors:
allowed-origins: ${CORS_ALLOWED_ORIGINS}
datasource:
master:
driver-class-name: ${MASTER_DATASOURCE_DRIVER_CLASS_NAME}
Expand All @@ -28,7 +30,6 @@ spring:
host: ${REDIS_HOST}
port: ${REDIS_PORT}
channel: ${REDIS_CHANNEL}

cloud:
aws:
s3:
Expand Down