fix:【ai 大模型】兼容 mcp server 关闭的情况

pull/207/head v2025.09(jdk17/21)
YunaiV 2025-08-31 16:06:37 +08:00
parent ed962134f6
commit cb5f05b421
1 changed files with 7 additions and 3 deletions

View File

@ -9,6 +9,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AuthorizeHttpRequestsConfigurer;
import java.util.Optional;
/**
* AI Security
*/
@ -16,7 +18,7 @@ import org.springframework.security.config.annotation.web.configurers.AuthorizeH
public class SecurityConfiguration {
@Resource
private McpServerProperties serverProperties;
private Optional<McpServerProperties> serverProperties;
@Bean("aiAuthorizeRequestsCustomizer")
public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() {
@ -40,8 +42,10 @@ public class SecurityConfiguration {
registry.requestMatchers(ApiConstants.PREFIX + "/**").permitAll();
// MCP Server
registry.requestMatchers(serverProperties.getSseEndpoint()).permitAll();
registry.requestMatchers(serverProperties.getSseMessageEndpoint()).permitAll();
serverProperties.ifPresent(properties -> {
registry.requestMatchers(properties.getSseEndpoint()).permitAll();
registry.requestMatchers(properties.getSseMessageEndpoint()).permitAll();
});
}
};