Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- joinfetch
- 프로젝트생성
- Hibernate
- 대량쿼리
- javascriptcalendar
- 자바서블릿
- jQueryUI
- 제네릭
- JPA
- springflow
- jscalendar
- paging
- LIST
- 페이징
- fullcalendar
- 페치조인
- 스프링데이터흐름
- values()
- 제너릭
- JQuery
- JPQL
- Generic
- fetchjoin
- javaservlet
- 벌크연산
- calendar
- 엔티티직접사용
- jQuery값전송
- namedQuery
- jQuery값전달
Archives
- Today
- Total
가자공부하러!
Spring Security 활용 회원 관리 (2) - 커스텀 로그인 뷰 설정 본문
소스코드 :
참고 : https://a1010100z.tistory.com/entry/Spring-Spring-boot-security-%EB%A1%9C%EA%B7%B8%EC%9D%B8-%EB%B7%B0-%EB%B3%80%EA%B2%BD%ED%95%98%EA%B8%B0%EA%B0%9C%EB%B0%9C%EC%9D%BC%EA%B8%B0A4
1. 로그인 뷰 설정
1. 요약
> WebSecurityConfigurerAdapter를 상속받은 @Configuration 파일에 로그인 뷰 경로 설정
> 컨트롤러 작성
> 뷰 작성
2. SpringSecurityConfiguration extends WebSecurityConfigurerAdapter
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 76 77 78 79 80 81 82 83 84 85 86 | package com.exam.app.config.security; import javax.sql.DataSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.web.session.HttpSessionEventPublisher; @Configuration @EnableWebSecurity public class SpringSecurityConfiguration extends WebSecurityConfigurerAdapter { @Autowired private DataSource dataSource; private final String LOGIN_PAGE_URI = "/logingo"; /** * 인증 설정 관련. * * @param auth * @throws Exception */ @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth .jdbcAuthentication() .dataSource(dataSource) .passwordEncoder(new BCryptPasswordEncoder()) ; } /** * security filter와 연결하기 위한 설정 관련. * * @param web * @throws Exception */ @Override public void configure(WebSecurity web) throws Exception { // 해당 패턴은 security filter 제외 web.ignoring().antMatchers("/favicon.ico", "/css/**", "/image/**", "/js/**", "/webjars/**"); } /** * request를 안전하게 보호하기 위한 설정 관련. * * @param http * @throws Exception */ @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/member","/member/*").authenticated() .antMatchers("/logingo","/logingo/*").authenticated() .antMatchers("/login","/login/*").authenticated() .anyRequest().permitAll() .and() .formLogin() .loginPage(LOGIN_PAGE_URI) .permitAll() .defaultSuccessUrl("/welcome") .and() .logout() .logoutUrl("/logout") .logoutSuccessUrl(LOGIN_PAGE_URI) .invalidateHttpSession(true) .permitAll(); } @Bean public HttpSessionEventPublisher httpSessionEventPublisher(){ return new HttpSessionEventPublisher(); } } | cs |
2.
'공부 > Spring Boot' 카테고리의 다른 글
EHCache 설정과 활용(Spring Boot 2.1.8) (0) | 2019.09.19 |
---|---|
Spring Security 활용 회원 관리 (3) - Spring Security와 Embedded Redis (0) | 2019.09.17 |
Spring Security 활용 회원 관리 (1) - 개요, 환경설정, DB 모델링 (1) | 2019.09.16 |
뷰(form)에 입력한 많은 데이터를 List 타입으로 컨트롤러로 보내는 방법 (4) | 2019.09.09 |
12. Spring Boot Gradle 프로젝트 생성 방법(Thymeleaf) (0) | 2019.09.04 |
Comments