최초 커밋

master
mjkhan21 1 year ago
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…
Cancel
Save