Spring Security
-
스프링 시큐리티 자동로그인 Remember-me 안될 때 해결방법Spring Security 2023. 11. 5. 21:05
일반적인 스프링시큐리티 자동로그인 설정을 하였지만 여러 문제가 발생 대표적인 문제는 브라우저에 remember-me 쿠키가 생성 안되는 문제다. 1. 시큐리티 설정파일에 SecurityService를 @Autowired로 의존성을 주입시킨다. SecurityConfig.java @EnableWebSecurity public class SecurityConfig { //스프링에서 제공하는 UserDetails 서비스의 loadUserByUsername 메소드를 구현한 서비스 @Autowired private SecurityService securityService; @Bean public SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws ..
-
스프링 시큐리티 중복로그인 안될 때 해결방법Spring Security 2023. 11. 3. 10:44
일반적인 스프링시큐리티 중복로그인 설정을 하였지만 여러 문제가 발생 1. 서로 다른 브라우저로 동일회원 로그인시 로그인처리가 되는 문제 2. 로그아웃하고 로그인하면 Maximum sessions of 1 for this principal exceeded 에러 발생 3. 브라우저를 강제로 종료후 다시 로그인하면 Maximum sessions of 1 for this principal exceeded 에러 발생 1. 시큐리티 설정파일에 ServletListenerRegistrationBean, SessionRegistry를 빈으로 등록한다. SecurityConfig.java @EnableWebSecurity public class SecurityConfig { //추가 @Bean ServletListene..
-
스프링부트 스프링시큐리티 연동하기(4) 커스텀login.jsp/join.jsp/home.jspSpring Security 2019. 6. 29. 21:46
1.시큐리티 커스텀 로그인 login.jsp 작성 (login.jsp) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 로그인 로그인 --%> 아이디 패스워드 아이디 기억하기 로그인 $(document).ready(function(){ alert('${msg}'); }); ccs는 부트스트랩을 사용하였고 form action 주소,id,password input name은 config에 설정한 로그인 프로세스를 수행하는 url을 적었다. 2.회원가입 join.jsp 작성 (jo..
-
스프링부트 스프링시큐리티 연동하기(3) WebSecurityConfigurerAdapter/LoginControllerSpring Security 2019. 6. 23. 20:52
1.SecurityConfig.java 작성 (SecurityConfig.java) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 package com.devmk.test.security.config; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.secur..
-
스프링부트 스프링시큐리티 연동하기(2) UserDetailsService/AuthenticationProviderSpring Security 2019. 6. 21. 22:46
DB에서 유저 정보를 직접 가져오는 인터페이스를 스프링 시큐리티에서 제공하는 UserDetailsService 인터페이스로 구현 하겠다. 1. UserDetailsService 상속 받은 SecurityService.java 인터페이스를 작성한다. (SecurityService.java) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 package com.devmk.test.security.service; import java.util.Collection; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core...
-
스프링부트 스프링시큐리티 연동하기(1) Gradle/Mybatis/OracleSpring Security 2019. 6. 15. 23:27
스프링부트로 스프링시큐리티 연동하는 예제가 별로 없어서 포스팅을 하게 되었다. (일반 xml로 하는 연동과 별반 차이는 없다..) 개발 사양은 다음과 같다. SpringBoot 버전 2.x / Gradle 버전 3.x / jdk 1.8 / Srping 버전 5.x / Spring Security 버전 5.x / 오라클11g xe 나도 스프링 시큐리티를 잘 모르지만 복습차원에서 비교적 간단하게 스프링시큐리티를 구현하겠다. 1. 스프링부트 프로젝트를 Gradle 빌드 타입으로 생성한다. 2. 프로젝트가 생성되면 build.gradle파일에 필요한 dependencies를 추가해야 한다. (build.gradle) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21..