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

Feat/infra settings #3

Merged
merged 7 commits into from
Jul 15, 2024
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
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
Loading