From 8f7f0527ca643da86d8596ef8d7968e7cd40cc7e Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 14 Nov 2026 03:17:11 +0000 Subject: [PATCH] fix: accept the wildcard CORS origin when credentials are allowed Co-Authored-By: jason.han --- .../openmbee/mms/example/config/ExampleSecurityConfig.java | 7 ++++++- example/src/main/resources/application-test.properties | 4 ++++ example/src/main/resources/application.properties.example | 5 ++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/example/src/main/java/org/openmbee/mms/example/config/ExampleSecurityConfig.java b/example/src/main/java/org/openmbee/mms/example/config/ExampleSecurityConfig.java index d7ccd3397..385e77bc9 100644 --- a/example/src/main/java/org/openmbee/mms/example/config/ExampleSecurityConfig.java +++ b/example/src/main/java/org/openmbee/mms/example/config/ExampleSecurityConfig.java @@ -75,7 +75,12 @@ private CorsFilter corsFilter() { CorsConfiguration config = new CorsConfiguration(); config.setAllowCredentials(true); for(String origin: allowedOrigins.split(",")) { - config.addAllowedOrigin(origin); + if (CorsConfiguration.ALL.equals(origin.trim())) { + // "*" cannot be an allowed origin when credentials are allowed; as a pattern the caller's origin is echoed. + config.addAllowedOriginPattern(CorsConfiguration.ALL); + } else { + config.addAllowedOrigin(origin); + } } config.addAllowedHeader(ORIGIN); config.addAllowedHeader(CONTENT_TYPE); diff --git a/example/src/main/resources/application-test.properties b/example/src/main/resources/application-test.properties index 3e65c69df..3ce46a231 100644 --- a/example/src/main/resources/application-test.properties +++ b/example/src/main/resources/application-test.properties @@ -4,6 +4,10 @@ mms.admin.password=test mms.stream.batch.size=100000 +# Comma separated list of allowed cross site origins, e.g. https://ve.example.org,https://other.example.org +# Credentials are allowed for every origin listed here. "*" allows any origin: the caller's origin is echoed +# back, so any website may make credentialed cross-origin requests to MMS. That lets a browser client such as +# View Editor work out of the box; listing the explicit origins is the stricter setting, use it in production. cors.allowed.origins=* jwt.secret=12345678901234567890123456789012 diff --git a/example/src/main/resources/application.properties.example b/example/src/main/resources/application.properties.example index 59ee2a251..72cd77793 100644 --- a/example/src/main/resources/application.properties.example +++ b/example/src/main/resources/application.properties.example @@ -5,7 +5,10 @@ mms.admin.password=test mms.stream.batch.size=100000 mms.optimize-for-federated=true -#Comma Separated list of allowed cross site origins +# Comma separated list of allowed cross site origins, e.g. https://ve.example.org,https://other.example.org +# Credentials are allowed for every origin listed here. "*" allows any origin: the caller's origin is echoed +# back, so any website may make credentialed cross-origin requests to MMS. That lets a browser client such as +# View Editor work out of the box; listing the explicit origins is the stricter setting, use it in production. cors.allowed.origins=* jwt.secret=make_me_something_really_long