Commit 9649fc49bbdd5eeb0e190c8cdb01d641bd397673

Authored by xp.Huang
2 parents be3d7520 f9d7c882

Merge branch '20230427' into 'master_dev'

fix: 鉴权脚本有效性校验完善

See merge request yunteng/thingskit!187
... ... @@ -34,6 +34,7 @@ import io.netty.channel.ChannelHandlerContext;
34 34 import io.netty.channel.ChannelInboundHandlerAdapter;
35 35 import io.netty.handler.codec.mqtt.*;
36 36 import io.netty.handler.ssl.SslHandler;
  37 +import io.netty.util.CharsetUtil;
37 38 import io.netty.util.ReferenceCountUtil;
38 39 import io.netty.util.concurrent.Future;
39 40 import io.netty.util.concurrent.GenericFutureListener;
... ... @@ -303,7 +304,7 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements
303 304 Futures.addCallback(item, new FutureCallback<String>() {
304 305 @Override
305 306 public void onSuccess(@Nullable String result) {
306   - processAuthTokenConnect(ctx, id, JacksonUtil.fromString(result, TcpAuthEntry.class));
  307 + processAuthTokenConnect(ctx, id, JacksonUtil.fromString(result.replace("\\","\\\\"), TcpAuthEntry.class));
307 308 }
308 309
309 310 @Override
... ... @@ -319,14 +320,13 @@ public class TcpTransportHandler extends ChannelInboundHandlerAdapter implements
319 320 private void processAuthTokenConnect(ChannelHandlerContext ctx, UUID scriptId, TcpAuthEntry accessToken) {
320 321
321 322 log.debug("[{}][{}] Processing connect msg for client with user name: {}!", address, sessionId, accessToken);
322   - TransportProtos.ValidateDeviceTokenRequestMsg.Builder request = TransportProtos.ValidateDeviceTokenRequestMsg.newBuilder();
323 323 if (null != accessToken.getClientId()) {
324 324 }
325 325 if (null != accessToken.getUserName()) {
326 326 }
327 327 String token = accessToken.getPassword();
328 328 if(StringUtils.isNotEmpty(token)){
329   - token.trim();
  329 + TransportProtos.ValidateDeviceTokenRequestMsg.Builder request = TransportProtos.ValidateDeviceTokenRequestMsg.newBuilder();
330 330 request.setToken(token);
331 331 transportService.process(DeviceTransportType.TCP, request.build(),
332 332 new TransportServiceCallback<>() {
... ...