This commit is contained in:
acgist
2023-02-11 22:11:51 +08:00
parent 50f80bee2d
commit 5f85dfccca
112 changed files with 1770 additions and 1213 deletions

View File

@@ -25,6 +25,11 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public class SecurityInterceptor extends InterceptorAdapter {
/**
* Basic认证
*/
private static final String BASIC = "Basic";
private AntPathMatcher matcher = new AntPathMatcher();
@Autowired
@@ -89,10 +94,10 @@ public class SecurityInterceptor extends InterceptorAdapter {
if(StringUtils.isEmpty(authorization)) {
return false;
}
if(!StringUtils.startsWithIgnoreCase(authorization, SecurityProperties.BASIC)) {
if(!StringUtils.startsWithIgnoreCase(authorization, BASIC)) {
return false;
}
authorization = authorization.substring(SecurityProperties.BASIC.length()).strip();
authorization = authorization.substring(BASIC.length()).strip();
authorization = new String(Base64.getDecoder().decode(authorization));
final int index = authorization.indexOf(':');
if(index < 0) {

View File

@@ -9,6 +9,7 @@ import org.springframework.context.annotation.ComponentScan;
public class TaoyaoApplication {
public static void main(String[] args) {
System.getProperties().setProperty("jdk.internal.httpclient.disableHostnameVerification", Boolean.TRUE.toString());
SpringApplication.run(TaoyaoApplication.class, args);
}

View File

@@ -1,4 +1,12 @@
taoyao:
webrtc:
mediasoup-list:
- name: mediasoup-local-a
enabled: true
host: 192.168.8.110
port: 4443
schema: wss
username: taoyao
password: taoyao
security:
permit: /v3/api-docs/**,/swagger-ui/**,/swagger-ui.html,/,/error,/index.html,/favicon.ico
permit: /v3/api-docs/**,/swagger-ui/**,/swagger-ui.html,/,/error,/index.html,/favicon.ico

View File

@@ -111,19 +111,17 @@ taoyao:
# 媒体配置
mediasoup-list:
- name: mediasoup-local-a
enabled: true
host: localhost
#host: 192.168.8.110
port: 4443
schema: wss
websocket: /websocket.signal
username: taoyao
password: taoyao
- name: mediasoup-local-z
enabled: true
host: localhost
#host: 192.168.8.110
port: 4443
schema: wss
websocket: /websocket.signal
username: taoyao
password: taoyao
# 安全配置
@@ -135,7 +133,7 @@ taoyao:
password: taoyao
# 定时任务
scheduled:
session: 0 * * * * ?
client: 0 * * * * ?
# 集群配置
node:
enabled: false

View File

@@ -37,7 +37,7 @@ public class WebSocketClient {
@Override
public void onOpen(WebSocket webSocket) {
webSocket.sendText(String.format("""
{"header":{"pid":2000,"v":"1.0.0","id":"1","sn":"%s"},"body":{"username":"taoyao","password":"taoyao","ip":"127.0.0.1","mac":"00:00:00:00:00:00"}}
{"header":{"pid":2000,"v":"1.0.0","id":"1","sn":"%s"},"body":{"username":"taoyao","password":"taoyao","ip":"127.0.0.1"}}
""", sn), true);
Listener.super.onOpen(webSocket);
}

View File

@@ -21,7 +21,7 @@ class PlatformScriptProtocolTest {
@Test
void testScript() {
assertDoesNotThrow(() -> {
this.platformScriptProtocol.execute("taoyao", Map.of("script", "netstat -ano"), Message.success(), null);
this.platformScriptProtocol.execute("taoyao", Map.of("script", "netstat -ano"), null, Message.success());
Thread.sleep(1000);
});
}

View File

@@ -19,7 +19,7 @@ class PlatformShutdownProtocolTest {
@Test
void testShutdown() {
assertDoesNotThrow(() -> {
this.platformShutdownProtocol.execute("taoyao", Message.success(), null);
this.platformShutdownProtocol.execute("taoyao", null, Message.success());
Thread.sleep(1000);
});
}