Spring Security 구성하기(1)
Spring Security 구성하기(1)
개발환경 Os Windows 10 IDE STS 3.9.6 Jdk 1.8.0_172 Spring 5.2.1.RELEASE Spring Security 4.2.13.RELEASE DB MsSql View JSP
1. 프로젝트 최초 생성 / 구조
- New > Spring Legacy Project > SPring MVC Project
2. Spring Security 관련 추가 작업
1) 의존성 추가를 위해 POM.xml 에 Spring Security 4.2.2.RELEASE 추가
org.springframework.security spring-security-core 4.2.2.RELEASE jar compile org.springframework.security spring-security-web 4.2.2.RELEASE jar compile org.springframework.security spring-security-config 4.2.2.RELEASE jar compile org.springframework.security spring-security-taglibs 4.2.2.RELEASE jar compile
2) Web.xml 에 springSecurityFilterChain 등록 및 security-context.xml (신규파일) 등록
- DelegatingFilterProxy 로인해 모든 요청이 스프링시큐리티를 통해 인증 인가를 수행
contextConfigLocation /WEB-INF/spring/*-context.xml org.springframework.web.context.ContextLoaderListener springSecurityFilterChain org.springframework.web.filter.DelegatingFilterProxy springSecurityFilterChain /* appServlet org.springframework.web.servlet.DispatcherServlet contextConfigLocation /WEB-INF/spring/appServlet/servlet-context.xml 1 appServlet /
3) security 의 관련된 설정을 위한 security-context.xml 신규파일생성
- auto-config="true" 로 설정시 가장 기본적인 로그인페이지가 생성
- use-expressions : SPEL (spring express language) 사용여부
3. 적용 후 프로젝트 구조
- 빨간 점선으로 표시된 3개의 파일이 내용 변경 및 추가된 파일
4. 톰캣 구동후 화면
- localhost:8080/ 접속시 security-context.xml 에 /** 접근권한을 ORL_USER로 주었기에 /login 으로 이동
- 다른 정보로 접속시 실패 로그
- 로그인성공
깃허브 : https://github.com/devHjlee/SpringSecurity.git
커밋 : 8b078e6bea10d048ef4068f0c3aced7533c007e0
from http://devhj.tistory.com/14 by ccl(A) rewrite - 2020-03-07 10:22:00
댓글
댓글 쓰기