This is an automated email from the ASF dual-hosted git repository.
epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-mcp.git
The following commit(s) were added to refs/heads/main by this push:
new 71e0031 refactor(security): move security configs to dedicated
package (#56)
71e0031 is described below
commit 71e0031634895c806056c64a3c01e6e439823d5d
Author: Aditya Parikh <[email protected]>
AuthorDate: Tue Mar 24 14:08:55 2026 -0400
refactor(security): move security configs to dedicated package (#56)
* refactor(security): move security configs to dedicated package
Rename McpServerConfiguration to HttpSecurityConfiguration and move both
HttpSecurityConfiguration and MethodSecurityConfiguration from
org.apache.solr.mcp.server.config to org.apache.solr.mcp.server.security.
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
* fix(security): rename spring.security.enabled to http.security.enabled
- Rename configuration property from `spring.security.enabled` to
`http.security.enabled` to avoid collision with Spring Boot's own
`spring.security.*` namespace
- Rename corresponding environment variable from `SECURITY_ENABLED`
to `HTTP_SECURITY_ENABLED` for consistency
- Update application-http.properties, HttpSecurityConfiguration,
MethodSecurityConfiguration, and keycloak.md
Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
* docs(security): move auth0 and keycloak docs to security-docs folder
Consolidate security-related documentation into a dedicated
security-docs directory for better organization.
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
* fix(quality): resolve SonarQube violations in security-refactor
Signed-off-by: Aditya Parikh <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
Signed-off-by: adityamparikh <[email protected]>
---------
Signed-off-by: adityamparikh <[email protected]>
Co-authored-by: Claude Sonnet 4.6 <[email protected]>
---
README.md | 6 +++---
{docs => security-docs}/AUTH0_SETUP.md | 0
keycloak.md => security-docs/keycloak.md | 12 ++++++------
.../HttpSecurityConfiguration.java} | 14 ++++++--------
.../{config => security}/MethodSecurityConfiguration.java | 8 ++++----
src/main/resources/application-http.properties | 2 +-
6 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/README.md b/README.md
index 488254e..642aee1 100644
--- a/README.md
+++ b/README.md
@@ -274,7 +274,7 @@ MCP tools.
### Quick Setup
-1. **Configure Auth0** (see detailed guide:
[docs/AUTH0_SETUP.md](docs/AUTH0_SETUP.md))
+1. **Configure Auth0** (see detailed guide:
[security-docs/AUTH0_SETUP.md](security-docs/AUTH0_SETUP.md))
- Create an Auth0 Application (Machine to Machine)
- Create an Auth0 API with your audience identifier
- Note your Domain, Client ID, Client Secret, and Audience
@@ -304,7 +304,7 @@ MCP tools.
http://localhost:8080/mcp
```
-For complete setup instructions, see [docs/AUTH0_SETUP.md](docs/AUTH0_SETUP.md)
+For complete setup instructions, see
[security-docs/AUTH0_SETUP.md](security-docs/AUTH0_SETUP.md)
## Available MCP tools
@@ -378,7 +378,7 @@ The `solr://{collection}/schema` resource supports
autocompletion for the `{coll
## Documentation
-- [Auth0 Setup (OAuth2 configuration)](docs/AUTH0_SETUP.md)
+- [Auth0 Setup (OAuth2 configuration)](security-docs/AUTH0_SETUP.md)
## Contributing
diff --git a/docs/AUTH0_SETUP.md b/security-docs/AUTH0_SETUP.md
similarity index 100%
rename from docs/AUTH0_SETUP.md
rename to security-docs/AUTH0_SETUP.md
diff --git a/keycloak.md b/security-docs/keycloak.md
similarity index 97%
rename from keycloak.md
rename to security-docs/keycloak.md
index 2338c80..941f2a0 100644
--- a/keycloak.md
+++ b/security-docs/keycloak.md
@@ -74,7 +74,7 @@ docker run -d --name keycloak \
# 3. Run Solr MCP Server with security enabled
export PROFILES=http
-export SECURITY_ENABLED=true
+export HTTP_SECURITY_ENABLED=true
export OAUTH2_ISSUER_URI=http://localhost:8180/realms/solr-mcp
./gradlew bootRun
```
@@ -168,7 +168,7 @@ The Solr MCP Server is pre-configured to work with any
OAuth2/OIDC provider. Upd
```properties
# Security toggle - set to true to enable OAuth2 authentication
-spring.security.enabled=${SECURITY_ENABLED:true}
+http.security.enabled=${HTTP_SECURITY_ENABLED:true}
# Keycloak OAuth2 Configuration
# Format: https://<keycloak-host>/realms/<realm-name>
@@ -183,7 +183,7 @@ No code changes are required—the existing
`McpServerConfiguration` handles JWT
```bash
export PROFILES=http
-export SECURITY_ENABLED=true
+export HTTP_SECURITY_ENABLED=true
export OAUTH2_ISSUER_URI=http://localhost:8180/realms/solr-mcp
./gradlew bootRun
```
@@ -192,7 +192,7 @@ export
OAUTH2_ISSUER_URI=http://localhost:8180/realms/solr-mcp
```bash
export PROFILES=http
-export SECURITY_ENABLED=false
+export HTTP_SECURITY_ENABLED=false
./gradlew bootRun
```
@@ -422,7 +422,7 @@ import
org.springframework.security.oauth2.server.resource.authentication.JwtAut
import
org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
@Bean
-@ConditionalOnProperty(name = "spring.security.enabled", havingValue = "true",
matchIfMissing = true)
+@ConditionalOnProperty(name = "http.security.enabled", havingValue = "true",
matchIfMissing = true)
public JwtAuthenticationConverter jwtAuthenticationConverter() {
JwtGrantedAuthoritiesConverter grantedAuthoritiesConverter = new
JwtGrantedAuthoritiesConverter();
// Keycloak stores realm roles in realm_access.roles
@@ -439,7 +439,7 @@ Wire it into the security filter chain:
```java
@Bean
-@ConditionalOnProperty(name = "spring.security.enabled", havingValue = "true",
matchIfMissing = true)
+@ConditionalOnProperty(name = "http.security.enabled", havingValue = "true",
matchIfMissing = true)
SecurityFilterChain securityFilterChain(HttpSecurity http,
JwtAuthenticationConverter jwtAuthenticationConverter) throws Exception {
return http
.authorizeHttpRequests(auth -> {
diff --git
a/src/main/java/org/apache/solr/mcp/server/config/McpServerConfiguration.java
b/src/main/java/org/apache/solr/mcp/server/security/HttpSecurityConfiguration.java
similarity index 88%
rename from
src/main/java/org/apache/solr/mcp/server/config/McpServerConfiguration.java
rename to
src/main/java/org/apache/solr/mcp/server/security/HttpSecurityConfiguration.java
index 17b4070..ac0c3ae 100644
---
a/src/main/java/org/apache/solr/mcp/server/config/McpServerConfiguration.java
+++
b/src/main/java/org/apache/solr/mcp/server/security/HttpSecurityConfiguration.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.mcp.server.config;
+package org.apache.solr.mcp.server.security;
import java.util.List;
import
org.springaicommunity.mcp.security.server.config.McpServerOAuth2Configurer;
@@ -34,13 +34,13 @@ import
org.springframework.web.cors.UrlBasedCorsConfigurationSource;
@Profile("http")
@Configuration
@EnableWebSecurity
-class McpServerConfiguration {
+class HttpSecurityConfiguration {
@Value("${spring.security.oauth2.resourceserver.jwt.issuer-uri:}")
private String issuerUrl;
@Bean
- @ConditionalOnProperty(name = "spring.security.enabled", havingValue =
"true", matchIfMissing = true)
+ @ConditionalOnProperty(name = "http.security.enabled", havingValue =
"true", matchIfMissing = true)
SecurityFilterChain securityFilterChain(HttpSecurity http) throws
Exception {
return http
// ⬇️ Open every request on the server
@@ -51,17 +51,15 @@ class McpServerConfiguration {
auth.anyRequest().authenticated();
})
// Configure OAuth2 on the MCP server
-
.with(McpServerOAuth2Configurer.mcpServerOAuth2(), (mcpAuthorization) -> {
- // REQUIRED: the issuerURI
-
mcpAuthorization.authorizationServer(issuerUrl);
- })
+
.with(McpServerOAuth2Configurer.mcpServerOAuth2(),
+ mcpAuthorization ->
mcpAuthorization.authorizationServer(issuerUrl))
// MCP inspector
.cors(cors ->
cors.configurationSource(corsConfigurationSource())).csrf(CsrfConfigurer::disable)
.build();
}
@Bean
- @ConditionalOnProperty(name = "spring.security.enabled", havingValue =
"false")
+ @ConditionalOnProperty(name = "http.security.enabled", havingValue =
"false")
SecurityFilterChain unsecured(HttpSecurity http) throws Exception {
return http.authorizeHttpRequests(auth ->
auth.anyRequest().permitAll())
// MCP inspector
diff --git
a/src/main/java/org/apache/solr/mcp/server/config/MethodSecurityConfiguration.java
b/src/main/java/org/apache/solr/mcp/server/security/MethodSecurityConfiguration.java
similarity index 83%
rename from
src/main/java/org/apache/solr/mcp/server/config/MethodSecurityConfiguration.java
rename to
src/main/java/org/apache/solr/mcp/server/security/MethodSecurityConfiguration.java
index 7345a57..d46c40b 100644
---
a/src/main/java/org/apache/solr/mcp/server/config/MethodSecurityConfiguration.java
+++
b/src/main/java/org/apache/solr/mcp/server/security/MethodSecurityConfiguration.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.solr.mcp.server.config;
+package org.apache.solr.mcp.server.security;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Configuration;
@@ -23,15 +23,15 @@ import
org.springframework.security.config.annotation.method.configuration.Enabl
/**
* Configuration class that enables method-level security only when
- * spring.security.enabled=true (or not set).
+ * http.security.enabled=true (or not set).
*
* <p>
* This allows the application to run without authentication when
- * spring.security.enabled=false, bypassing @PreAuthorize annotations.
+ * http.security.enabled=false, bypassing @PreAuthorize annotations.
*/
@Profile("http")
@Configuration
-@ConditionalOnProperty(name = "spring.security.enabled", havingValue = "true",
matchIfMissing = true)
+@ConditionalOnProperty(name = "http.security.enabled", havingValue = "true",
matchIfMissing = true)
@EnableMethodSecurity
class MethodSecurityConfiguration {
}
diff --git a/src/main/resources/application-http.properties
b/src/main/resources/application-http.properties
index 6d79619..12e2d94 100644
--- a/src/main/resources/application-http.properties
+++ b/src/main/resources/application-http.properties
@@ -9,7 +9,7 @@ spring.ai.mcp.server.stdio=false
# For Okta:
https://<your-okta-domain>/oauth2/default/.well-known/openid-configuration
spring.security.oauth2.resourceserver.jwt.issuer-uri=${OAUTH2_ISSUER_URI:https://your-auth0-domain.auth0.com/}
# Security toggle - set to true to enable OAuth2 authentication, false to
bypass
-spring.security.enabled=${SECURITY_ENABLED:false}
+http.security.enabled=${HTTP_SECURITY_ENABLED:false}
# observability
management.endpoints.web.exposure.include=health,sbom,metrics,info,loggers,prometheus
# Enable @Observed annotation support for custom spans