Skip to content

fix: accept the wildcard CORS origin when credentials are allowed - #286

Merged
HuiJun merged 1 commit into
developfrom
fix/cors-wildcard-origin-login
Nov 15, 2026
Merged

HuiJun merged 1 commit into
developfrom
fix/cors-wildcard-origin-login

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

With the shipped default cors.allowed.origins=*, every request carrying an Origin header answered HTTP 500, so a browser client such as View Editor could not log in. corsFilter() in ExampleSecurityConfig sets allowCredentials(true) and added each configured entry with addAllowedOrigin; Spring rejects * in that combination (IllegalArgumentException: When allowCredentials is true, allowedOrigins cannot contain the special value "*").

The * entry is now registered as an origin pattern; every other entry is registered as before:

if ("*".equals(origin.trim())) config.addAllowedOriginPattern("*");
else                           config.addAllowedOrigin(origin);

Behaviour and trade-off

  • cors.allowed.origins=*: MMS echoes the caller's origin in Access-Control-Allow-Origin together with Access-Control-Allow-Credentials: true. Any website may therefore make credentialed cross-origin requests to MMS. MMS is stateless and takes its token in the Authorization header, so the ambient credential a foreign site could ride on is HTTP Basic credentials the browser has cached for the MMS origin; a deployment that adds cookie-based authentication in front of MMS is more exposed.
  • An explicit origin list is unchanged and is the stricter setting: listed origins are allowed with credentials, unlisted origins get 403. Use it in production.

Both application.properties.example and application-test.properties now say this next to the property.

Verification

Compose stack (SPRING_PROFILES_ACTIVE=test), real requests with curl, before (develop) and after:

Request *, before *, after http://localhost:9001, before and after
OPTIONS /authentication (Origin: http://localhost:9001, request header content-type) 500 200, Allow-Origin: http://localhost:9001, Allow-Credentials: true 200, same headers
POST /authentication 500 200, token issued 200, token issued
OPTIONS /projects (request header authorization) 500 200 200
GET /projects with the bearer token 500 200 200
The same four from unlisted Origin: http://evil.example 500 200, origin echoed 403

Not tested: a browser session with View Editor against this build, and the Spring Boot 3 branch (#284). A trial merge of this branch with chore/spring-boot-3-migration is clean; addAllowedOriginPattern exists in Spring Web 6 as well.

Link to Devin session: https://nasa-jpl-demo.devinenterprise.com/sessions/c1ca43096c8046d6adec7631ee635d99
Open in Devin Desktop: https://nasa-jpl-demo.devinenterprise.com/desktop/session/c1ca43096c8046d6adec7631ee635d99?variant=devin
Requested by: @HuiJun


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

Co-Authored-By: jason.han <hanhuijun@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@HuiJun
HuiJun merged commit a4cba01 into develop Nov 15, 2026
4 checks passed
@devin-ai-integration
devin-ai-integration Bot deleted the fix/cors-wildcard-origin-login branch November 20, 2026 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant