-
Notifications
You must be signed in to change notification settings - Fork 26.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature 3.3] Triple Rest Cors Support (#14073)
* feat(): add cors key * feat(): add base cors class * feat(): add cors class in rpc-triple and rest-spring * feat(): add cors class in rpc-triple and rest-spring * test(): add rpc-triple cors test * fix(): fix CorsUtil bug * fix(): fix CorsUtil bug * fix(): fix objectUtil bug * fix(): fix corsmeta set bug * fix(): fix config load fail bug * fix(): option method can not be look fail * fix(): CorsMeta method will null * fix(): request-header not set will fail * refactor(): improve CorsMeta CorsProcess some code * fix(): coreMeta combine priority * test(): remove rest-spring cors test to sample * docs(): add docs * revert(): test version * fix(): getCorsMeta can be null * fix(): combine can be null * fix(): save option and vary bug * fix(): pom version * fix(): spring version will cause allowPrivateWork resolve error * fix(): ci * refactor(): delete useless code * refactor(): accept some sonarcloud issue * refactor(): add @nullable to point the CorsMeta Attributes * refactor(): style * fix(): fix prelight logic * fix(): remove credential & privateNetWork report * refactor(): Move globalMetaMerge in RequestMappingResolver * refactor(): use array replace corsConfig string * refactor(): move CorsProcessor to CorsHeaderFilterAdapter * fix(): fix unit test * fix(): fix test failure * fix(): delete useless param * fix(): fix sonarcloud * fix(): fix wrong class place & naming * fix(): fix wrong static global corsMeta * fix(): refactor CorsUtil from sonar issue * feat(rest): refine cors support * feat(rest): refine cors support * feat(rest): refine cors support bugfix * fix(): getBoolean will throw exception when null * fix(rest-spring): fix crossOrigin allowCredentials is string * fix(): fix globalCorsMeta load null * fix(): fix vary header bug * fix(): fix unit test && Fix cors specification * fix(): fix pom * fix(): fix combine bug * fix(): fix some sonar issue * fix(): fix style * feat(rest): refine cors support * fix(): fix style * fix(): fix needed sonar issue * refactor(): refactor CorsMeta.combine() and add comment * fix(): Replenish license * fix(): update test * test(): Refactor the test class and add credential test cases * test(): Refactor the test class and add credential test cases * fix(rest): revert api HeaderFilter * fix(): accept sonar issue --------- Co-authored-by: Sean Yang <[email protected]> Co-authored-by: earthchen <[email protected]>
- Loading branch information
1 parent
8368262
commit 1f6d441
Showing
19 changed files
with
1,301 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
dubbo-common/src/main/java/org/apache/dubbo/config/CorsConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.dubbo.config; | ||
|
||
import java.io.Serializable; | ||
|
||
public class CorsConfig implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
/** | ||
* A list of origins for which cross-origin requests are allowed. Values may be a specific domain, e.g. | ||
* {@code "https://domain1.com"}, or the CORS defined special value {@code "*"} for all origins. | ||
* <p>By default this is not set which means that no origins are allowed. | ||
* However, an instance of this class is often initialized further, e.g. for {@code @CrossOrigin}, via | ||
* {@code org.apache.dubbo.rpc.protocol.tri.rest.mapping.meta.CorsMeta.Builder#applyDefault()}. | ||
*/ | ||
private String[] allowedOrigins; | ||
|
||
/** | ||
* Set the HTTP methods to allow, e.g. {@code "GET"}, {@code "POST"}, | ||
* {@code "PUT"}, etc. The special value {@code "*"} allows all methods. | ||
* <p>If not set, only {@code "GET"} and {@code "HEAD"} are allowed. | ||
* <p>By default this is not set. | ||
*/ | ||
private String[] allowedMethods; | ||
|
||
/** | ||
* /** | ||
* Set the list of headers that a pre-flight request can list as allowed | ||
* for use during an actual request. The special value {@code "*"} allows | ||
* actual requests to send any header. | ||
* <p>By default this is not set. | ||
*/ | ||
private String[] allowedHeaders; | ||
|
||
/** | ||
* Set the list of response headers that an actual response might have | ||
* and can be exposed to the client. The special value {@code "*"} | ||
* allows all headers to be exposed. | ||
* <p>By default this is not set. | ||
*/ | ||
private String[] exposedHeaders; | ||
|
||
/** | ||
* Whether user credentials are supported. | ||
* <p>By default this is not set (i.e. user credentials are not supported). | ||
*/ | ||
private Boolean allowCredentials; | ||
|
||
/** | ||
* Configure how long, as a duration, the response from a pre-flight request | ||
* can be cached by clients. | ||
*/ | ||
private Long maxAge; | ||
|
||
public String[] getAllowedOrigins() { | ||
return allowedOrigins; | ||
} | ||
|
||
public void setAllowedOrigins(String[] allowedOrigins) { | ||
this.allowedOrigins = allowedOrigins; | ||
} | ||
|
||
public String[] getAllowedMethods() { | ||
return allowedMethods; | ||
} | ||
|
||
public void setAllowedMethods(String[] allowedMethods) { | ||
this.allowedMethods = allowedMethods; | ||
} | ||
|
||
public String[] getAllowedHeaders() { | ||
return allowedHeaders; | ||
} | ||
|
||
public void setAllowedHeaders(String[] allowedHeaders) { | ||
this.allowedHeaders = allowedHeaders; | ||
} | ||
|
||
public String[] getExposedHeaders() { | ||
return exposedHeaders; | ||
} | ||
|
||
public void setExposedHeaders(String[] exposedHeaders) { | ||
this.exposedHeaders = exposedHeaders; | ||
} | ||
|
||
public Boolean getAllowCredentials() { | ||
return allowCredentials; | ||
} | ||
|
||
public void setAllowCredentials(Boolean allowCredentials) { | ||
this.allowCredentials = allowCredentials; | ||
} | ||
|
||
public Long getMaxAge() { | ||
return maxAge; | ||
} | ||
|
||
public void setMaxAge(Long maxAge) { | ||
this.maxAge = maxAge; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.