-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CorsConfiguration based on pattern matching #24763
Comments
Historically, we have built But indeed patterns like Any thoughts @rstoyanchev? |
Yes, I think it would be useful to support that. |
@rstoyanchev can I do the change myself and open a merge request? |
@korektur yes if you submit a pull request, we'll review it. |
More tests added. Closes spring-projectsgh-24763
More tests added. Combininig CorsConfiguration fixed. Closes spring-projectsgh-24763
More tests added. Combininig CorsConfiguration fixed. Closes spring-projectsgh-24763
@rstoyanchev I have opened a pull request - #25016 |
@rstoyanchev @sdeleuze can you review the merge request please? |
Superseded by #25016. |
More tests added. Combininig CorsConfiguration fixed. Closes spring-projectsgh-24763
Affects: Spring Web 5.2.4.RELEASE
Initial issue opened in Spring Cloud Gateway: spring-cloud/spring-cloud-gateway#1607
Application APIs can be called by multiple origins. For applications that represent some kind of platform within a company it often makes sense to accept all request from orings coming from company domain, basically accept all request with origin matching a pattern *.company.com. Currently default spring
CorsConfiguration
supports only list of origins, I think this might not be flexible enough, as it will require configuration change every time new application within a company wants to call that REST api (especially in case of an API Gateway).Proposal: add support for CORS configuration based on a pattern matching.
One option would'be, I guess, to extend existing
CorsConfiguration
class with additional fieldsallowedOriginPatterns
and modifycheckOrigin
to use this property.Or have separate
CorsConfiguration
implementation that is using pattern matching.While current solution is extendible and this approach can be implemented within the application itself, I think this should be a part of framework because it's a widely used functionality and is supported by other frameworks that are used for API implementation.
For example vert.x CorsHandler suipports that: https://github.com/vert-x3/vertx-web/blob/5cd7ecaa6bead1b246b5327537ee9b82c22187bc/vertx-web/src/main/java/io/vertx/ext/web/handler/CorsHandler.java#L42
Also, Kong supports pattern based origins as well.
The text was updated successfully, but these errors were encountered: