验证部分改走内网

This commit is contained in:
黎润豪 2026-03-24 15:58:45 +08:00
parent 154c88d8bf
commit 5e56d21107
4 changed files with 22 additions and 22 deletions

View File

@ -20,6 +20,11 @@ public class UnifiedAuthConfig {
*/
private String authUrl;
/**
* 认证地址内网
*/
private String authUrlIntranet;
/**
* 客户端ID
*/
@ -71,27 +76,27 @@ public class UnifiedAuthConfig {
* 获取完整令牌接口URL
*/
public String getTokenUrl() {
return authUrl + tokenPath;
return authUrlIntranet + tokenPath;
}
/**
* 获取完整用户信息接口URL
*/
public String getUserinfoUrl() {
return authUrl + userinfoPath;
return authUrlIntranet + userinfoPath;
}
/**
* 获取完整验证令牌接口URL
*/
public String getCheckTokenUrl() {
return authUrl + checkTokenPath;
return authUrlIntranet + checkTokenPath;
}
/**
* 获取完整单点登出接口URL
*/
public String getLogoutUrl() {
return authUrl + logoutPath;
return authUrlIntranet + logoutPath;
}
}

View File

@ -49,14 +49,6 @@ public class ImsSyncController {
@ApiOperation(value = "机构同步接口", notes = "接收IMS推送的机构数据支持新增、修改、删除操作")
public ImsResultVO orgSynchronous(@RequestBody ImsOrgDTO dto, HttpServletRequest request) {
log.info("IMS机构同步请求: type={}, orgCode={}", dto.getType(), dto.getCode());
try (ServletInputStream inputStream = request.getInputStream();
ByteArrayOutputStream os = new ByteArrayOutputStream()) {
IOUtils.copy(inputStream, os);
log.info("IMS机构同步请求body{}", os);
} catch (Exception e) {
log.error("IMS机构同步请求参数读取失败", e);
}
try {
boolean result = imsOrgService.syncOrg(dto);
if (result) {
@ -82,14 +74,6 @@ public class ImsSyncController {
public ImsResultVO userSynchronous(@RequestBody ImsUserDTO dto, HttpServletRequest request) {
log.info("IMS用户同步请求: type={}, userCode={}", dto.getType(), dto.getUsercode());
try (ServletInputStream inputStream = request.getInputStream();
ByteArrayOutputStream os = new ByteArrayOutputStream()) {
IOUtils.copy(inputStream, os);
log.info("IMS用户同步请求body{}", os);
} catch (Exception e) {
log.error("IMS用户同步请求参数读取失败", e);
}
try {
boolean result = imsUserService.syncUser(dto);
if (result) {

View File

@ -8,12 +8,17 @@ import com.chinaweal.aiccs.org.entity.dto.UnifiedAuthDTO;
import com.chinaweal.aiccs.org.service.IUnifiedAuthService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.UUID;
/**
@ -41,7 +46,11 @@ public class UnifiedAuthServiceImpl implements IUnifiedAuthService {
StringBuilder url = new StringBuilder(unifiedAuthConfig.getAuthorizeUrl());
url.append("?response_type=code");
url.append("&client_id=").append(unifiedAuthConfig.getClientId());
url.append("&redirect_uri=").append(unifiedAuthConfig.getRedirectUri());
try {
url.append("&redirect_uri=").append(URLEncoder.encode(unifiedAuthConfig.getRedirectUri(), "utf-8"));
} catch (UnsupportedEncodingException e) {
log.error("{}的UrlEncode失败", unifiedAuthConfig.getRedirectUri(), e);
}
url.append("&state=").append(state);
log.info("构建统一认证平台登录URL: {}", url.toString());

View File

@ -160,6 +160,8 @@ oauth2:
unified-auth:
# 认证地址,根据实际环境配置
auth-url: ${UNIFIED_AUTH_URL:https://58.18.173.243:8002}
# 认证地址,内网
auth-url-intranet: ${UNIFIED_AUTH_URL_INTRANET:https://10.6.48.70:443}
# 客户端ID由统一认证平台分配
client-id: ${UNIFIED_AUTH_CLIENT_ID:xyjgxt}
# 客户端秘钥,由统一认证平台分配