规范命名.
This commit is contained in:
@@ -11,8 +11,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @since 2023/7/10 15:49
|
||||
*/
|
||||
@Data
|
||||
@ConfigurationProperties(prefix = "orion.thread.pool")
|
||||
public class ThreadPoolConfig {
|
||||
@ConfigurationProperties(prefix = "orion.async.executor")
|
||||
public class AsyncExecutorConfig {
|
||||
|
||||
/**
|
||||
* 核心线程数量
|
||||
@@ -34,7 +34,7 @@ public class ThreadPoolConfig {
|
||||
*/
|
||||
private int keepAliveSeconds;
|
||||
|
||||
public ThreadPoolConfig() {
|
||||
public AsyncExecutorConfig() {
|
||||
this.corePoolSize = 8;
|
||||
this.maxPoolSize = 16;
|
||||
this.queueCapacity = 200;
|
||||
@@ -23,7 +23,7 @@ import java.util.concurrent.ThreadPoolExecutor;
|
||||
@EnableAsync
|
||||
@AutoConfiguration
|
||||
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_COMMON)
|
||||
@EnableConfigurationProperties(ThreadPoolConfig.class)
|
||||
@EnableConfigurationProperties(AsyncExecutorConfig.class)
|
||||
public class OrionCommonAutoConfiguration {
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ public class OrionCommonAutoConfiguration {
|
||||
*/
|
||||
@Primary
|
||||
@Bean(name = "asyncExecutor")
|
||||
public TaskExecutor asyncExecutor(ThreadPoolConfig config) {
|
||||
public TaskExecutor asyncExecutor(AsyncExecutorConfig config) {
|
||||
ThreadPoolMdcTaskExecutor executor = new ThreadPoolMdcTaskExecutor();
|
||||
executor.setCorePoolSize(config.getCorePoolSize());
|
||||
executor.setMaxPoolSize(config.getMaxPoolSize());
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package com.orion.ops.framework.common.utils;
|
||||
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
|
||||
/**
|
||||
* 工具类
|
||||
*
|
||||
* @author Jiahang Li
|
||||
* @version 1.0.0
|
||||
* @since 2023/7/14 16:34
|
||||
*/
|
||||
public class Kits {
|
||||
|
||||
private Kits() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取登陆凭证
|
||||
*
|
||||
* @param authorization authorization
|
||||
* @return token
|
||||
*/
|
||||
public static String getAuthorization(String authorization) {
|
||||
if (Strings.isEmpty(authorization)) {
|
||||
return null;
|
||||
}
|
||||
if (!authorization.contains(Const.BEARER) || authorization.length() <= Const.BEARER_PREFIX_LEN) {
|
||||
return null;
|
||||
}
|
||||
return authorization.substring(Const.BEARER_PREFIX_LEN).trim();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +1,32 @@
|
||||
{
|
||||
"groups": [
|
||||
{
|
||||
"name": "orion.thread.pool",
|
||||
"type": "com.orion.ops.framework.common.config.ThreadPoolConfig",
|
||||
"sourceType": "com.orion.ops.framework.common.config.ThreadPoolConfig"
|
||||
"name": "orion.async.executor",
|
||||
"type": "com.orion.ops.framework.common.config.AsyncExecutorConfig",
|
||||
"sourceType": "com.orion.ops.framework.common.config.AsyncExecutorConfig"
|
||||
}
|
||||
],
|
||||
"properties": [
|
||||
{
|
||||
"name": "orion.thread.pool.core-pool-size",
|
||||
"name": "orion.async.executor.core-pool-size",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "核心线程数量",
|
||||
"defaultValue": "8"
|
||||
},
|
||||
{
|
||||
"name": "orion.thread.pool.max-pool-size",
|
||||
"name": "orion.async.executor.max-pool-size",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "最大线程数量.",
|
||||
"defaultValue": "16"
|
||||
},
|
||||
{
|
||||
"name": "orion.thread.pool.queue-capacity",
|
||||
"name": "orion.async.executor.queue-capacity",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "队列容量.",
|
||||
"defaultValue": "200"
|
||||
},
|
||||
{
|
||||
"name": "orion.thread.pool.keep-alive-seconds",
|
||||
"name": "orion.async.executor.keep-alive-seconds",
|
||||
"type": "java.lang.Integer",
|
||||
"description": "活跃时间.",
|
||||
"defaultValue": "300"
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.orion.ops.framework.security.core.utils;
|
||||
|
||||
import com.orion.lang.constant.StandardHttpHeader;
|
||||
import com.orion.lang.utils.Strings;
|
||||
import com.orion.ops.framework.common.constant.Const;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.framework.common.utils.Kits;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContext;
|
||||
@@ -31,7 +32,14 @@ public class SecurityUtils {
|
||||
* @return token
|
||||
*/
|
||||
public static String obtainAuthorization(HttpServletRequest request) {
|
||||
return Kits.getAuthorization(request.getHeader(StandardHttpHeader.AUTHORIZATION));
|
||||
String authorization = request.getHeader(StandardHttpHeader.AUTHORIZATION);
|
||||
if (Strings.isEmpty(authorization)) {
|
||||
return null;
|
||||
}
|
||||
if (!authorization.contains(Const.BEARER) || authorization.length() <= Const.BEARER_PREFIX_LEN) {
|
||||
return null;
|
||||
}
|
||||
return authorization.substring(Const.BEARER_PREFIX_LEN).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,9 +45,9 @@ public enum WsCloseCode {
|
||||
VALID(4150, WsCloseReason.AUTHENTICATION_FAILURE),
|
||||
|
||||
/**
|
||||
* 机器不合法
|
||||
* 主机不合法
|
||||
*/
|
||||
INVALID_MACHINE(4200, WsCloseReason.CLOSED_CONNECTION),
|
||||
INVALID_HOST(4200, WsCloseReason.CLOSED_CONNECTION),
|
||||
|
||||
/**
|
||||
* 连接远程服务器连接超时
|
||||
@@ -70,9 +70,9 @@ public enum WsCloseCode {
|
||||
CONNECTION_EXCEPTION(4210, WsCloseReason.UNABLE_TO_CONNECT_REMOTE_SERVER),
|
||||
|
||||
/**
|
||||
* 机器未启用
|
||||
* 主机未启用
|
||||
*/
|
||||
MACHINE_DISABLED(4215, WsCloseReason.MACHINE_DISABLED),
|
||||
HOST_DISABLED(4215, WsCloseReason.HOST_DISABLED),
|
||||
|
||||
/**
|
||||
* 打开shell出现异常
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface WsCloseReason {
|
||||
|
||||
String REMOTE_SERVER_AUTHENTICATION_FAILURE = "remote server authentication failure...";
|
||||
|
||||
String MACHINE_DISABLED = "machine disabled...";
|
||||
String HOST_DISABLED = "host disabled...";
|
||||
|
||||
String UNABLE_TO_CONNECT_REMOTE_SERVER = "unable to connect remote server...";
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class WebSockets {
|
||||
} else if (Exceptions.isCausedBy(e, AuthenticationException.class)) {
|
||||
close(session, WsCloseCode.CONNECTION_AUTH_FAILURE);
|
||||
} else if (Exceptions.isCausedBy(e, DisabledException.class)) {
|
||||
close(session, WsCloseCode.MACHINE_DISABLED);
|
||||
close(session, WsCloseCode.HOST_DISABLED);
|
||||
} else {
|
||||
close(session, WsCloseCode.CONNECTION_EXCEPTION);
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ orion:
|
||||
aes:
|
||||
# 加密秘钥
|
||||
secret-key: uQeacXV8b3isvKLK
|
||||
thread:
|
||||
pool:
|
||||
async:
|
||||
executor:
|
||||
core-pool-size: 8
|
||||
max-pool-size: 16
|
||||
queue-capacity: 200
|
||||
|
||||
@@ -146,9 +146,9 @@ orion:
|
||||
infra:
|
||||
group: "infra - 基建模块"
|
||||
path: "infra"
|
||||
machine:
|
||||
group: "machine - 机器资源模块"
|
||||
path: "machine"
|
||||
asset:
|
||||
group: "asset - 资产模块"
|
||||
path: "asset"
|
||||
|
||||
logging:
|
||||
# 全局日志打印
|
||||
@@ -189,10 +189,10 @@ orion:
|
||||
secret-key: I66AndrKWrwXjtBL
|
||||
use-generator-key: true
|
||||
generator-key-length: 128
|
||||
thread:
|
||||
async:
|
||||
# 线程池配置
|
||||
pool:
|
||||
executor:
|
||||
core-pool-size: 2
|
||||
max-pool-size: 4
|
||||
keep-alive-seconds: 180
|
||||
queue-capacity: 30
|
||||
keep-alive-seconds: 180
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
};
|
||||
</script>
|
||||
|
||||
<script setup lang="ts">
|
||||
<script lang="ts" setup>
|
||||
import { usePagination, useColLayout } from '@/types/card';
|
||||
import { computed, reactive, ref } from 'vue';
|
||||
import useLoading from '@/hooks/loading';
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- machine provider -->
|
||||
<!-- asset provider -->
|
||||
<dependency>
|
||||
<groupId>com.orion.ops</groupId>
|
||||
<artifactId>orion-ops-module-asset-provider</artifactId>
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.orion.ops.module.infra.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.orion.lang.constant.StandardHttpHeader;
|
||||
import com.orion.lang.define.wrapper.Pair;
|
||||
import com.orion.lang.utils.Exceptions;
|
||||
import com.orion.lang.utils.collect.Lists;
|
||||
@@ -12,10 +11,10 @@ import com.orion.ops.framework.common.constant.ErrorMessage;
|
||||
import com.orion.ops.framework.common.security.LoginUser;
|
||||
import com.orion.ops.framework.common.utils.CryptoUtils;
|
||||
import com.orion.ops.framework.common.utils.IpUtils;
|
||||
import com.orion.ops.framework.common.utils.Kits;
|
||||
import com.orion.ops.framework.common.utils.Valid;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisStrings;
|
||||
import com.orion.ops.framework.redis.core.utils.RedisUtils;
|
||||
import com.orion.ops.framework.security.core.utils.SecurityUtils;
|
||||
import com.orion.ops.module.infra.convert.SystemUserConvert;
|
||||
import com.orion.ops.module.infra.dao.SystemUserDAO;
|
||||
import com.orion.ops.module.infra.dao.SystemUserRoleDAO;
|
||||
@@ -97,7 +96,7 @@ public class AuthenticationServiceImpl implements AuthenticationService {
|
||||
@Override
|
||||
public void logout(HttpServletRequest request) {
|
||||
// 获取登陆 token
|
||||
String loginToken = Kits.getAuthorization(request.getHeader(StandardHttpHeader.AUTHORIZATION));
|
||||
String loginToken = SecurityUtils.obtainAuthorization(request);
|
||||
if (loginToken == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user