-
Notifications
You must be signed in to change notification settings - Fork 3.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 #1607
Comments
Trying to understand. Is the issue that you would prefer more flexibility with the allowed-origins header? Rather than having to have configuration for a.y.z, b.y.z, c.y.z...you would rather have one configuration for *.y.z? If that is the case, do you know any other reverse proxy that allows such configuration? |
@tony-clarke-amdocs yes that's correct. For example vert.x I ended up extending Spring |
I think Spring supports * to allow all origins but not *.y.z. I suspect there is a good reason for this. I guess @rstoyanchev would be able to comment here. |
I am not aware of any reasons why we do not have pattern support other than |
Looks like this should be a feature request in framework then. I can't transfer this since the projects are in different orgs. @korektur please open a new issue there and link to this one. |
Opened an issue in framework: spring-projects/spring-framework#24763 |
Is your feature request related to a problem? Please describe.
Gateway can has multiple underlying services and numerous services using it as an entry point into those services. In case of browser preflight request it does make sense to have global cors policy definde on gateway level and respond to them directly from gateway instead of routing those to underlying services. However in case where there are many services calling gateway it makes it hard to keep track of all possible origins that are required to be defined for that configuration. If it's an internal gateway that is supposed to be accepting requests only from other firm services it makes sense to just specify something like ".companyHost.com" and accept all requests with origin that ends with this host.
Describe the solution you'd like
I suggest implementing a new
CorsConfiguration
, that will override methodcheckOrigin
to use pattern matching, something like:Since CORS header specification forbids to return something like "*.companyHost.com", and requires either a "*" or a full host name, in this case we'll return a request origin which would be a full host name.
Describe alternatives you've considered
Considered allowed origing as a "*" but this wouldn't work in case when credentials are passed. Also as mentioned earlier specifying list of all possible origins calling gateway is not a good option in case when it's a widely used service, it will also make it more dificult to onboard new services.
The text was updated successfully, but these errors were encountered: