Skip to content

Commit

Permalink
bug fix: mqq sub auth error (#755)
Browse files Browse the repository at this point in the history
  • Loading branch information
caseone committed Mar 23, 2021
1 parent f991f09 commit 2bb35dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,20 @@ public Optional<MqttMessage> process(MqttMessage req, String sessionId, String r
}

if (auth && req.fixedHeader().messageType().equals(MqttMessageType.SUBSCRIBE)) {
boolean isAuth = true;
List<MqttTopicSubscription> topicSubscriptions = ((MqttSubscribePayload) req.payload()).topicSubscriptions();
for (MqttTopicSubscription topicSubscription : topicSubscriptions) {
String topicName = topicSubscription.topicName();
String userName = this.authorSessions.get(sessionId).getUserName();
AccountTopicAuthEntity entity = accountTopicAuthRepository.findAllByUserNameAndTopicNameAndDeleteAt(userName, topicName, IsDeleteEnum.NOT_DELETED.getCode());
if (null != entity && (entity.getPermission() == SUB_PUB || entity.getPermission() == PUB)) {
return this.subscribe.process(req, clientId, remoteIp);
continue;
}
log.error("userName:{},topicName:{}, not subscribe permission", userName, topicName);
isAuth = false;
break;
}
if (!isAuth) {
throw new BrokerException(ErrorCode.MQTT_NOT_PERMISSION);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public boolean verifyUserName(String userName, String password) {
if (null == accountEntity) {
return false;
}
log.info("accountEntity:{}", accountEntity.toString());
log.info("accountEntity:{}", accountEntity.getUserName());
return password.equals(accountEntity.getPassword());
}
}
5 changes: 2 additions & 3 deletions weevent-governance/web/src/components/fileTranspoart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<el-button @click="dialogFormVisible = false">{{$t('common.cancel')}}</el-button>
</div>
</el-dialog>

<el-dialog :title="$t('file.secretKey')" :visible.sync="dialogSecretKeyVisible" center width='450px' :close-on-click-modal='false'>
<el-form :model="form" ref='form' label-position="top">
<el-form-item>
Expand Down Expand Up @@ -576,8 +576,7 @@ export default {
role: e.role,
topicName: e.topicName,
brokerId: localStorage.getItem('brokerId'),
groupId: localStorage.getItem('groupId'),
nodeAddress: e.nodeAddress
groupId: localStorage.getItem('groupId')
})
} else {
// download file
Expand Down

0 comments on commit 2bb35dc

Please sign in to comment.