-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
bug: If allow_origins_by_regex is not nil,using other domain is also verified. #9027
Comments
I don't think this is a bug apisix/apisix/plugins/cors.lua Lines 298 to 302 in c159f04
|
@mscb402Hi, At present, many companies have many security requirements for cors and setting Access-Control-Allow-Origin to * is not allowed. Only the specified source domain name is allowed to pass. According to the current plug-in processing logic, If conf.allow_origins is set to * and Access-Control-Allow-Origin will still return * even if allow_origins_by_regex is set to the specified range of domain names. This is not safe. |
I think you can set |
@mscb402 Hi, many companies only wants to the specified range. So they set allow_origins_by_regex to sspecified range and not set allow_origins. At the time, the default value of allow_origins is * and all origins will be passed. This is not in compliance with safety regulations. |
Sounds good! |
We are having the same problem. We would like to only use |
Current Behavior
allow_origins: Origins to allow CORS
allow_origins_by_regex: Regex to match with origin for enabling CORS.
As a user, When I set the value of allow_origins_by_regex,the orgins to allow CORS must be in the range and other origin will be failed. But it's not ready.
In code,the default value of allow orgins is ‘*’ and all origins will be passed and allow_origins_by_regex has not effect.
Expected Behavior
In my opinion,allow_origins_by_regex should be considered first. If the allow_origins_by_regex has no value. it can judge using allow_origins.
Error Logs
No response
Steps to Reproduce
set the value of allow_origins_by_regex is '.\.domain.com' and allow_origins is ''. The use of other domain names is also verified.
Environment
apisix version
):uname -a
):openresty -V
ornginx -V
):curl http://127.0.0.1:9090/v1/server_info
):luarocks --version
):The text was updated successfully, but these errors were encountered: