超高压接入生管系统

This commit is contained in:
hzj
2025-04-18 10:19:25 +08:00
parent d738116968
commit 0f712c45fd
3 changed files with 82 additions and 2 deletions

View File

@@ -37,7 +37,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers("/oauth/getPublicKey","/oauth/logout","/auth/getImgCode","/judgeToken/guangZhou","/judgeToken/heBei","/oauth/autoLogin").permitAll()
.antMatchers("/oauth/getPublicKey","/oauth/logout","/auth/getImgCode","/judgeToken/guangZhou","/judgeToken/heBei","/oauth/autoLogin","/judgeToken/productionManagementCheck").permitAll()
// @link https://gitee.com/xiaoym/knife4j/issues/I1Q5X6 (接口文档knife4j需要放行的规则)
.antMatchers("/webjars/**","/doc.html","/swagger-resources/**","/v2/api-docs").permitAll()
.anyRequest().authenticated()

View File

@@ -76,6 +76,85 @@ public class JudgeThirdToken extends BaseController {
}
}
/**
* 生产管理系统token校验
* @param token
* @return
*/
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/productionManagementCheck")
@ApiOperation("生产管理系统token校验")
@ApiImplicitParam(name = "token", required = true)
public HttpResult<Object> productionManagementCheck (String token) {
RestTemplate restTemplate = new RestTemplate();
String methodDescribe = getMethodDescribe("productionManagementCheck");
LogUtil.njcnDebug(log, "{}token{}", methodDescribe, token);
// 请求地址
String url = "http://10.120.192.72:80/head-auth-service/oauth/check_token";
// 请求头设置,x-www-form-urlencoded格式的数据
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
//提交参数设置
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add("token", token);
// 组装请求体
HttpEntity<MultiValueMap<String, String>> request =
new HttpEntity<>(map, headers);
// 发送post请求并打印结果以String类型接收响应结果JSON字符串
String result = restTemplate.postForObject(url, request, String.class);
JSONObject resultJson = new JSONObject(result);
// JSONObject resultJson = new JSONObject(token);
/**
* 成功
* {
* "sub": "40a21660947c44a6a40030109214f313",
* "ver": "JWT1.0",
* "user_name": "web",
* "pri": [
* "MASTER_ADMIN",
* "znxs",
* "root",
* "ADMIN"
* ],
* "last_login": 1744875032,
* "scope": [
* "all"
* ],
* "iss": "nrec",
* "active": true,
* "exp": 1744961431,
* "jti": "32add77a-43f0-4d67-82a2-8376fed6fc3d",
* "client_id": "frontend"
* }
*
* 失败
*
* {
* "msg": "Cannot convert access token to JSON",
* "path": "/auth-service/oauth/check_token",
* "code": "2500",
* "succ": false,
* "error": "Internal Server Error",
* "timestamp": 1744879150627
* }
*/
if (resultJson.containsKey("code")) {
//成功
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
} else {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/heBei")

View File

@@ -215,7 +215,8 @@ whitelist:
- /pqs-auth/oauth/getPublicKey
- /pqs-auth/judgeToken/heBei
- /pqs-auth/judgeToken/guangZhou
- /pqs-auth/judgeToken/productionManagementCheck
-
- /webjars/**
- /doc.html
- /swagger-resources/**