[Spring Security4] HelloWorld Test
http://websystique.com/spring-security/spring-security-4-hello-world-annotation-xml-example/ 참고
web.xml
<!-- Security 필터 -->
<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>
<!-- 인코딩 필터만 추가!!! -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
root-context (namespace security 체크)
<security:http auto-config="true" >
<security:intercept-url pattern="/" access="permitAll" />
<security:intercept-url pattern="/home" access="permitAll" />
<security:intercept-url pattern="/admin**" access="hasRole('ADMIN')" />
<security:intercept-url pattern="/dba**" access="hasRole('ADMIN') or hasRole('DBA')" />
<security:form-login authentication-failure-url="/Access_Denied" />
</security:http>
<security:authentication-manager >
<security:authentication-provider>
<security:user-service>
<security:user name="bill" password="abc123" authorities="ROLE_USER" />
<security:user name="admin" password="root123" authorities="ROLE_ADMIN" />
<security:user name="dba" password="root123" authorities="ROLE_ADMIN,ROLE_DBA" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
pom.xml
<properties>
<org.springframework-version>4.1.6.RELEASE</org.springframework-version>
<springsecurity-version>4.0.1.RELEASE</springsecurity-version>
</properties>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>${springsecurity-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>${springsecurity-version}</version>
</dependency>
'게임 개발 초보자 > 초보자의 개발일기' 카테고리의 다른 글
[Spring] 경로 입력할 때 (0) | 2018.07.13 |
---|---|
[디자인패턴] 싱글톤으로 클래스 만들기 (0) | 2018.06.28 |
[Spring] 게시판에 페이지 기능 추가하기 Paging (Oracle) (0) | 2018.06.04 |
[Spring] 서버 DB에 테이블 만들기(Oracle, MariaDB) (0) | 2018.06.04 |
[Spring] Mybatis 설정 (0) | 2018.06.04 |