물생활 유튜브 채널입니다.
나날이 커가는 구피와 코리들을 업로드 하고 있어요.
들어오셔서 구독&좋아요 부탁드려요.
'[일상] > [물생활]' 카테고리의 다른 글
코리도라스 바닥재 금사로 교체하기 (0) | 2019.04.16 |
---|
물생활 유튜브 채널입니다.
나날이 커가는 구피와 코리들을 업로드 하고 있어요.
들어오셔서 구독&좋아요 부탁드려요.
코리도라스 바닥재 금사로 교체하기 (0) | 2019.04.16 |
---|
스프링 시큐리티는 스프링 기반의 어플리케이션의 보안(인증과 권한)을 담당하는 프레임워크이다. 만약 스프링시큐리티를 사용하지 않았다면, 자체적으로 세션을 체크하고 redirect 등을 해야할 것이다. 스프링 시큐리티는 보안과 관련해서 체계적으로 많은 옵션들로 이를 지원해준다. spring security는 filter 기반으로 동작하기 때문에 spring MVC 와 분리되어 관리 및 동작한다. 참고로 security 3.2부터는 XML로 설정하지 않고도 자바 bean 설정으로 간단하게 설정할 수 있도록 지원한다.
여기서는 현재기준 최신버전인 스프링 4.3.18과 시큐리티 4.2.7을 가지고 진행했다.
출처: https://sjh836.tistory.com/165 [빨간색코딩]
1. pom.xml 에 depencency 추가
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
2. web.xml > context 추가 & filter 작성
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring/root-context.xml
/WEB-INF/spring/appServlet/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>
3. security-context.xml 에 내용 작성 (로그인/로그아웃 상태 등의 응용 로직 추가)
<?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.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd">
<security:http auto-config="true">
<security:form-login login-page="/loginForm.html"/>
<security:intercept-url pattern="/login.html*" access="ROLE_USER"/>
<security:intercept-url pattern="/welcome.html*" access="ROLE_ADMIN"/>
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="user" password="123" authorities="ROLE_USER"/>
<security:user name="admin" password="123" authorities="ROLE_ADMIN,ROLE_USER"/>
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
</beans>
[출처]https://seouliotcenter.tistory.com/89?category=663840
스프링 에러 - Request method 'POST' not supported (2) | 2021.01.25 |
---|---|
Spring Boot란 / Spring과의 차이 (0) | 2019.05.13 |
SpringJDBC 마리아(maria)DB 메이븐 설정 (0) | 2019.03.29 |
SpringJDBC - Oracle 연동을 위한 pom.xml 설정 (0) | 2019.03.29 |
간단한 Spring framework의 정의 및 개념 (0) | 2019.03.29 |
이디야 유리JAR 랜덤무료증정 이벤트/ 어피치 블라썸 (0) | 2019.03.30 |
---|---|
구리맛집 돌다리곱창골목 보배곱창 (0) | 2019.03.30 |
[맛집탐방]신사역 라공방 (0) | 2019.03.24 |
[맛집탐방]듀자미(Deux Amis) 카페 (0) | 2019.03.24 |
[맛집탐방]신사역 핫도그찹찹 (0) | 2019.03.24 |