提交 520e6002 authored 作者: 林振杰's avatar 林振杰

修改mqtt连接验证

上级 25e65dd9
......@@ -8,10 +8,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.glinfo.enbao.common.annotation.Login;
import tech.glinfo.enbao.common.utils.ByteUtils;
import tech.glinfo.enbao.common.utils.EncryptUtil;
import tech.glinfo.enbao.common.utils.R;
import tech.glinfo.enbao.common.utils.StringUtils;
import tech.glinfo.enbao.common.utils.*;
import tech.glinfo.enbao.config.MqttGateway;
import tech.glinfo.enbao.modules.mqtt.entity.AuthEntity;
......@@ -27,11 +24,16 @@ public class MqttController {
private MqttGateway mqttGateway;
@PostMapping("auth")
public ResponseEntity<Object> auth(AuthEntity auth){
public ResponseEntity<Object> auth(@RequestBody AuthEntity auth){
log.info("请求参数:{}", auth);
String pwd = EncryptUtil.encrypt(auth.getUsername());
if(auth.getPassword() != null && auth.getPassword().equals(pwd)) {
return new ResponseEntity<Object>(HttpStatus.OK);
boolean isSuperuser = false;
if(auth.getUsername().startsWith("168EG")) {//暂时写死
isSuperuser = true;
}
MapUtils rtn = new MapUtils().put("result", "allow").put("is_superuser", isSuperuser);
return new ResponseEntity<Object>(rtn, HttpStatus.OK);
} else {
return new ResponseEntity<Object>("auth deny!", HttpStatus.UNAUTHORIZED);
}
......
......@@ -3,7 +3,7 @@ spring:
type: com.alibaba.druid.pool.DruidDataSource
druid:
driver-class-name: com.mysql.cj.jdbc.Driver #172.19.211.93
url: jdbc:mysql://192.168.0.164:3306/glinfo?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
url: jdbc:mysql://192.168.0.26:3306/glinfo?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
username: root
password: Glinfo#123456!
initial-size: 10
......@@ -36,7 +36,7 @@ spring:
redis:
open: true # 是否开启redis缓存 true开启 false关闭
database: 0
host: 192.168.0.164
host: 192.168.0.26
port: 6379
password: # 密码(默认为空)
timeout: 6000ms # 连接超时时长(毫秒)
......@@ -49,7 +49,7 @@ spring:
#MQ配置
activemq:
broker-url: failover:(tcp://106.14.139.199:61617,tcp://106.14.139.199:61618)
broker-url: tcp://192.168.0.26:61616
user: admin
password: admin123!
in-memory: false #是否启用内存模式(就是不安装MQ,项目启动时同时启动一个MQ实例)
......@@ -62,12 +62,12 @@ spring:
#mqtt配置
mqtt:
url: tcp://mqtt.gonglian.info:1883
username: 002WX212230209
username: 168EG212230209
password: nfefhjljt
client:
id: 'iotclientid${random.int}'
default:
topic: $share/api/sys/+/+/up,$share/api/sys/+/+/response
topic: $share/glapi/sys/+/+/up,$share/glapi/sys/+/+/response,$share/glapi/$SYS/brokers/+/clients/#
completionTimeout: 3000
##多数据源的配置
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论