본문 바로가기

Spring Security

(3)
[Spring Boot] Spring Security JWT Token JWT(Json Web Token) Json 객체를 통해 안전하게 정보를 전송할 수 있는 웹표준 Json 객체를 암호화하여 만든 String 값 기본적으로 암호화가 되어 있어 변조하기 어려움 JWT를 이용하여 로그인 구현 1. gradle dependency 추가 - build.gradle dependencies { implementation 'org.springframework.boot:spring-boot-starter-security' implementation 'io.jsonwebtoken:jjwt:0.9.1' } 2. 비밀키 설정 - application.properties jwt.secret=thisiskey 3. JwtTokenProvider 생성 Jwt 생성하고, 유효성을 검증하는 컴포넌트..
[Spring Boot] Spring Security PasswordEncoder PasswordEncoder Spring Sercurity에서 지원하는 비밀번호 단방향 암호화 인터페이스 public interface PasswordEncoder { // 비밀번호 암호화 String encode(CharSequence rawPassword); // 암호화되지 않은 비밀번호(raw)와 암호화된 비밀번호(encoded)가 일치하는지 비교 boolean matches(CharSequence rawPassword, String encodedPassword); // 암호화된 비밀번호를 다시 암호화하고자 할 경우 return true default boolean upgradeEncoding(String encodedPassword) { return false; } } BcryptPasswordE..
[Spring Boot] thymeleaf-layout-dialect 적용하기 thymeleaf view template engine 서버상에서 동작하지 않아도 됨 (Natural Template) 순수 HTML 구조를 유지 Spring에서도 공식적으로 thymeleaf 사용을 권장하고 있음 thymeleaf-layout-dialect thymleaf에서 제공하는 layout 라이브러리 spring boot에 thymeleaf-layout-dialect 적용하기 1. gradle dependency 추가 - build.gradle dependencies { implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5' implementation 'org.springframework.boot:spring-boot-sta..