기본구성 동작 처리
This commit is contained in:
@@ -78,6 +78,9 @@ dependencies {
|
||||
implementation 'redis.clients:jedis:4.3.1'
|
||||
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
|
||||
|
||||
// Playwright (브라우저 자동화)
|
||||
implementation 'com.microsoft.playwright:playwright:1.41.0'
|
||||
|
||||
compileOnly 'org.projectlombok:lombok'
|
||||
// PostgreSQL
|
||||
runtimeOnly 'org.postgresql:postgresql'
|
||||
|
||||
38
src/main/java/com/domain/service/LogoutService.java
Normal file
38
src/main/java/com/domain/service/LogoutService.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.domain.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.web.authentication.logout.LogoutHandler;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.domain.dao.TokenMapper;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class LogoutService implements LogoutHandler {
|
||||
private final TokenMapper tokenMapper;
|
||||
|
||||
@Override
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, org.springframework.security.core.Authentication authentication) {
|
||||
final String authHeader = request.getHeader("Authorization");
|
||||
final String jwt;
|
||||
if (authHeader == null ||!authHeader.startsWith("Bearer ")) {
|
||||
return;
|
||||
}
|
||||
jwt = authHeader.substring(7);
|
||||
var storedToken = tokenMapper.findByToken(jwt)
|
||||
.orElse(null);
|
||||
if (storedToken != null) {
|
||||
storedToken.setExpired(true);
|
||||
storedToken.setRevoked(true);
|
||||
tokenMapper.updateToken(storedToken);
|
||||
SecurityContextHolder.clearContext();
|
||||
}
|
||||
|
||||
log.info("logout User: {}", authentication.getName());
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.global.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
@@ -51,9 +50,10 @@ public class AuthenticationConfig {
|
||||
}))
|
||||
.authorizeHttpRequests()
|
||||
.requestMatchers(
|
||||
// "/api/v1/auth/login",
|
||||
// "/api/v1/auth/register",
|
||||
"/api/v1/**"
|
||||
"/api/v1/auth/login",
|
||||
"/api/v1/auth/register",
|
||||
// "/api/v1/**",
|
||||
"/api/v2/**"
|
||||
).permitAll() // login,register은 언제나 가능
|
||||
// .requestMatchers(HttpMethod.POST,"/api/v1/**").authenticated()
|
||||
.anyRequest()
|
||||
|
||||
82
src/main/java/com/global/configuration/MongodbConfig.java
Normal file
82
src/main/java/com/global/configuration/MongodbConfig.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package com.global.configuration;
|
||||
|
||||
import com.mongodb.ConnectionString;
|
||||
import com.mongodb.MongoClientSettings;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
import com.mongodb.repository.MongoRepository;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.mongodb.MongoDatabaseFactory;
|
||||
import org.springframework.data.mongodb.core.MongoTemplate;
|
||||
import org.springframework.data.mongodb.core.SimpleMongoClientDatabaseFactory;
|
||||
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableMongoRepositories(basePackageClasses = MongoRepository.class, basePackages = "com.mongodb.repository", mongoTemplateRef = "mongodbTemplate")
|
||||
public class MongodbConfig {
|
||||
|
||||
@Value("${mongodb.host}")
|
||||
String businessLogHost;
|
||||
@Value("${mongodb.username}")
|
||||
String username;
|
||||
@Value("${mongodb.password}")
|
||||
String password;
|
||||
@Value("${mongodb.db}")
|
||||
String db;
|
||||
|
||||
@Bean(name = "mongodbClient")
|
||||
public MongoClient mongoStatClient() {
|
||||
String encodePassword = URLEncoder.encode(password, StandardCharsets.UTF_8);
|
||||
String auth = username.isEmpty() ? "" : String.format("%s:%s@",username, encodePassword);
|
||||
String connection;
|
||||
connection = String.format("mongodb://%s%s/?authSource=%s", auth, businessLogHost, db);
|
||||
|
||||
MongoClientSettings settings = MongoClientSettings.builder()
|
||||
.applyConnectionString(new ConnectionString(connection))
|
||||
// 커넥션 풀 설정
|
||||
.applyToConnectionPoolSettings(builder -> {
|
||||
builder.maxSize(100) // 최대 연결 수
|
||||
.minSize(10) // 최소 연결 수
|
||||
.maxWaitTime(30, TimeUnit.SECONDS) // 연결 대기 시간
|
||||
.maxConnectionLifeTime(0, TimeUnit.MILLISECONDS) // 연결 최대 수명 (0 = 무제한)
|
||||
.maxConnectionIdleTime(0, TimeUnit.MILLISECONDS); // 연결 최대 유휴 시간 (0 = 무제한)
|
||||
})
|
||||
// 소켓 설정
|
||||
.applyToSocketSettings(builder -> {
|
||||
builder.connectTimeout(10, TimeUnit.SECONDS) // 연결 타임아웃
|
||||
.readTimeout(0, TimeUnit.MILLISECONDS); // 읽기 타임아웃 (0 = 무제한)
|
||||
})
|
||||
// 서버 선택 설정
|
||||
.applyToServerSettings(builder -> {
|
||||
builder.heartbeatFrequency(10, TimeUnit.SECONDS) // 하트비트 주기
|
||||
.minHeartbeatFrequency(500, TimeUnit.MILLISECONDS); // 최소 하트비트 주기
|
||||
})
|
||||
// 클러스터 설정
|
||||
.applyToClusterSettings(builder -> {
|
||||
builder.serverSelectionTimeout(30, TimeUnit.SECONDS) // 서버 선택 타임아웃
|
||||
.localThreshold(15, TimeUnit.MILLISECONDS); // 로컬 임계값
|
||||
})
|
||||
.build();
|
||||
|
||||
return MongoClients.create(settings);
|
||||
}
|
||||
|
||||
@Bean(name = "mongoFactory")
|
||||
public MongoDatabaseFactory mongoFactory(@Qualifier("mongodbClient") MongoClient mongoClient) {
|
||||
return new SimpleMongoClientDatabaseFactory(mongoClient, db);
|
||||
}
|
||||
|
||||
@Bean(name = "mongodbTemplate")
|
||||
public MongoTemplate mongodbTemplate(@Qualifier("mongoFactory") MongoDatabaseFactory mongoFactory) {
|
||||
return new MongoTemplate(mongoFactory);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(value = "com.domain.dao.admin", sqlSessionFactoryRef = "SqlSessionFactory")
|
||||
@MapperScan(value = "com.domain.dao", sqlSessionFactoryRef = "SqlSessionFactory")
|
||||
@EnableTransactionManagement
|
||||
public class MybatisConfig {
|
||||
@Value("${spring.mybatis.mapper-locations}")
|
||||
|
||||
@@ -44,64 +44,56 @@ public class RedisConfig {
|
||||
@Value("${redis.abort-connect}")
|
||||
private boolean abortConnect;
|
||||
|
||||
@Value("${spring.profiles.active}")
|
||||
private String activeProfile;
|
||||
|
||||
@Bean
|
||||
public JedisConnectionFactory jedisConnectionFactory() {
|
||||
// String activeProfile = System.getProperty("active.profile", "local");
|
||||
log.info("RedisConfig Active profile: {}", activeProfile);
|
||||
|
||||
if(activeProfile.equals("local") || activeProfile.equals("dev")){
|
||||
log.info("RedisConfig local config Set");
|
||||
/// Redis Standalone 설정
|
||||
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration();
|
||||
standaloneConfig.setHostName(host);
|
||||
standaloneConfig.setPort(port);
|
||||
if (password != null && !password.isEmpty()) {
|
||||
standaloneConfig.setPassword(password);
|
||||
}
|
||||
|
||||
JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfig = JedisClientConfiguration.builder();
|
||||
jedisClientConfig.connectTimeout(java.time.Duration.ofMillis(asyncTimeout)); // AsyncTimeout
|
||||
jedisClientConfig.readTimeout(java.time.Duration.ofMillis(syncTimeout)); // SyncTimeout
|
||||
if (ssl) {
|
||||
jedisClientConfig.useSsl();
|
||||
}
|
||||
//if (!abortConnect) { jedisClientConfig.blockOnReconnect(false);}
|
||||
|
||||
return new JedisConnectionFactory(standaloneConfig, jedisClientConfig.build());
|
||||
log.info("RedisConfig local config Set");
|
||||
/// Redis Standalone 설정
|
||||
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration();
|
||||
standaloneConfig.setHostName(host);
|
||||
standaloneConfig.setPort(port);
|
||||
if (password != null && !password.isEmpty()) {
|
||||
standaloneConfig.setPassword(password);
|
||||
}
|
||||
|
||||
log.info("RedisConfig deploy config Set");
|
||||
//cluster로 변경 수정
|
||||
JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||
poolConfig.setMaxTotal(128); // 연결 풀 설정
|
||||
|
||||
// Redis 클러스터 진입점 노드만 지정
|
||||
RedisClusterConfiguration clusterConfig = new RedisClusterConfiguration();
|
||||
clusterConfig.clusterNode(host, port);
|
||||
clusterConfig.setPassword(password); // 패스워드 설정
|
||||
clusterConfig.setMaxRedirects(5);
|
||||
var builder = JedisClientConfiguration.builder();
|
||||
builder.usePooling().poolConfig(poolConfig);
|
||||
if(ssl){
|
||||
builder.useSsl();
|
||||
JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfig = JedisClientConfiguration.builder();
|
||||
jedisClientConfig.connectTimeout(java.time.Duration.ofMillis(asyncTimeout)); // AsyncTimeout
|
||||
jedisClientConfig.readTimeout(java.time.Duration.ofMillis(syncTimeout)); // SyncTimeout
|
||||
if (ssl) {
|
||||
jedisClientConfig.useSsl();
|
||||
}
|
||||
JedisClientConfiguration clientConfig = builder.build();
|
||||
//if (!abortConnect) { jedisClientConfig.blockOnReconnect(false);}
|
||||
|
||||
JedisConnectionFactory factory = new JedisConnectionFactory(clusterConfig, clientConfig);
|
||||
return new JedisConnectionFactory(standaloneConfig, jedisClientConfig.build());
|
||||
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
try {
|
||||
factory.getConnection().ping(); // Redis 서버에 Ping 명령어를 전송해 응답을 확인
|
||||
log.info("Successfully connected to Redis server: {}", factory.getHostName());
|
||||
} catch (Exception e) {
|
||||
log.error("Failed to connect to Redis server: {}", e.getMessage());
|
||||
}
|
||||
|
||||
return factory;
|
||||
// log.info("RedisConfig deploy config Set");
|
||||
// //cluster로 변경 수정
|
||||
// JedisPoolConfig poolConfig = new JedisPoolConfig();
|
||||
// poolConfig.setMaxTotal(128); // 연결 풀 설정
|
||||
//
|
||||
// // Redis 클러스터 진입점 노드만 지정
|
||||
// RedisClusterConfiguration clusterConfig = new RedisClusterConfiguration();
|
||||
// clusterConfig.clusterNode(host, port);
|
||||
// clusterConfig.setPassword(password); // 패스워드 설정
|
||||
// clusterConfig.setMaxRedirects(5);
|
||||
// var builder = JedisClientConfiguration.builder();
|
||||
// builder.usePooling().poolConfig(poolConfig);
|
||||
// if(ssl){
|
||||
// builder.useSsl();
|
||||
// }
|
||||
// JedisClientConfiguration clientConfig = builder.build();
|
||||
//
|
||||
// JedisConnectionFactory factory = new JedisConnectionFactory(clusterConfig, clientConfig);
|
||||
//
|
||||
// factory.afterPropertiesSet();
|
||||
//
|
||||
// try {
|
||||
// factory.getConnection().ping(); // Redis 서버에 Ping 명령어를 전송해 응답을 확인
|
||||
// log.info("Successfully connected to Redis server: {}", factory.getHostName());
|
||||
// } catch (Exception e) {
|
||||
// log.error("Failed to connect to Redis server: {}", e.getMessage());
|
||||
// }
|
||||
//
|
||||
// return factory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.mongodb.repository;
|
||||
|
||||
|
||||
|
||||
public interface MongoRepository {
|
||||
}
|
||||
@@ -37,12 +37,9 @@ public class DataInitializeHistoryService {
|
||||
private final TransactionIdManager transactionIdManager;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("mongoIndicatorTemplate")
|
||||
@Qualifier("mongodbTemplate")
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
@Value("${amazon.dynamodb.metaTable}")
|
||||
private String dynamodbTableName;
|
||||
|
||||
public <T> List<T> loadHistoryData(LogGenericRequest logGenericRequest, Class<T> class1) {
|
||||
String startTime = logGenericRequest.getStartDt().toString().substring(0, 10);
|
||||
String endTime = logGenericRequest.getEndDt().toString().substring(0, 10);
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class HistoryLogService {
|
||||
@Autowired
|
||||
@Qualifier("mongoIndicatorTemplate")
|
||||
@Qualifier("mongodbTemplate")
|
||||
private MongoTemplate mongoTemplate;
|
||||
|
||||
public <T> List<T> loadHistoryData(HistoryRequest historyRequest, Class<T> class1) {
|
||||
|
||||
@@ -10,9 +10,9 @@ server:
|
||||
spring:
|
||||
datasource:
|
||||
driver-class-name: org.postgresql.Driver
|
||||
url: jdbc:postgresql://localhost:5432/postgres
|
||||
username: postgres
|
||||
password: postgres
|
||||
jdbc-url: jdbc:postgresql://140.238.22.48:5432/postgres
|
||||
username: bcjang
|
||||
password: dlawls051)
|
||||
|
||||
jpa:
|
||||
hibernate:
|
||||
@@ -107,112 +107,25 @@ excel:
|
||||
file-path: D:\caliverse-api/upload/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################################################################################################################################
|
||||
# AWS
|
||||
################################################################################################################################################################################################
|
||||
amazon:
|
||||
dynamodb:
|
||||
# endpoint: http://localhost:8000/
|
||||
|
||||
|
||||
# metaTable: Metaverse-Live
|
||||
aws:
|
||||
# accesskey: ""
|
||||
# secretkey: ""
|
||||
# region: ""
|
||||
accesskey: AKIA4G3CB4Z5T6JUPHJN
|
||||
secretkey: G82Bq5tCUTvSPe9InGayH8kONbtEnLxMrgzrAbCn
|
||||
|
||||
s3:
|
||||
|
||||
|
||||
enabled: true
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################################################################################################################################
|
||||
# RabbitMq
|
||||
################################################################################################################################################################################################
|
||||
rabbitmq:
|
||||
# url: localhost
|
||||
# port: 5672
|
||||
# username: admin
|
||||
# password: admin
|
||||
# ssl: false
|
||||
# dev
|
||||
url: 10.20.20.8
|
||||
|
||||
username: admin
|
||||
password: admin
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
################################################################################################################################################################################################
|
||||
# Mongodb
|
||||
################################################################################################################################################################################################
|
||||
mongodb:
|
||||
host: 10.20.20.8:27017
|
||||
business-log:
|
||||
username: ""
|
||||
password: ""
|
||||
|
||||
indicator:
|
||||
username: ""
|
||||
password: ""
|
||||
|
||||
#local
|
||||
# host: localhost:27017
|
||||
# business-log:
|
||||
# username: ""
|
||||
# password: ""
|
||||
# db: LogDB
|
||||
# indicator:
|
||||
# username: ""
|
||||
# password: ""
|
||||
# db: IndicatorDB
|
||||
#live
|
||||
# host: metaverse-live.7d0do.mongodb.net
|
||||
# business-log:
|
||||
# username: metaverseliverw
|
||||
# password: K1spqwBbHrP2ZSMX
|
||||
# db: BusinessLog-Db-Live
|
||||
# indicator:
|
||||
# username: metaverseliverw
|
||||
# password: K1spqwBbHrP2ZSMX
|
||||
# db: BackOffice-Db-Live
|
||||
host: 140.238.22.48:27017
|
||||
username: bcjang
|
||||
password: dlawls05081)
|
||||
db: myListBridge
|
||||
|
||||
|
||||
################################################################################################################################################################################################
|
||||
# "Redis": "127.0.0.1:6379,password=KT-i5#i%-%LxKfZ5YJj6,AsyncTimeout=30000,SyncTimeout=30000,ssl=false,abortConnect=false",
|
||||
################################################################################################################################################################################################
|
||||
redis:
|
||||
prefix: backOffice
|
||||
# host: localhost
|
||||
# port: 6379
|
||||
# password: KT-i5#i%-%LxKfZ5YJj6
|
||||
# async-timeout: 30000
|
||||
# sync-timeout: 30000
|
||||
# ssl: false
|
||||
# abort-connect: false
|
||||
host: 10.20.20.8
|
||||
prefix: myListBridge
|
||||
host: 140.238.22.48
|
||||
port: 6379
|
||||
password: KT-i5#i%-%LxKfZ5YJj6
|
||||
async-timeout: 30000
|
||||
sync-timeout: 30000
|
||||
ssl: false
|
||||
abort-connect: false
|
||||
|
||||
|
||||
web3:
|
||||
url: https://eco-system-dev-rollup-admin-api.caliverse.io
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user