인증번호 적용시 암호화
This commit is contained in:
@@ -38,14 +38,12 @@ public class AuthNumberServiceImpl implements AuthNumberService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 이메일 인증도 가능하도록 개선
|
|
||||||
* @param recipientKey
|
* @param recipientKey
|
||||||
* @param msgType
|
* @param msgType
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(noRollbackFor = AuthNumberException.class)
|
@Transactional(noRollbackFor = AuthNumberException.class)
|
||||||
public void sendRequestAuthNumber(String recipientKey, String msgType) {
|
public void sendRequestAuthNumber(String recipientKey, String msgType) {
|
||||||
// TODO: 이메일 인증도 가능하도록 개선
|
|
||||||
logger.info("Sending auth number to: {} via {}", recipientKey, msgType);
|
logger.info("Sending auth number to: {} via {}", recipientKey, msgType);
|
||||||
|
|
||||||
validateResendTime(recipientKey);
|
validateResendTime(recipientKey);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class AuthNumberStorage {
|
|||||||
|
|
||||||
public void saveAuthNumber(String recipientKey, String authNumber, LocalDateTime expiresAt) {
|
public void saveAuthNumber(String recipientKey, String authNumber, LocalDateTime expiresAt) {
|
||||||
|
|
||||||
Optional<TwoFactorAuth> exist = twoFactorAuthRepository.findById(recipientKey);
|
Optional<TwoFactorAuth> exist = twoFactorAuthRepository.findByRecipient(recipientKey);
|
||||||
if (exist.isPresent()) {
|
if (exist.isPresent()) {
|
||||||
TwoFactorAuth old = exist.get();
|
TwoFactorAuth old = exist.get();
|
||||||
old.setAuthNumber(authNumber);
|
old.setAuthNumber(authNumber);
|
||||||
@@ -33,7 +33,7 @@ public class AuthNumberStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Optional<TwoFactorAuth> getAuthNumber(String recipientKey) {
|
public Optional<TwoFactorAuth> getAuthNumber(String recipientKey) {
|
||||||
return twoFactorAuthRepository.findById(recipientKey);
|
return twoFactorAuthRepository.findByRecipient(recipientKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAuthNumber(String recipientKey) {
|
public void deleteAuthNumber(String recipientKey) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package com.eactive.apim.portal.apps.auth.service;
|
package com.eactive.apim.portal.apps.auth.service;
|
||||||
|
|
||||||
import com.eactive.apim.portal.portaluser.event.RequestAuthNumberEvent;
|
import com.eactive.apim.portal.portaluser.event.UserVerificationMobilePhoneEvent;
|
||||||
import com.eactive.apim.portal.template.service.MessageHandlerService;
|
import com.eactive.apim.portal.template.service.MessageHandlerService;
|
||||||
import com.eactive.apim.portal.template.service.MessageRecipient;
|
import com.eactive.apim.portal.template.service.MessageRecipient;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -29,6 +29,17 @@ public class MessageSender {
|
|||||||
HashMap<String, Object> params = new HashMap<>();
|
HashMap<String, Object> params = new HashMap<>();
|
||||||
params.put("authNumber", authNumber);
|
params.put("authNumber", authNumber);
|
||||||
|
|
||||||
messageHandlerService.publishEvent(RequestAuthNumberEvent.KEY, recipient, params);
|
|
||||||
|
// 이메일, SMS MESSAEG_CODE 다름 처리
|
||||||
|
String messageCode = "";
|
||||||
|
if ("email".equalsIgnoreCase(msgType)) {
|
||||||
|
messageCode = "USER_VERIFICATION_EMAIL";
|
||||||
|
} else if ("sms".equalsIgnoreCase(msgType)) {
|
||||||
|
messageCode = "USER_VERIFICATION_MOBILEPHONE";
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Unsupported message type: " + msgType);
|
||||||
|
}
|
||||||
|
|
||||||
|
messageHandlerService.publishEvent(UserVerificationMobilePhoneEvent.KEY, recipient, params);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
|||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,12 +47,14 @@ import java.util.HashMap;
|
|||||||
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
|
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PortalConfigPortalDatasource {
|
public class PortalConfigPortalDatasource {
|
||||||
|
private final EmsDatasourceProperties emsDatasourceProperties;
|
||||||
|
private final Environment env;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private EmsDatasourceProperties emsDatasourceProperties;
|
|
||||||
|
|
||||||
@Autowired
|
public PortalConfigPortalDatasource(EmsDatasourceProperties emsDatasourceProperties, Environment env) {
|
||||||
Environment env;
|
this.emsDatasourceProperties = emsDatasourceProperties;
|
||||||
|
this.env = env;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@@ -130,6 +134,7 @@ public class PortalConfigPortalDatasource {
|
|||||||
properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle12cDialect");
|
properties.put("hibernate.dialect", "org.hibernate.dialect.Oracle12cDialect");
|
||||||
properties.put("hibernate.format_sql", "true");
|
properties.put("hibernate.format_sql", "true");
|
||||||
properties.put("hibernate.physical_naming_strategy", "com.eactive.apim.portal.common.entity.CustomPhysicalNamingStrategy");
|
properties.put("hibernate.physical_naming_strategy", "com.eactive.apim.portal.common.entity.CustomPhysicalNamingStrategy");
|
||||||
|
|
||||||
// properties.put("hibernate.show_sql", "true");
|
// properties.put("hibernate.show_sql", "true");
|
||||||
properties.put("hibernate.transaction.jta.platform", "org.hibernate.engine.transaction.jta.platform.internal.AtomikosJtaPlatform");
|
properties.put("hibernate.transaction.jta.platform", "org.hibernate.engine.transaction.jta.platform.internal.AtomikosJtaPlatform");
|
||||||
properties.put("hibernate.use_sql_comments", "true");
|
properties.put("hibernate.use_sql_comments", "true");
|
||||||
@@ -148,6 +153,28 @@ public class PortalConfigPortalDatasource {
|
|||||||
properties.put("org.hibernate.envers.revision_number_field_name", "id");
|
properties.put("org.hibernate.envers.revision_number_field_name", "id");
|
||||||
properties.put("org.hibernate.envers.store_data_at_delete", "true");
|
properties.put("org.hibernate.envers.store_data_at_delete", "true");
|
||||||
|
|
||||||
|
// 개발 환경용
|
||||||
|
if (env.matchesProfiles("dev", "local")) {
|
||||||
|
properties.put("hibernate.hbm2ddl.auto", "validate");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// DDL 생성용
|
||||||
|
if (env.matchesProfiles("ddl_generate")) {
|
||||||
|
log.warn("Spring profile 내 ddl_generate 지정됨 / 로컬 개발용");
|
||||||
|
|
||||||
|
String filePath = "D:\\kjb-logs\\devSvr99\\portal-schema_ddl-" +
|
||||||
|
DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss").format(LocalDateTime.now()) + ".sql";
|
||||||
|
|
||||||
|
properties.put("hibernate.hbm2ddl.auto", "validate");
|
||||||
|
properties.put("javax.persistence.schema-generation.create-source", "metadata");
|
||||||
|
properties.put("javax.persistence.schema-generation.scripts.action", "update");
|
||||||
|
// properties.put("javax.persistence.schema-generation.scripts.action", "create");
|
||||||
|
properties.put("javax.persistence.schema-generation.scripts.create-target", filePath);
|
||||||
|
|
||||||
|
log.info("DDL script 생성 : {}", filePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return builder
|
return builder
|
||||||
.dataSource(dataSource)
|
.dataSource(dataSource)
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.eactive.apim.portal.tools;
|
||||||
|
|
||||||
|
import com.eactive.apim.portal.PortalApplication;
|
||||||
|
import org.springframework.boot.WebApplicationType;
|
||||||
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DDL SQL 생성용으로 HTTP 서버는 구동하지 않음
|
||||||
|
*/
|
||||||
|
public class HibernateSqlGenerator {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
ConfigurableApplicationContext context =
|
||||||
|
new SpringApplicationBuilder(PortalApplication.class)
|
||||||
|
.web(WebApplicationType.NONE)
|
||||||
|
.profiles("ddl_generate", "gf63")
|
||||||
|
.run(args);
|
||||||
|
context.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -100,12 +100,25 @@
|
|||||||
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" additivity="false">
|
<logger name="org.hibernate.type.descriptor.sql.BasicBinder" level="TRACE" additivity="false">
|
||||||
<appender-ref ref="HIBERNATE_APPENDER" />
|
<appender-ref ref="HIBERNATE_APPENDER" />
|
||||||
</logger>
|
</logger>
|
||||||
|
<logger name="org.hibernate.engine.jdbc.spi.SqlExceptionHelper" additivity="false">
|
||||||
|
<appender-ref ref="HIBERNATE_APPENDER" />
|
||||||
|
></logger>
|
||||||
|
|
||||||
<logger name="com.eactive.eapim" level="DEBUG" additivity="false"/>
|
<logger name="com.eactive.eapim" level="DEBUG" additivity="false"/>
|
||||||
|
<logger name="kjb.safedb" level="DEBUG" additivity="false">
|
||||||
|
<appender-ref ref="ROLLING"/>
|
||||||
|
<appender-ref ref="CONSOLE"/>
|
||||||
|
</logger>
|
||||||
|
|
||||||
|
|
||||||
<root level="INFO">
|
<root level="INFO">
|
||||||
<appender-ref ref="ROLLING"/>
|
<appender-ref ref="ROLLING"/>
|
||||||
<appender-ref ref="CONSOLE"/>
|
<appender-ref ref="CONSOLE"/>
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
<!-- <root level="DEBUG">-->
|
||||||
|
<!-- <appender-ref ref="ROLLING"/>-->
|
||||||
|
<!-- <appender-ref ref="CONSOLE"/>-->
|
||||||
|
<!-- </root>-->
|
||||||
</springProfile>
|
</springProfile>
|
||||||
</configuration>
|
</configuration>
|
||||||
Reference in New Issue
Block a user