超高压接入生管系统
This commit is contained in:
@@ -37,7 +37,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
protected void configure(HttpSecurity http) throws Exception {
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
http
|
http
|
||||||
.authorizeRequests()
|
.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需要放行的规则)
|
// @link https://gitee.com/xiaoym/knife4j/issues/I1Q5X6 (接口文档knife4j需要放行的规则)
|
||||||
.antMatchers("/webjars/**","/doc.html","/swagger-resources/**","/v2/api-docs").permitAll()
|
.antMatchers("/webjars/**","/doc.html","/swagger-resources/**","/v2/api-docs").permitAll()
|
||||||
.anyRequest().authenticated()
|
.anyRequest().authenticated()
|
||||||
|
|||||||
@@ -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)
|
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||||
@PostMapping("/heBei")
|
@PostMapping("/heBei")
|
||||||
|
|||||||
@@ -215,7 +215,8 @@ whitelist:
|
|||||||
- /pqs-auth/oauth/getPublicKey
|
- /pqs-auth/oauth/getPublicKey
|
||||||
- /pqs-auth/judgeToken/heBei
|
- /pqs-auth/judgeToken/heBei
|
||||||
- /pqs-auth/judgeToken/guangZhou
|
- /pqs-auth/judgeToken/guangZhou
|
||||||
|
- /pqs-auth/judgeToken/productionManagementCheck
|
||||||
|
-
|
||||||
- /webjars/**
|
- /webjars/**
|
||||||
- /doc.html
|
- /doc.html
|
||||||
- /swagger-resources/**
|
- /swagger-resources/**
|
||||||
|
|||||||
Reference in New Issue
Block a user