Skip to content

Commit 71662d8

Browse files
committed
Merge branch 'main' of https://github.com/eclipse-basyx/basyx-java-server-sdk into apiclient-pooling
2 parents e4f58cb + 42d183b commit 71662d8

23 files changed

Lines changed: 112 additions & 52 deletions

File tree

basyx.aasenvironment/basyx.aasenvironment.component/src/main/java/org/eclipse/digitaltwin/basyx/aasenvironment/component/AasEnvironmentConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class AasEnvironmentConfiguration {
5050

5151
@Bean
5252
@ConditionalOnMissingBean
53-
public static AasEnvironment getAasEnvironment(AasEnvironmentFactory aasEnvironmentFactory, List<AasEnvironmentFeature> features, @Value("${basyx.aasenvironment.minInflateRatio:0.001}") double minInflateRatio) {
53+
public static AasEnvironment getAasEnvironment(AasEnvironmentFactory aasEnvironmentFactory, List<AasEnvironmentFeature> features, @Value("${basyx.aasenvironment.mininflateratio:0.001}") double minInflateRatio) {
5454
ZipSecureFile.setMinInflateRatio(minInflateRatio);
5555
return new DecoratedAasEnvironmentFactory(aasEnvironmentFactory, features).create();
5656
}

basyx.aasenvironment/basyx.aasenvironment.component/src/main/resources/application.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ basyx.backend = InMemory
2020
# basyx.cors.allowed-origins=http://localhost:3000, http://localhost:4000
2121
# basyx.cors.allowed-methods=GET,POST,PATCH,DELETE,PUT,OPTIONS,HEAD
2222

23-
# basyx.aasenvironment.minInflateRatio=0.00001
23+
# basyx.aasenvironment.mininflateratio=0.00001
2424

2525
####################################################################################
2626
# Preconfiguring the Environment;
@@ -113,4 +113,4 @@ basyx.backend = InMemory
113113
# basyx.submodelrepository.feature.experimental.search.indexname=sm-index-test
114114
# spring.elasticsearch.uris=http://localhost:9200
115115
# spring.elasticsearch.username=elastic
116-
# spring.elasticsearch.password=vtzJFt1b
116+
# spring.elasticsearch.password=vtzJFt1b

basyx.aasregistry/basyx.aasregistry-feature-search/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.fasterxml.jackson.core</groupId>
3232
<artifactId>jackson-core</artifactId>
33-
<version>2.20.1</version>
33+
<version>2.21.0</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>com.fasterxml.jackson.core</groupId>

basyx.aasregistry/docker-compose/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ services:
8080
- basyx
8181

8282
mongodb:
83-
image: mongo:5.0.10
83+
image: mongo:8
8484
container_name: mongodb
8585
environment:
8686
MONGO_INITDB_ROOT_USERNAME: admin

basyx.common/basyx.authorization/src/main/java/org/eclipse/digitaltwin/basyx/authorization/CommonSecurityConfiguration.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
3434
import org.springframework.security.oauth2.server.resource.authentication.JwtGrantedAuthoritiesConverter;
3535
import org.springframework.security.web.SecurityFilterChain;
36+
import org.springframework.web.cors.CorsConfigurationSource;
3637

3738
/**
3839
* Common configurations for security
@@ -43,9 +44,16 @@
4344
@ConditionalOnExpression("#{${" + CommonAuthorizationProperties.ENABLED_PROPERTY_KEY + ":false}}")
4445
public class CommonSecurityConfiguration {
4546

47+
private final CorsConfigurationSource corsConfigurationSource;
48+
49+
public CommonSecurityConfiguration(CorsConfigurationSource corsConfigurationSource) {
50+
this.corsConfigurationSource = corsConfigurationSource;
51+
}
52+
4653
@Bean
4754
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
4855
http
56+
.cors(cors -> cors.configurationSource(corsConfigurationSource))
4957
.authorizeHttpRequests(authorize -> authorize
5058
.requestMatchers("/actuator/health/**").permitAll()
5159
.requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()

basyx.common/basyx.http/src/main/java/org/eclipse/digitaltwin/basyx/http/BaSyxHTTPConfiguration.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
import org.springframework.context.annotation.Bean;
3636
import org.springframework.context.annotation.Configuration;
3737
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
38+
import org.springframework.web.cors.CorsConfiguration;
39+
import org.springframework.web.cors.CorsConfigurationSource;
40+
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
3841
import org.springframework.web.servlet.config.annotation.CorsRegistry;
3942
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
4043

@@ -103,4 +106,45 @@ private void configureOrigins(String[] allowedOrigins, String[] allowedMethods,
103106
}
104107
};
105108
}
109+
110+
/**
111+
* Creates a {@link CorsConfigurationSource} that can be used by Spring Security
112+
* to apply CORS headers even on error responses (e.g., 401, 403).
113+
* This ensures consistent CORS behavior between Spring MVC and Spring Security.
114+
*
115+
* @param configurationUrlProviders
116+
* @param allowedOrigins
117+
* @param allowedMethods
118+
* @return
119+
*/
120+
@Bean
121+
public CorsConfigurationSource corsConfigurationSource(List<CorsPathPatternProvider> configurationUrlProviders,
122+
@Value("${basyx.cors.allowed-origins:}") String[] allowedOrigins,
123+
@Value("${basyx.cors.allowed-methods:}") String[] allowedMethods) {
124+
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
125+
126+
if (allowedOrigins.length == 0 && allowedMethods.length == 0) {
127+
return source;
128+
}
129+
130+
CorsConfiguration configuration = new CorsConfiguration();
131+
132+
if (allowedOrigins.length > 0) {
133+
configuration.setAllowedOriginPatterns(Arrays.asList(allowedOrigins));
134+
}
135+
136+
if (allowedMethods.length > 0) {
137+
configuration.setAllowedMethods(Arrays.asList(allowedMethods));
138+
}
139+
140+
configuration.setAllowedHeaders(List.of("*"));
141+
configuration.setAllowCredentials(true);
142+
143+
for (CorsPathPatternProvider provider : configurationUrlProviders) {
144+
logger.info("Registering CORS configuration for path pattern: " + provider.getPathPattern());
145+
source.registerCorsConfiguration(provider.getPathPattern(), configuration);
146+
}
147+
148+
return source;
149+
}
106150
}

basyx.conceptdescriptionrepository/basyx.conceptdescriptionrepository-feature-search/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<dependency>
3939
<groupId>com.fasterxml.jackson.core</groupId>
4040
<artifactId>jackson-core</artifactId>
41-
<version>2.20.1</version>
41+
<version>2.21.0</version>
4242
</dependency>
4343
<dependency>
4444
<groupId>com.fasterxml.jackson.core</groupId>

basyx.submodelregistry/basyx.submodelregistry-feature-search/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<dependency>
3131
<groupId>com.fasterxml.jackson.core</groupId>
3232
<artifactId>jackson-core</artifactId>
33-
<version>2.20.1</version>
33+
<version>2.21.0</version>
3434
</dependency>
3535
<dependency>
3636
<groupId>com.fasterxml.jackson.core</groupId>

basyx.submodelregistry/docker-compose/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ services:
8080
- basyx-submodel
8181

8282
mongodb:
83-
image: mongo:5.0.10
83+
image: mongo:8
8484
container_name: mongodb
8585
environment:
8686
MONGO_INITDB_ROOT_USERNAME: admin

basyx.submodelrepository/basyx.submodelrepository-feature-search/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
<dependency>
4141
<groupId>com.fasterxml.jackson.core</groupId>
4242
<artifactId>jackson-core</artifactId>
43-
<version>2.20.1</version>
43+
<version>2.21.0</version>
4444
</dependency>
4545
<dependency>
4646
<groupId>com.fasterxml.jackson.core</groupId>

0 commit comments

Comments
 (0)