🔧 Changing configuration files.remove some default config
This commit is contained in:
1 parent
bef61f80af
commit
88bc4c6665
2 files changed
+13
-8
No files matched your search
@@ -70,12 +70,8 @@ mybatis-plus:
|
||||
# 关闭MP3.0自带的banner
|
||||
banner: false
|
||||
db-config:
|
||||
# 主键类型 0:数据库ID自增 1.未定义 2.用户输入 3 id_worker 4.uuid 5.id_worker字符串表示
|
||||
id-type: 0
|
||||
#字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
|
||||
field-strategy: 1
|
||||
# 默认数据库表下划线命名
|
||||
table-underline: true
|
||||
# 主键类型
|
||||
id-type: auto
|
||||
|
||||
#swagger公共信息
|
||||
swagger:
|
||||
|
||||
+11
-2
@@ -1,5 +1,6 @@
|
||||
package com.pig4cloud.pigx.act.config;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -49,16 +50,24 @@ public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
|
||||
@Override
|
||||
public Message<?> preSend(Message<?> message, MessageChannel channel) {
|
||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||
// 判断是否首次连接请求
|
||||
if (StompCommand.CONNECT.equals(accessor.getCommand())) {
|
||||
String tokens = accessor.getFirstNativeHeader("Authorization");
|
||||
log.info("webSocket token is {}", tokens);
|
||||
if (StrUtil.isBlank(tokens)) {
|
||||
return null;
|
||||
}
|
||||
// 验证令牌信息
|
||||
OAuth2Authentication auth2Authentication = tokenService.loadAuthentication(tokens.split(" ")[1]);
|
||||
SecurityContextHolder.getContext().setAuthentication(auth2Authentication);
|
||||
accessor.setUser(() -> (String) auth2Authentication.getPrincipal());
|
||||
if(ObjectUtil.isNotNull(auth2Authentication)) {
|
||||
SecurityContextHolder.getContext().setAuthentication(auth2Authentication);
|
||||
accessor.setUser(() -> (String) auth2Authentication.getPrincipal());
|
||||
return message;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//不是首次连接,已经成功登陆
|
||||
return message;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user