티스토리 뷰
Spring Security : Web MVC + Security + JDBC - Password Encyption 사용하기
Korean Eagle 2020. 5. 18. 13:121. 스프링 Security는 hashing(변환) 알고리즘으로 bcrypt을 권장하고 있다. 자세한 건 아래 링크 참조
1-1 단방향 hasning이다. 즉 암호화 된 값으로 원래값 복원이 불가능하다.
1-2 추가적인 보호를 위해 hashing 할때 랜덤 값(salt)을 추가하여 사용한다.
1-3 BCypt의 장점에 대한 글이다.
1-4 Salited Password Hashing에 대한 내용이다.
2. BCrypt 사용 방법
2-1 별도의 웹사이트에서 변환한 값을 저장하는 방법
2-1-0 Bcrypt hashing값을 구하는 프로그램에서 hash값을 받아서 데이터베이스에 저장한다.
2-2 자바 코드로 암호화를 수행하는 방법
2-3 데이터베이스에 저장할 때 {bcrypt}hashedpassword 형식으로 저장한다. {noop}은 plain text를 사용할 때 지정한다.
2-4 bcrypt는 단방향 hasing이므로 처리된 값만 있으면 된다.
2-4-1 로그인 시에 사용자가 입력한 값을 받아서 {op} 를 확인하고
2-4-2 사용자가 입력한 plain text을 데이터베이스에 저장된 값에서 salt를 추출하여 hashing한 후
2-4-3 양 쪽을 비교하여 일치하면 인증이 성공된다.
3. 데이터베이스 수정하기
3-1 password를 저장하는 필드를 68글자로 수정한다. {bcrypt}가 8글자이고 hash된 값의 길이가 60글자 고정이다.
3-2 아래는 바꾸는 DDL이다.
alter table spring_security.users modify column password varchar(68)
3-3 생성한 bcrypt를 가지고 데이터베이스에 저장한다.
3-3-1 아래는 username이 pilseong이고 password도 pilseong이다.
update users
set password="{bcrypt}$2a$10$BeFxx1Rh2OlFPPGrOcZVuO801xaUvG45NKppU8F7mgr0/g4GprUEK"
where username="pilseong"
4. 소스코드는 변경 사항이 전혀 없다.
4-1 데이터베이스 password에 저장된 {bcrypt} 부분을 읽고 어떤 방식으로 검증해야 할지 Spring Security가 판단한다.
'Spring > Spring Security' 카테고리의 다른 글
Spring Security : 스프링 보안의 구조 - 1 인증 (0) | 2020.06.30 |
---|---|
Spring Security : WEB + Security - Basic Authentication Entry point 설정(인증 실패 메시지 변경) (1) | 2020.05.26 |
Spring Security : Web MVC + Security + JDBC 으로 인증 구현하기 (0) | 2020.05.17 |
Spring Security : Web MVC + Security - Role에 따라 내용 보여주기 (0) | 2020.05.17 |
Spring Security : Web MVC + Security - 접근 거부 Custom 페이지 생성 (0) | 2020.05.17 |
- Total
- Today
- Yesterday
- 도커 개발환경 참고
- AWS ARN 구조
- Immuability에 관한 설명
- 자바스크립트 멀티 비동기 함수 호출 참고
- WSDL 참고
- SOAP 컨슈머 참고
- MySql dump 사용법
- AWS Lambda with Addon
- NFC 드라이버 linux 설치
- electron IPC
- mifare classic 강의
- go module 관련 상세한 정보
- C 메모리 찍어보기
- C++ Addon 마이그레이션
- JAX WS Header 관련 stackoverflow
- SOAP Custom Header 설정 참고
- SOAP Custom Header
- SOAP BindingProvider
- dispatcher 사용하여 설정
- vagrant kvm으로 사용하기
- git fork, pull request to the …
- vagrant libvirt bridge network
- python, js의 async, await의 차이
- go JSON struct 생성
- Netflix Kinesis 활용 분석
- docker credential problem
- private subnet에서 outbound IP 확…
- 안드로이드 coroutine
- kotlin with, apply, also 등
- 안드로이드 초기로딩이 안되는 경우
- navigation 데이터 보내기
- 레이스 컨디션 navController
- raylib