반응형
- 스프링시큐리티 간단 설정
1 pom.xml 라이브러리 추가
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <!-- 시큐리티 --> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-core</artifactId> <version>4.0.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-web</artifactId> <version>4.0.4.RELEASE</version> </dependency> <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> <version>4.0.4.RELEASE</version> </dependency> | cs |
2 web.xml 설정
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | <!-- 스프링의 환경설정 파일 로딩 --> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/spring/root-context.xml <!-- 스프링 시큐리티 --> /WEB-INF/spring-security-context.xml </param-value> </context-param> <!-- 스프링 시큐리티 --> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> | cs |
3.WEB-INF에 spring-security-context.xml 생성
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd"> <security:http auto-config="true"> <security:intercept-url pattern="/favicon.ico" access="ROLE_ANONYMOUS" /> <security:intercept-url pattern="/**" access="hasRole('ROLE_USER')" /> </security:http> <security:authentication-manager> <security:authentication-provider> <security:user-service> <security:user name="guest" password="guest" authorities="ROLE_USER" /> </security:user-service> </security:authentication-provider> </security:authentication-manager> </beans> | cs |
4 확인
반응형
'매일코딩 > Spring' 카테고리의 다른 글
23.스프링프로젝트 - board write (0) | 2016.11.17 |
---|---|
22.spring board list (0) | 2016.11.17 |
20.스프링프로젝트 - 스프링 마이바티스 mysql 연동 (0) | 2016.11.16 |
19.스프링프로젝트 - 화면이동 redirect (0) | 2016.11.01 |
18.스프링프로젝트 - 메뉴바(구버전) 방명록 조회 수정 삭제 (0) | 2016.11.01 |
댓글