fix: SpringDocsConfig 서버 목록 추가

- http, https 서버
     Cors yml 설정 정리
dev
gitea-관리자 12 months ago
parent 6734c05949
commit bd23fac669

@ -43,7 +43,7 @@ spring:
# core의 application-common.yml과 application-auth.yml include
include:
#- https
- https
- common
- auth
- app

@ -0,0 +1,92 @@
/*
* Copyright 2008-2009 MOPAS(MINISTRY OF SECURITY AND PUBLIC ADMINISTRATION).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package egovframework.com.cmm.filter;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* SessionTimeoutCookieFilter
* @author
* @since 2020.06.17
* @version 1.0
* @see
*
* <pre>
* << (Modification Information) >>
*
*
* ---------- -------- ---------------------------
* 2020.06.17
*
*/
public class SessionTimeoutCookieFilter implements Filter{
@SuppressWarnings("unused")
private FilterConfig config;
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletResponse httpResponse = (HttpServletResponse) response;
HttpServletRequest httpRequest = (HttpServletRequest) request;
long serverTime = System.currentTimeMillis();
long sessionExpireTime = serverTime + httpRequest.getSession().getMaxInactiveInterval() * 1000;
Cookie cookie = new Cookie("egovLatestServerTime", "" + serverTime);
boolean secure = request.isSecure();
if ( secure ) cookie.setSecure(true);
cookie.setHttpOnly(true);
cookie.setPath("/");
httpResponse.addCookie(cookie);
cookie = new Cookie("egovExpireSessionTime", "" + sessionExpireTime);
if ( secure ) cookie.setSecure(true);
cookie.setHttpOnly(true);
cookie.setPath("/");
// Date dateServer = new java.util.Date(serverTime);
// Date dateExpiry = new java.util.Date(sessionExpireTime);
// SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// String serverYMD = format.format(dateServer);
// String expiryYMD = format.format(dateExpiry);
//System.out.println("=====>>> serverYMD = "+serverYMD);
//System.out.println("=====>>> expiryYMD = "+expiryYMD);
//System.out.println("=====>>> server TimeStamp = "+serverTime);
//System.out.println("=====>>> expire TimeStamp = "+sessionExpireTime);
httpResponse.addCookie(cookie);
chain.doFilter(request, response);
}
public void init(FilterConfig config) throws ServletException {
this.config = config;
}
public void destroy() {
}
}

@ -62,10 +62,10 @@ public class SpringDocsConfig {
// https enabled
List<Server> servers = new ArrayList<>();
if(HTTP_PORT != 0){
String httpsUrl = Checks.isNotEmpty(swaggerUrl)? swaggerUrl : String.format("https://localhost:%d", SERVER_PORT);
String httpUrl = Checks.isNotEmpty(swaggerUrl)? swaggerUrl : String.format("http://localhost:%d", HTTP_PORT);
servers.add(new Server().url(httpsUrl).description(name + "(" + active + ")"));
String httpsUrl = Checks.isNotEmpty(swaggerUrl)? swaggerUrl : String.format("https://localhost:%d", SERVER_PORT);
servers.add(new Server().url(httpUrl).description(name + "(" + active + ")"));
servers.add(new Server().url(httpsUrl).description(name + "(" + active + ")"));
}else {
String httpUrl = Checks.isNotEmpty(swaggerUrl)? swaggerUrl : String.format("http://localhost:%d", SERVER_PORT);
servers.add(new Server().url(httpUrl).description(name + "(" + active + ")"));

@ -81,9 +81,6 @@ public class WebMvcConfig implements WebMvcConfigurer {
private final CorsProperties corsProperties;
@Value("${app.spring.security.white-list}")
private String[] EXCLUDE_AUTHS;
/**
* MappingJackson2XmlHttpMessageConverter
* @param converters
@ -100,7 +97,12 @@ public class WebMvcConfig implements WebMvcConfigurer {
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new AuthentificationInterceptor())
.addPathPatterns("/**/*")
.excludePathPatterns(EXCLUDE_AUTHS);
.excludePathPatterns(
"/api/core/*",
"/swagger-ui.html",
"/swagger-ui/*",
"/api-docs/*"
);
registry.addInterceptor(localeChangeInterceptor());
}

@ -70,6 +70,7 @@ spring:
classpath:/egovframework/messages/message-common,
classpath:/egovframework/messages/message-api,
classpath:/egovframework/messages/message-batch,
classpath:/egovframework/messages/message-admin,
classpath:/org/egovframe/rte/fdl/idgnr/messages/idgnr,
classpath:/org/egovframe/rte/fdl/property/messages/properties,
classpath:/egovframework/egovProps/globals

Loading…
Cancel
Save