전자정부 개발프레임워크의 Spring Security 기본구조와 기본 환경 설정을 설명한다.
전자정부 개발프레임워크의 Server Security는 컨테이너 기동시 적용되는 XML기반 인증이 아닌 실시간 적용되는 DB기반의 JDBC 인증을 사용한다.
<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>
CREATE TABLE USERS ( USERNAME VARCHAR(50) NOT NULL, PASSWORD VARCHAR(50) NOT NULL, ENABLED BIT NOT NULL, CONSTRAINT PK_USERS PRIMARY KEY(USERNAME) );
CREATE TABLE AUTHORITIES ( USERNAME VARCHAR(50) NOT NULL, AUTHORITY VARCHAR(50) NOT NULL, CONSTRAINT PK_AUTHORITIES PRIMARY KEY(USER_ID,AUTHORITY), CONSTRAINT FK_USERS FOREIGN KEY(USER_ID) REFERENCES USERS(USER_ID), CONSTRAINT FK_ROLES3 FOREIGN KEY(AUTHORITY) REFERENCES ROLES(AUTHORITY) );
CREATE TABLE ROLES ( AUTHORITY VARCHAR(50) NOT NULL, ROLE_NAME VARCHAR(50), DESCRIPTION VARCHAR(100), CREATE_DATE DATE, MODIFY_DATE DATE, CONSTRAINT PK_ROLES PRIMARY KEY(AUTHORITY) );
AUTHORITY | DESCRIPTION |
---|---|
IS_AUTHENTICATED_ANONYMOUSLY | 익명 사용자 |
IS_AUTHENTICATED_REMEMBERED | REMEMBERED 사용자 |
IS_AUTHENTICATED_FULLY | 인증된 사용자 |
ROLE_RESTRICTED | 제한된 사용자 |
ROLE_USER | 일반 사용자 |
ROLE_ADMIN | 관리자 |
ROLE_A | A 업무 |
ROLE_B | B 업무 |
역할의 계층구조를 저장하는 테이블
CREATE TABLE ROLES_HIERARCHY ( PARENT_ROLE VARCHAR(50) NOT NULL, CHILD_ROLE VARCHAR(50) NOT NULL, CONSTRAINT PK_ROLES_HIERARCHY PRIMARY KEY(PARENT_ROLE,CHILD_ROLE), CONSTRAINT FK_ROLES1 FOREIGN KEY(PARENT_ROLE) REFERENCES ROLES(AUTHORITY), CONSTRAINT FK_ROLES2 FOREIGN KEY(CHILD_ROLE) REFERENCES ROLES (AUTHORITY) );
CHILD_ROLE | PARENT_ROLE |
---|---|
ROLE_ADMIN | ROLE_USER |
ROLE_USER | ROLE_RESTRICTED |
ROLE_RESTRICTED | IS_AUTHENTICATED_FULLY |
IS_AUTHENTICATED_FULLY | IS_AUTHENTICATED_REMEMBERED |
IS_AUTHENTICATED_REMEMBERED | IS_AUTHENTICATED_ANONYMOUSLY |
ROLE_ADMIN | ROLE_A |
ROLE_ADMIN | ROLE_B |
ROLE_A | ROLE_RESTRICTED |
ROLE_B | ROLE_RESTRICTED |
CREATE TABLE SECURED_RESOURCES ( RESOURCE_ID VARCHAR(10) NOT NULL, RESOURCE_NAME VARCHAR(50), RESOURCE_PATTERN VARCHAR(300) NOT NULL, DESCRIPTION VARCHAR(100), RESOURCE_TYPE VARCHAR(10), SORT_ORDER INTEGER, CREATE_DATE DATE, MODIFY_DATE DATE, CONSTRAINT PK_RECURED_RESOURCES PRIMARY KEY(RESOURCE_ID) );
url, method, pointcut으로 자원을 보호한다.
RESOURCE_ID | RESOURCE_PATTERN |
---|---|
web-000001 | \A/test\.do\Z |
web-000002 | \A/sale/.*\.do\Z |
web-000003 | \A/cvpl/((?!EgovCvplLogin\.do).)*\Z |
mtd-000001 | egovframework.rte.sample.service.EgovSampleService.updateSample |
mtd-000002 | egovframework.rte.sample.service.EgovSampleService.deleteSample |
mtd-000003 | execution(* egovframework.rte.sample..service.*Service.insert*(..)) |
보호된 자원과 역할과의 매핑 테이블
CREATE TABLE SECURED_RESOURCES_ROLE ( RESOURCE_ID VARCHAR(10) NOT NULL, AUTHORITY VARCHAR(50) NOT NULL, CONSTRAINT PK_SECURED_RESOURCES_ROLE PRIMARY KEY(RESOURCE_ID,AUTHORITY), CONSTRAINT FK_SECURED_RESOURCES FOREIGN KEY(RESOURCE_ID) REFERENCES SECURED_RESOURCES(RESOURCE_ID), CONSTRAINT FK_ROLES4 FOREIGN KEY (AUTHORITY) REFERENCES ROLES(AUTHORITY) );