Skip to content

Commit

Permalink
Merge pull request #3 from LikeLion-Hackathon-T1/feat/infra-settings
Browse files Browse the repository at this point in the history
Feat/infra settings
  • Loading branch information
Jeongh00 authored Jul 15, 2024
2 parents acc44b1 + bb7aaca commit c6ff736
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.likelion.apimodule.security.config;

import com.likelion.apimodule.security.util.JwtUtil;
import com.likelion.commonmodule.exception.jwt.JwtAccessDeniedHandler;
import com.likelion.commonmodule.exception.jwt.JwtAuthenticationEntryPoint;
import com.likelion.commonmodule.redis.util.RedisUtil;
import com.likelion.commonmodule.security.config.CorsConfig;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
Expand All @@ -17,9 +15,6 @@
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.web.SecurityFilterChain;

import java.util.Arrays;
import java.util.stream.Stream;

@Configuration
@EnableWebSecurity
@RequiredArgsConstructor
Expand Down Expand Up @@ -63,8 +58,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// .requestMatchers("/swagger-ui/**").permitAll()
// .requestMatchers("/api-docs").permitAll()
// .requestMatchers("/v1/users/login/**").permitAll()
.requestMatchers("/v1/api/**").authenticated()
.anyRequest().permitAll()
.requestMatchers("/v1/api/**").authenticated()
.anyRequest().permitAll()
);

// Jwt Filters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
@Configuration
public class RedisConfig {

@Value("${spring.database.redis.host}")
@Value("${spring.data.redis.host}")
private String redisHost;

@Value("${spring.database.redis.port}")
@Value("${spring.data.redis.port}")
private int redisPort;

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class CorsConfig implements WebMvcConfigurer {
Expand All @@ -17,15 +19,16 @@ public static CorsConfigurationSource apiConfigurationSource() {

ArrayList<String> allowedOriginPatterns = new ArrayList<>();
allowedOriginPatterns.add("http://localhost:8080");
allowedOriginPatterns.add("https://localhost:8080");
allowedOriginPatterns.add("http://localhost:3000");
allowedOriginPatterns.add("https://www.sponus.co.kr");

ArrayList<String> allowedHttpMethods = new ArrayList<>();
allowedHttpMethods.add("GET");
allowedHttpMethods.add("POST");
allowedOriginPatterns.add("https://localhost:3000");
allowedOriginPatterns.add("https://syluv.link");

configuration.setAllowedOrigins(allowedOriginPatterns);
configuration.setAllowedMethods(allowedHttpMethods);
configuration.setAllowedMethods(List.of("HEAD", "POST", "GET", "DELETE", "PUT", "OPTIONS", "PATCH"));
configuration.setAllowedHeaders(List.of("*"));
configuration.setAllowCredentials(true);
configuration.setExposedHeaders(List.of(HttpHeaders.LOCATION, HttpHeaders.SET_COOKIE));

UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
Expand Down
6 changes: 3 additions & 3 deletions common-module/src/main/resources/application-redis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
spring:
database:
data:
redis:
host: localhost
port: 6379
host: redis
port: 6379
2 changes: 1 addition & 1 deletion core-module/src/main/resources/application-oauth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ spring:
oauth:
kakao:
iss: https://kauth.kakao.com
client-id: 3eb7359e3155987d42f0855e0319af33
client-id: d0b1a662419cddfea6be47ef2d84d2ee
7 changes: 5 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
version: "3.8"
services:
redis:
container_name: syluv-redis
container_name: redis
image: redis:latest
hostname: redis
ports:
- "6379:6379"
networks:
- db_network
restart: always

koa-app:
container_name: syluv-app
build: .
Expand All @@ -23,6 +25,7 @@ services:
- redis
networks:
- db_network

networks:
db_network:
driver: bridge
driver: bridge

0 comments on commit c6ff736

Please sign in to comment.