Skip to content

Commit

Permalink
[#23] feat: DB 암호화 jasypt 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
hsik0225 committed May 25, 2020
1 parent f1efdf9 commit 5a1b199
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
5 changes: 4 additions & 1 deletion BE/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'org.springframework.boot' version '2.3.0.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'war' //war 설정
id 'war' //war
}

group = 'com.codesquad'
Expand Down Expand Up @@ -36,6 +36,9 @@ dependencies {
// 외부 톰캣 설정
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'

// 암호화
implementation 'com.github.ulisesbocchio:jasypt-spring-boot-starter:3.0.2'

implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ public class AirbnbApplication {
public static void main(String[] args) {
SpringApplication.run(AirbnbApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.codesquad.airbnb.infra.config;

import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JasyptConfig {

String password = System.getenv("JASYPT_PASSWORD");

@Bean("jasyptStringEncryptor")
public StringEncryptor stringEncryptor() {
PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();
SimpleStringPBEConfig config = new SimpleStringPBEConfig();
config.setPassword(password); // 암호화에 사용할 키
config.setAlgorithm("PBEWithMD5AndDES"); //사용할 알고리즘
config.setKeyObtentionIterations("1000");
config.setPoolSize("1");
config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");
config.setStringOutputType("base64");
encryptor.setConfig(config);
return encryptor;
}
}

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.codesquad.airbnb.ui;

import com.codesquad.airbnb.domain.dto.*;
import com.codesquad.airbnb.domain.dto.Confirmation;
import com.codesquad.airbnb.infra.dao.ReservationDAO;
import com.codesquad.airbnb.infra.dao.UtilDAO;
import com.codesquad.airbnb.infra.dao.ViewDAO;
Expand Down
10 changes: 6 additions & 4 deletions BE/src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
spring.profiles=local

# debug
debug=true

# MySQL 접속
# MySQL 접속 (Local 설정)
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost/airbnb?serverTimezone=UTC&characterEncoding=UTF-8
spring.datasource.username=ever
spring.datasource.password=asdqwe1!
spring.datasource.url=ENC(HSjfo6OYwgBwHCc/00w5bbZOxmOQPHQgBOvTG1WU5P1v+4NC2r8QKmiygx1tvQ6l1Ty+XuYnYGT9rlbua2WwbrU9v/Og1TPkTd/bIvFhrBQeZl0Pjxr0xQ==)
spring.datasource.username=ENC(/5pFz7soRZT+On8AeVz8hQ==)
spring.datasource.password=ENC(CSt6010jO5jxYaOOwIE1TWHdaVqE9aqw)

spring.datasource.platform=mysql

Expand Down

0 comments on commit 5a1b199

Please sign in to comment.