SPRING/스프링 시큐리티
-
세션 정책 및 고정세션 공격방지SPRING/스프링 시큐리티 2021. 8. 3. 10:51
스프링 시큐리티에서는 세션 관련 정책을 설정할 수 있다. 하나의 계정에 최대 몇개의 세션을 유지할 것인지, 새로운 사용자가 접근하면 로그인을 금지할 것인지 아니면 기존 사용자를 로그아웃 시킬 것인 지 등 정책 설정이 필요하다. @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired UserDetailsService userDetailsService; @Override protected void configure(HttpSecurity http) throws Exception { // 모든 리소스에 대한 인증완료시 접근 허용 http .authorizeReques..
-
remember-meSPRING/스프링 시큐리티 2021. 8. 1. 17:24
1. 세션이 만료되고 브라우저가 종료된 후에도 어플리케이션이 사용자를 기억하는 기능 2. Remember-Me 쿠키에 대한 Http 요청을 확인한 후 토큰 기반 인증을 사용해 유효성을 검사하고 토큰이 검증되면 사용자는 로그인이 됨. @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired UserDetailsService userDetailsService; @Override protected void configure(HttpSecurity http) throws Exception { // 모든 리소스에 대한 인증완료시 접근 허용 http .authorizeReq..
-
로그아웃SPRING/스프링 시큐리티 2021. 8. 1. 16:04
아래와 같이 로그아웃 관련 설정을 할 수 있다. @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { // 모든 리소스에 대한 인증완료시 접근 허용 http .authorizeRequests() .anyRequest().authenticated(); // form Login 사용 http .formLogin(); // LogOut http .logout() // 로그아웃 처리 .logoutUrl("/logout") // 로그아웃 처리 URL .logo..
-
FORM 인증 - 기본SPRING/스프링 시큐리티 2021. 8. 1. 15:21
기본적인 Form 인증 관련 Config Class @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { // 모든 리소스에 대한 인증완료시 접근 허용 http .authorizeRequests() .anyRequest().authenticated(); // form Login 사용 http.formLogin() //.loginPage("/loginPage") // 사용자 정의 로그인 페이지 .defaultSuccessUrl("/") // 로그인 성공..
-
Security Configuration 클래스 기본 설정SPRING/스프링 시큐리티 2021. 8. 1. 11:37
Security Configuration(설정) 관련 클래스는 WebSecurityConfigurerAdapter를 상속하고, 세부적인 보안 기능을 설정할 수 있는 HttpSecurity API를 제공한다, HttpSecurity API는 크게 인증 API, 인가 API를 제공한다. 인증 : 계정인증에 대한 설정 인가 : 계정의 Role, 권한에 대한 설정 @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { // 모든 리소스에 대한 인증완료시 접근 ..
-
의존성 추가 및 기본 세팅SPRING/스프링 시큐리티 2021. 8. 1. 02:35
스프링 시큐리티를 추가하기 위해서는 아래와 같은 의존성 추가가 필요하다. org.springframework.boot spring-boot-starter-security 로그인 후 이동할 기본 페이지 작성 @RestController public class SecurityController { @GetMapping("/") public String index() { return "home"; } } 스프링 시큐리티 의존성을 추가한 것 만으로도 브라우저에서 웹페이지를 띄우면 아래와 같은 화면이 나타난다. 별다른 세팅을 하지 않았다면, 아이디는 user 비밀번호는 콘솔창에 나타난 비밀번호를 입력하면 정상적으로 루트 페이지 이동이 가능하다.. 스프링 시큐리티의 의존성 추가 시 - 서버가 기동되면 스프링 시큐리..