Skip to content
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

Allow wildcard origins in CORS middleware #2988

Open
ftruter opened this issue Mar 24, 2023 · 0 comments
Open

Allow wildcard origins in CORS middleware #2988

ftruter opened this issue Mar 24, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@ftruter
Copy link

ftruter commented Mar 24, 2023

Is your feature request related to a problem? Please describe.

We have one server that deals with several data silos, one per customer, and this is done via subdomain, e.g. ACME.my.app and PEAK.my.app, etc. As and when new customers sign up, we create new DNS entries, but have to recompile our server code and add yet another origin into the CORS configuration .any([...]).

Describe the solution you'd like

In addition to case any([String]) I would like case anyWildcard([NSRegularExpression]) so that I can code what amounts to "https://*.my.app" via NSRegularExpression("https://.*\\.my\\.app")
The caller creates the regular expressions once only during configuration and they are cached inside the configuration object.

Matching an incoming origin header to a short list of pre compiled regular expressions at runtime should be just a little more expensive than matching that origin in long list of strings. Regardless of the runtime performance, this enhancement will decouple the creation of a new customer from having to recompile the server code, even though we have automated this.

Describe alternatives you've considered

Scanning all the strings in the case .any(...) for wildcard characters "*" and "?" then converting those strings to NSRegularExpressions on the fly would be too much extra work at runtime, on every incoming request to the server. Plus, this may break someone's existing code in the wild.

Additional context

Please see Shelton-Development-Services#1 for an initial implementation.

@ftruter ftruter added the enhancement New feature or request label Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant