@@ -1,5 +1,6 @@ | |||||
package com.hz.pm.api.external; | package com.hz.pm.api.external; | ||||
import cn.hutool.http.useragent.UserAgentUtil; | |||||
import com.hz.pm.api.meeting.entity.config.WebProps; | import com.hz.pm.api.meeting.entity.config.WebProps; | ||||
import com.ningdatech.basic.exception.BizException; | import com.ningdatech.basic.exception.BizException; | ||||
import com.ningdatech.file.entity.File; | import com.ningdatech.file.entity.File; | ||||
@@ -10,6 +11,7 @@ import org.slf4j.LoggerFactory; | |||||
import org.springframework.beans.factory.annotation.Value; | import org.springframework.beans.factory.annotation.Value; | ||||
import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
/** | /** | ||||
@@ -26,8 +28,11 @@ public class FilePreviewClient { | |||||
private static final Logger log = LoggerFactory.getLogger(FilePreviewClient.class); | private static final Logger log = LoggerFactory.getLogger(FilePreviewClient.class); | ||||
@Value("${mh.file-preview.host}") | |||||
private String mhFilePreviewUrl; | |||||
@Value("${mh.file-preview.public-host:}") | |||||
private String mhFilePreviewPublicUrl; | |||||
@Value("${mh.file-preview.private-host:}") | |||||
private String mhFilePreviewPrivateUrl; | |||||
private final FileService fileService; | private final FileService fileService; | ||||
@@ -37,10 +42,19 @@ public class FilePreviewClient { | |||||
private static final String PREVIEW_PATH_FMT = "%s/public/risen/core/resrc/view/pdf_view.html.do?strMap.remote_url=%s&strMap.ext=%s"; | private static final String PREVIEW_PATH_FMT = "%s/public/risen/core/resrc/view/pdf_view.html.do?strMap.remote_url=%s&strMap.ext=%s"; | ||||
public String getFilePreviewUrl(Long fileId) { | |||||
String fileDownUrl = WebProps.apiUrl + FILE_DOWN_NO_AUTH_URL + fileId; | |||||
File file = fileService.getById(fileId); | |||||
return String.format(PREVIEW_PATH_FMT, mhFilePreviewUrl, fileDownUrl, file.getSuffix()); | |||||
public String getFilePreviewUrl(Long fileId, HttpServletRequest request) { | |||||
String serverName = request.getServerName(); | |||||
log.info("serverName:{}", serverName); | |||||
if (serverName.contains("weixin") || serverName.contains("10.54.38.13")) { | |||||
// 浙政钉访问需要转换为互联网可访问的地址 | |||||
String fileDownUrl = WebProps.zzdApiUrl + FILE_DOWN_NO_AUTH_URL + fileId; | |||||
File file = fileService.getById(fileId); | |||||
return String.format(PREVIEW_PATH_FMT, mhFilePreviewPublicUrl, fileDownUrl, file.getSuffix()); | |||||
} else { | |||||
String fileDownUrl = WebProps.apiUrl + FILE_DOWN_NO_AUTH_URL + fileId; | |||||
File file = fileService.getById(fileId); | |||||
return String.format(PREVIEW_PATH_FMT, mhFilePreviewPrivateUrl, fileDownUrl, file.getSuffix()); | |||||
} | |||||
} | } | ||||
public void downloadFile(Long fileId, HttpServletResponse response) { | public void downloadFile(Long fileId, HttpServletResponse response) { | ||||
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable; | |||||
import org.springframework.web.bind.annotation.RequestMapping; | import org.springframework.web.bind.annotation.RequestMapping; | ||||
import org.springframework.web.bind.annotation.RestController; | import org.springframework.web.bind.annotation.RestController; | ||||
import javax.servlet.http.HttpServletRequest; | |||||
import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
/** | /** | ||||
@@ -29,8 +30,8 @@ public class FilePreviewController { | |||||
@ApiOperation("获取文件的预览地址") | @ApiOperation("获取文件的预览地址") | ||||
@GetMapping("/getFilePreviewUrl/{fileId}") | @GetMapping("/getFilePreviewUrl/{fileId}") | ||||
public String getFilePreviewUrl(@PathVariable Long fileId) { | |||||
return filePreviewClient.getFilePreviewUrl(fileId); | |||||
public String getFilePreviewUrl(@PathVariable Long fileId, HttpServletRequest request) { | |||||
return filePreviewClient.getFilePreviewUrl(fileId, request); | |||||
} | } | ||||
@ApiOperation("文件下载(不鉴权)") | @ApiOperation("文件下载(不鉴权)") | ||||
@@ -20,6 +20,10 @@ public class WebProps { | |||||
public static String apiUrl; | public static String apiUrl; | ||||
public static String zzdApiUrl; | |||||
@Value("${web.login.url:}") | @Value("${web.login.url:}") | ||||
private void setLoginUrl(String url) { | private void setLoginUrl(String url) { | ||||
loginUrl = url; | loginUrl = url; | ||||
@@ -30,4 +34,9 @@ public class WebProps { | |||||
apiUrl = url; | apiUrl = url; | ||||
} | } | ||||
@Value("${web.zzd-api.url:}") | |||||
private void setZzdApiUrl(String url) { | |||||
zzdApiUrl = url; | |||||
} | |||||
} | } |
@@ -193,7 +193,9 @@ public class MeetingNotifyHelper { | |||||
private void smsExperts(Meeting meeting, List<MeetingExpert> experts) { | private void smsExperts(Meeting meeting, List<MeetingExpert> experts) { | ||||
String content = String.format(VoiceSmsTemplateConst.EXPERT_INVITE_SMS, | String content = String.format(VoiceSmsTemplateConst.EXPERT_INVITE_SMS, | ||||
meeting.getHoldOrg(), meeting.getName(), officialTime(meeting.getStartTime()), | meeting.getHoldOrg(), meeting.getName(), officialTime(meeting.getStartTime()), | ||||
meeting.getMeetingAddress()); | |||||
meeting.getMeetingAddress(), | |||||
meeting.getConnecter(), | |||||
meeting.getContact()); | |||||
Set<String> phones = CollUtils.fieldSet(experts, MeetingExpert::getMobile); | Set<String> phones = CollUtils.fieldSet(experts, MeetingExpert::getMobile); | ||||
String submitKey; | String submitKey; | ||||
if (environmentUtil.isDevEnv() && Boolean.TRUE.equals(inviteSkipSendSms)) { | if (environmentUtil.isDevEnv() && Boolean.TRUE.equals(inviteSkipSendSms)) { | ||||
@@ -28,6 +28,6 @@ public class VoiceSmsTemplateConst { | |||||
*/ | */ | ||||
public static final String EXPERT_INVITE_CALL = "尊敬的专家您好,%s现邀请您作为专家参加%s会议,会议时间:%s,会议地点:%s。 确认参加请按 1,拒绝参加请按 2,重听请按星号键。请您选择"; | public static final String EXPERT_INVITE_CALL = "尊敬的专家您好,%s现邀请您作为专家参加%s会议,会议时间:%s,会议地点:%s。 确认参加请按 1,拒绝参加请按 2,重听请按星号键。请您选择"; | ||||
public static final String EXPERT_INVITE_SMS = "【杭州数字信创】尊敬的专家您好,%s现邀请您作为专家参加%s会议,会议时间:%s,会议地点:%s。 确认参加请回复 1,拒绝参加请回复 2。请您选择"; | |||||
public static final String EXPERT_INVITE_SMS = "【杭州数字信创】尊敬的专家您好,%s现邀请您作为专家参加%s会议,会议时间:%s,会议地点:%s。 确认参加请回复 1,拒绝参加请回复 2。如有疑问请联系:%s(%s)。"; | |||||
} | } |
@@ -1,17 +1,23 @@ | |||||
package com.hz.pm.api.user.security.config; | package com.hz.pm.api.user.security.config; | ||||
import com.hz.pm.api.common.model.constant.BizConst; | |||||
import com.hz.pm.api.common.model.constant.CommonConst; | import com.hz.pm.api.common.model.constant.CommonConst; | ||||
import com.hz.pm.api.user.security.auth.code.AuthCodeLoginSecurityConfig; | import com.hz.pm.api.user.security.auth.code.AuthCodeLoginSecurityConfig; | ||||
import com.hz.pm.api.user.security.auth.credential.CredentialAuthSecurityConfig; | import com.hz.pm.api.user.security.auth.credential.CredentialAuthSecurityConfig; | ||||
import com.hz.pm.api.user.security.handler.DefaultExpiredSessionStrategy; | import com.hz.pm.api.user.security.handler.DefaultExpiredSessionStrategy; | ||||
import com.hz.pm.api.user.security.handler.DefaultLogoutSuccessHandler; | import com.hz.pm.api.user.security.handler.DefaultLogoutSuccessHandler; | ||||
import com.hz.pm.api.user.security.auth.mh.MhAuthSecurityConfig; | import com.hz.pm.api.user.security.auth.mh.MhAuthSecurityConfig; | ||||
import com.ningdatech.basic.util.NdJsonUtil; | |||||
import com.ningdatech.basic.util.StrPool; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.context.annotation.Configuration; | import org.springframework.context.annotation.Configuration; | ||||
import org.springframework.http.HttpStatus; | |||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||||
import org.springframework.security.web.AuthenticationEntryPoint; | |||||
import org.springframework.security.web.csrf.CookieCsrfTokenRepository; | import org.springframework.security.web.csrf.CookieCsrfTokenRepository; | ||||
import java.io.PrintWriter; | |||||
import java.util.Map; | import java.util.Map; | ||||
import java.util.Set; | import java.util.Set; | ||||
@@ -38,7 +44,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | |||||
protected void configure(HttpSecurity http) throws Exception { | protected void configure(HttpSecurity http) throws Exception { | ||||
assemblerPreAuthUrls(http); | assemblerPreAuthUrls(http); | ||||
http.formLogin() | http.formLogin() | ||||
.loginPage(authProperties.getAuthRequireUrl()) | |||||
.and() | |||||
.exceptionHandling() | |||||
.authenticationEntryPoint(authenticationEntryPoint()) | |||||
.and().apply(credentialAuthSecurityConfig) | .and().apply(credentialAuthSecurityConfig) | ||||
.and().apply(authCodeLoginSecurityConfig) | .and().apply(authCodeLoginSecurityConfig) | ||||
.and().apply(mhAuthSecurityConfig) | .and().apply(mhAuthSecurityConfig) | ||||
@@ -68,6 +76,17 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { | |||||
.ignoringAntMatchers(authProperties.getIgnoreCsrfUrlsArray()); | .ignoringAntMatchers(authProperties.getIgnoreCsrfUrlsArray()); | ||||
} | } | ||||
private AuthenticationEntryPoint authenticationEntryPoint() { | |||||
return (request, response, authException) -> { | |||||
response.setContentType(StrPool.CONTENT_TYPE); | |||||
response.setStatus(HttpStatus.UNAUTHORIZED.value()); | |||||
PrintWriter writer = response.getWriter(); | |||||
writer.write(NdJsonUtil.getInstance().writeValueAsString(BizConst.UNAUTHENTICATED)); | |||||
writer.flush(); | |||||
writer.close(); | |||||
}; | |||||
} | |||||
private void assemblerPreAuthUrls(HttpSecurity http) throws Exception { | private void assemblerPreAuthUrls(HttpSecurity http) throws Exception { | ||||
Map<String, String[]> roleArrayMap = authProperties.getRoleArrayMap(); | Map<String, String[]> roleArrayMap = authProperties.getRoleArrayMap(); | ||||
Set<String> roleSet = roleArrayMap.keySet(); | Set<String> roleSet = roleArrayMap.keySet(); | ||||
@@ -189,7 +189,7 @@ mh: | |||||
detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList | detail-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/ossfile/getFileInfoList | ||||
upload-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/uploadFileSkipLogin | upload-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/uploadFileSkipLogin | ||||
file-preview: | file-preview: | ||||
host: http://ztzz2.hzswb.cn/yl | |||||
public-host: http://ztzz2.hzswb.cn/yl | |||||
auth-code: | auth-code: | ||||
secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 | secret-key: nqkmzqojg5j4eiypr3rb8s7nb4noa8b2 | ||||
@@ -182,6 +182,8 @@ web: | |||||
url: https://hzszxc.hzswb.cn:8443/project | url: https://hzszxc.hzswb.cn:8443/project | ||||
api: | api: | ||||
url: https://hzszxc.hzswb.cn:8443/hzpm | url: https://hzszxc.hzswb.cn:8443/hzpm | ||||
zzd-api: | |||||
url: https://weixin.hzszxc.hzswb.cn:8143/hzpm | |||||
mh: | mh: | ||||
sso: | sso: | ||||
@@ -199,8 +201,8 @@ mh: | |||||
purchase-notice: | purchase-notice: | ||||
open: true | open: true | ||||
file-preview: | file-preview: | ||||
# host: http://ztzz2.hzswb.cn/yl | |||||
host: http://172.18.43.208/yl | |||||
public-host: http://ztzz2.hzswb.cn/yl | |||||
private-host: http://172.18.43.208/yl | |||||
sms-send: | sms-send: | ||||
host: http://10.54.38.13:8081/mh-gateway/auth-single | host: http://10.54.38.13:8081/mh-gateway/auth-single | ||||