-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from wooyeon0626/feature/join
[REFACTOR] 회원가입 과정 중, DB에 insert하는 최종 비밀번호 암호화 방법을 SHA256+salt -> PassswordEncoder(Spring Security)로 변경 (로그인 비밀번호를 PasswordEncoder 사용으로 인한 충돌 수정)
- Loading branch information
Showing
4 changed files
with
66 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
//package com.wooyeon.yeon.user; | ||
// | ||
//import com.wooyeon.yeon.user.domain.User; | ||
//import com.wooyeon.yeon.user.repository.UserRepository; | ||
//import org.junit.jupiter.api.Test; | ||
//import org.springframework.beans.factory.annotation.Autowired; | ||
//import org.springframework.boot.test.context.SpringBootTest; | ||
//import org.springframework.security.crypto.password.PasswordEncoder; | ||
// | ||
//@SpringBootTest | ||
//public class UserTest { | ||
// @Autowired | ||
// private UserRepository userRepository; | ||
// @Autowired | ||
// private PasswordEncoder passwordEncoder; | ||
package com.wooyeon.yeon.user; | ||
|
||
import com.wooyeon.yeon.user.domain.User; | ||
import com.wooyeon.yeon.user.repository.UserRepository; | ||
import com.wooyeon.yeon.user.service.UserService; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.security.crypto.password.PasswordEncoder; | ||
|
||
import java.util.UUID; | ||
|
||
@SpringBootTest | ||
public class UserTest { | ||
@Autowired | ||
private UserRepository userRepository; | ||
@Autowired | ||
private PasswordEncoder passwordEncoder; | ||
@Autowired | ||
private UserService userService; | ||
// | ||
// @Test | ||
// public void createUser() { | ||
|
@@ -25,4 +30,29 @@ | |
// userRepository.save(user); | ||
// } | ||
// | ||
//} | ||
// passwordEncoder 사용 | ||
/*@Test | ||
public void pwEncoderUser() { | ||
User user = User.builder() | ||
.email("[email protected]") | ||
.userCode(UUID.randomUUID()) | ||
.password(passwordEncoder.encode("1234")) | ||
.build(); | ||
userRepository.save(user); | ||
}*/ | ||
|
||
// sha256 + salt 사용 | ||
/*@Test | ||
public void shaUser() { | ||
String pw = userService.encryptSha256("1234"); | ||
String salt = userService.createSalt(); | ||
String fin = userService.encryptSha256("1234"+salt); | ||
User usersh = User.builder() | ||
.email("[email protected]") | ||
.userCode(UUID.randomUUID()) | ||
.password("{bcrypt}$2a$10$"+salt+fin) | ||
.salt(salt) | ||
.build(); | ||
userRepository.save(usersh); | ||
}*/ | ||
} |