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

master
YunaiV 5 months ago
parent ed962134f6
commit cb5f05b421

@ -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();
});
}
};

Loading…
Cancel
Save