MapleStory Finger Point

๐ŸŸค JAVA/๐ŸŸค Spring

[Spring Security] ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” ๊ตฌํ˜„

HYEJU01 2024. 12. 4. 19:32

( ์ œ๊ฐ€ ์ž‘์—…ํ–ˆ๋˜  ํ”„๋กœ์ ํŠธ ์ฝ”๋“œ ๊ธฐ๋ฐ˜์œผ๋กœ ์„ค๋ช…ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.) 

 

 

์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™”์— ๊ด€ํ•œ ์ด๋ก ์€ ์ด์ชฝ ๊ฒŒ์‹œ๋ฌผ ์ฐธ๊ณ  !

 

https://hyejux.tistory.com/801

 

[Spring Security] BCrypt ํ•ด์‹œ ํ•จ์ˆ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜

Spring Security ์—์„œ๋Š” BCryptPasswordEncoder ๋ผ๋Š” ํด๋ž˜์Šค๋ฅผ ์ œ๊ณตํ•˜๋Š”๋ฐ์ด ํด๋ž˜์Šค๋Š” ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์•”ํ˜ธํ™”ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค. ์ด๋•Œ ์•”ํ˜ธํ™” ๋ฐฉ์‹์„ BCrypt ํ•ด์‹œ ํ•จ์ˆ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์‚ฌ์šฉํ•˜๋Š”๋ฐBCrypt ํ•ด์‹œ ํ•จ์ˆ˜ ์•Œ๊ณ 

hyejux.tistory.com

 

https://hyejux.tistory.com/802

 

[Spring Security] BCryptPasswordEncoder ํด๋ž˜์Šค

[ ์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ ๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” ] BCryptPasswordEncoder ๋Š” ์Šคํ”„๋ง ์‹œํ๋ฆฌํ‹ฐ(ํ”„๋ ˆ์ž„์›Œํฌ) ์—์„œ ์ œ๊ณตํ•˜๋Š” ํด๋ž˜์Šค ๋‹จ๋ฐฉํ–ฅ ํ•ด์‹œ ํ•จ์ˆ˜์ธ BCrypt ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.BCrypt ์˜ ๊ฒฝ์šฐ์—๋Š”  ์†”ํŠธ(salt) ๋ฅผ ๋ถ€์—ฌํ•˜์—ฌ

hyejux.tistory.com

 


 

๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™” ๊ตฌํ˜„

`BCryptPasswordEncoder` ํด๋ž˜์Šค์˜ 'encode' ๋ฉ”์„œ๋“œ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ„ํŽธํ•˜๊ฒŒ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์•”ํ˜ธํ™” ํ•  ์ˆ˜ ์žˆ๋‹ค.

 @Autowired
  BCryptPasswordEncoder bCryptPasswordEncoder;

.
.
.

@Override
  public void employeeUpdateMypagePw(EmployeeDTO dto) {
    if (dto.getEmployeePw() != null) {
      dto.setEmployeePw(bCryptPasswordEncoder.encode(dto.getEmployeePw()));
    }
    employeeMapper.employeeUpdateMypagePw(dto);
  }

 

 

์ง์› ๋“ฑ๋ก

 

 

 

DB ์—์„œ ํ™•์ธ

 

 

์•”ํ˜ธํ™” ๋œ ๊ฐ’์ด ๋“ค์–ด๊ฐ„ ๊ฑธ ํ™•์ธ ํ•  ์ˆ˜ ์žˆ๋‹ค.