최초 커밋
commit
af3f822702
@ -0,0 +1,127 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.7.12</version>
|
||||||
|
<relativePath/>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<groupId>cokr.xit.boot</groupId>
|
||||||
|
<artifactId>xit-base-starter</artifactId>
|
||||||
|
<version>23.04.01-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>xit-base-starter</name>
|
||||||
|
<description>xit-base module for Spring Boot</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>17</java.version>
|
||||||
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>mvn2</id>
|
||||||
|
<url>http://repo1.maven.org/maven2/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>egovframe</id>
|
||||||
|
<url>http://www.egovframe.go.kr/maven/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>egovframe2</id>
|
||||||
|
<url>http://maven.egovframe.kr:8080/maven/</url>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>maven-public</id>
|
||||||
|
<url>http://xit.xit-nexus.com:8081/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<repository>
|
||||||
|
<id>maven-releases</id>
|
||||||
|
<url>http://xit.xit-nexus.com:8081/repository/maven-releases/</url>
|
||||||
|
<snapshots>
|
||||||
|
<enabled>false</enabled>
|
||||||
|
</snapshots>
|
||||||
|
<releases>
|
||||||
|
<enabled>true</enabled>
|
||||||
|
</releases>
|
||||||
|
</repository>
|
||||||
|
-->
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cokr.xit.boot</groupId>
|
||||||
|
<artifactId>xit-foundation-starter</artifactId>
|
||||||
|
<version>23.04.01-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>cokr.xit.base</groupId>
|
||||||
|
<artifactId>xit-base</artifactId>
|
||||||
|
<version>23.04.01-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<includes>
|
||||||
|
<include>**/*.class</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<distributionManagement>
|
||||||
|
<snapshotRepository>
|
||||||
|
<id>maven-snapshot</id>
|
||||||
|
<url>http://xit.xit-nexus.com:8081/repository/maven-snapshots/</url>
|
||||||
|
</snapshotRepository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>maven-release</id>
|
||||||
|
<url>http://xit.xit-nexus.com:8081/repository/maven-releases/</url>
|
||||||
|
</repository>
|
||||||
|
</distributionManagement>
|
||||||
|
|
||||||
|
</project>
|
@ -0,0 +1,39 @@
|
|||||||
|
package cokr.xit.base.boot;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||||
|
|
||||||
|
import cokr.xit.base.file.web.DownloadView;
|
||||||
|
import cokr.xit.base.menu.web.MenuInjector;
|
||||||
|
import cokr.xit.foundation.boot.MvcConfig;
|
||||||
|
|
||||||
|
/**web mvc 설정(기존 dispatcher servlet) 클래스
|
||||||
|
* @author mjkhan
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class MvcConfig2 extends MvcConfig {
|
||||||
|
/**MenuInjector를 반환한다.
|
||||||
|
* @return MenuInjector
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public MenuInjector menuInjector() {
|
||||||
|
return new MenuInjector();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**MenuInjector를 interceptor로 추가한다.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
super.addInterceptors(registry);
|
||||||
|
registry.addInterceptor(menuInjector()).addPathPatterns(URL_PATTERNS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**DownloadView를 반환한다.
|
||||||
|
* @return DownloadView
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public DownloadView downloadView() {
|
||||||
|
return new DownloadView();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,145 @@
|
|||||||
|
package cokr.xit.base.boot;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.authentication.ProviderManager;
|
||||||
|
import org.springframework.security.authorization.AuthorizationManager;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer;
|
||||||
|
import org.springframework.security.web.SecurityFilterChain;
|
||||||
|
import org.springframework.security.web.access.intercept.RequestAuthorizationContext;
|
||||||
|
|
||||||
|
import cokr.xit.base.security.access.ApplicationAccess;
|
||||||
|
import cokr.xit.base.security.authentication.service.bean.AuthenticationServiceBean;
|
||||||
|
import cokr.xit.base.security.authentication.service.bean.PasswordEncoder;
|
||||||
|
import cokr.xit.base.security.authentication.web.AuthenticationExtraDetailsSource;
|
||||||
|
import cokr.xit.base.security.authentication.web.AuthenticationFailure;
|
||||||
|
import cokr.xit.base.security.authentication.web.AuthenticationSuccess;
|
||||||
|
import cokr.xit.base.security.authentication.web.LogoutSuccess;
|
||||||
|
import cokr.xit.foundation.web.ExceptionController;
|
||||||
|
|
||||||
|
/**spring security 관련 설정 클래스
|
||||||
|
* @author mjkhan
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableWebSecurity
|
||||||
|
public class SecurityConfig {
|
||||||
|
/**SecurityFilterChain을 반환한다.
|
||||||
|
* @param http http-security 설정
|
||||||
|
* @return SecurityFilterChain
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
|
http.authorizeHttpRequests(conf ->
|
||||||
|
conf.antMatchers("/resources/**", "/login.do", "/logout.do", "/error/*.do").permitAll()
|
||||||
|
.antMatchers("/**/*.do").access(authorizationManager())
|
||||||
|
.anyRequest().authenticated()
|
||||||
|
)
|
||||||
|
.formLogin(conf ->
|
||||||
|
conf.loginPage("/login.do")
|
||||||
|
.usernameParameter("account")
|
||||||
|
.passwordParameter("password")
|
||||||
|
.loginProcessingUrl("/login.do")
|
||||||
|
.authenticationDetailsSource(authenticationDetailsSource())
|
||||||
|
.successHandler(authenticationSuccess())
|
||||||
|
.failureHandler(authenticationFailure())
|
||||||
|
)
|
||||||
|
.logout(conf ->
|
||||||
|
conf.logoutUrl("/logout.do")
|
||||||
|
.logoutSuccessHandler(logoutSuccess())
|
||||||
|
)
|
||||||
|
.sessionManagement(conf ->
|
||||||
|
conf.invalidSessionUrl("/error/invalidSession.do")
|
||||||
|
.sessionConcurrency(config ->
|
||||||
|
config.expiredUrl("/error/sessionExpired.do")
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.authenticationManager(authenticationManager())
|
||||||
|
.exceptionHandling().accessDeniedHandler((hreq, hresp, e) ->
|
||||||
|
exceptionController.accessDenied(hreq, hresp)
|
||||||
|
);
|
||||||
|
|
||||||
|
return http.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ExceptionController exceptionController;
|
||||||
|
|
||||||
|
/**WebSecurityCustomizer를 반환한다.<br />
|
||||||
|
* 모든 정적 파일에 대한 접근 url은 /resources/**로 한다.
|
||||||
|
* @return WebSecurityCustomizer
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public WebSecurityCustomizer webSecurityCustomizer() {
|
||||||
|
return conf -> conf.ignoring().antMatchers("/resources/**");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**AuthenticationSuccess(로그인 성공 핸들러)를 반환한다.
|
||||||
|
* @return AuthenticationSuccess
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public AuthenticationSuccess authenticationSuccess() {
|
||||||
|
return new AuthenticationSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**AuthenticationFailure(로그인 실패 핸들러)를 반환한다.
|
||||||
|
* @return AuthenticationFailure
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public AuthenticationFailure authenticationFailure() {
|
||||||
|
return new AuthenticationFailure();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**LogoutSuccess(로그아웃 성공 핸들러)를 반환한다.
|
||||||
|
* @return LogoutSuccess
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public LogoutSuccess logoutSuccess() {
|
||||||
|
return new LogoutSuccess();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**AuthenticationExtraDetailsSource(사용자 인증 시 필요한 정보 핸들러)를 반환한다.
|
||||||
|
* @return AuthenticationExtraDetailsSource
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public AuthenticationExtraDetailsSource authenticationDetailsSource() {
|
||||||
|
return new AuthenticationExtraDetailsSource();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**PasswordEncoder를 반환한다.
|
||||||
|
* @return PasswordEncoder
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public PasswordEncoder passwordEncoder() {
|
||||||
|
return new PasswordEncoder();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**AuthenticationServiceBean(인증 서비스)를 반환한다.
|
||||||
|
* @return AuthenticationServiceBean
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public AuthenticationServiceBean authenticationService() {
|
||||||
|
AuthenticationServiceBean bean = new AuthenticationServiceBean();
|
||||||
|
bean.setPasswordEncoder(passwordEncoder());
|
||||||
|
return bean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**ProviderManager(인증 서비스 제공자)를 반환한다.
|
||||||
|
* @return ProviderManager
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public ProviderManager authenticationManager() {
|
||||||
|
return new ProviderManager(authenticationService());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**AuthorizationManager(접근 관리자)를 반환한다.
|
||||||
|
* @return AuthorizationManager
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public AuthorizationManager<RequestAuthorizationContext> authorizationManager() {
|
||||||
|
return new ApplicationAccess();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package cokr.xit.base.boot;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
|
import cokr.xit.foundation.boot.FoundationApplication;
|
||||||
|
|
||||||
|
/**xit-base 모듈에 의존하는 spring boot 애플리케이션의 베이스 클래스
|
||||||
|
* @author mjkhan
|
||||||
|
*/
|
||||||
|
@Import({
|
||||||
|
MvcConfig2.class,
|
||||||
|
SecurityConfig.class,
|
||||||
|
})
|
||||||
|
public class XitBaseApplication extends FoundationApplication {}
|
@ -0,0 +1,8 @@
|
|||||||
|
package cokr.xit.base.boot;
|
||||||
|
|
||||||
|
import cokr.xit.foundation.boot.FoundationTest;
|
||||||
|
|
||||||
|
/**Spring Boot에서 xit-base를 사용하는 클래스의 단위 테스트 작성을 위한 베이스 클래스.
|
||||||
|
* @author mjkhan
|
||||||
|
*/
|
||||||
|
public class XitBaseTest extends FoundationTest {}
|
@ -0,0 +1,6 @@
|
|||||||
|
/**xit-base 모듈을 Spring Boot 애플리케이션에서 사용할 수 있도록 지원
|
||||||
|
* <ul><li>배포 모듈: xit-base-starter-yy.mm.dd.jar</li>
|
||||||
|
* <li>의존 모듈: {@link cokr.xit.base xit-base-yy.mm.dd.jar}</li>
|
||||||
|
* </ul>
|
||||||
|
*/
|
||||||
|
package cokr.xit.base.boot;
|
Loading…
Reference in New Issue