-
Notifications
You must be signed in to change notification settings - Fork 26.4k
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
[Feature 3.3] Triple Rest Cors Support #14073
Merged
Merged
Changes from 63 commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
96b82c2
feat(): add cors key
Rawven 513789a
feat(): add base cors class
Rawven 6897c8f
feat(): add cors class in rpc-triple and rest-spring
Rawven a21d7a2
feat(): add cors class in rpc-triple and rest-spring
Rawven f6594c5
test(): add rpc-triple cors test
Rawven cf42edb
fix(): fix CorsUtil bug
Rawven 352e974
fix(): fix CorsUtil bug
Rawven 32015a3
fix(): fix objectUtil bug
Rawven c785a5e
fix(): fix corsmeta set bug
Rawven 194bbc5
fix(): fix config load fail bug
Rawven 995b87b
fix(): option method can not be look fail
Rawven f45cc0c
fix(): CorsMeta method will null
Rawven 755d39b
fix(): request-header not set will fail
Rawven 7efd588
refactor(): improve CorsMeta CorsProcess some code
Rawven e743a54
fix(): coreMeta combine priority
Rawven 5445bbe
test(): remove rest-spring cors test to sample
Rawven d089ad3
docs(): add docs
Rawven e64fad4
revert(): test version
Rawven 342c64f
fix(): getCorsMeta can be null
Rawven 8137167
fix(): combine can be null
Rawven 791c905
fix(): save option and vary bug
Rawven 81fff53
fix(): pom version
Rawven 8be4988
fix(): spring version will cause allowPrivateWork resolve error
Rawven a93b3e8
fix(): ci
Rawven fd60c82
Merge branch '3.3-triple-cors' into 3.3
Rawven e1fb1e7
Merge pull request #4 from Rawven/3.3
Rawven fa1020e
refactor(): delete useless code
Rawven 8a4c279
refactor(): accept some sonarcloud issue
Rawven 5b44226
refactor(): add @Nullable to point the CorsMeta Attributes
Rawven c3c0771
refactor(): style
Rawven 1875011
fix(): fix prelight logic
Rawven a7912fa
fix(): remove credential & privateNetWork report
Rawven 6f4b817
refactor(): Move globalMetaMerge in RequestMappingResolver
Rawven 3cb3af7
refactor(): use array replace corsConfig string
Rawven 4eb0546
refactor(): move CorsProcessor to CorsHeaderFilterAdapter
Rawven ff60f3d
fix(): fix unit test
Rawven 1cfab7f
fix(): fix test failure
Rawven 4fcb1cc
fix(): delete useless param
Rawven 639ca84
fix(): fix sonarcloud
Rawven e1b4a7f
Merge branch '3.3' into 3.3-triple-cors
Rawven 73951bd
fix(): fix wrong class place & naming
Rawven 1326607
fix(): fix wrong static global corsMeta
Rawven f100803
Merge remote-tracking branch 'origin/3.3-triple-cors' into 3.3-triple…
Rawven 70f0404
fix(): refactor CorsUtil from sonar issue
Rawven 854c9bb
feat(rest): refine cors support
oxsean 5f9bfd7
feat(rest): refine cors support
oxsean 5b01155
Merge remote-tracking branch 'oxsean/triple-cors' into 3.3-triple-cors
Rawven 4d84717
feat(rest): refine cors support bugfix
oxsean d3b3eaf
fix(): getBoolean will throw exception when null
Rawven c8dcb9e
fix(rest-spring): fix crossOrigin allowCredentials is string
Rawven 87f6423
fix(): fix globalCorsMeta load null
Rawven 360e9e8
fix(): fix vary header bug
Rawven 8269417
fix(): update unit test
Rawven 9be5013
fix(): fix unit test && Fix cors specification
Rawven e503110
Merge branch '3.3' into 3.3-triple-cors
Rawven e90185f
fix(): fix pom
Rawven 4385532
fix(): fix combine bug
Rawven c0026bd
Merge remote-tracking branch 'origin/3.3-triple-cors' into 3.3-triple…
Rawven 00aa06a
fix(): fix some sonar issue
Rawven c4b501a
fix(): fix style
Rawven 8bae639
feat(rest): refine cors support
oxsean 88ebc5a
fix(): fix style
Rawven 12d1b87
fix(): fix needed sonar issue
Rawven c04a61f
refactor(): refactor CorsMeta.combine() and add comment
Rawven c61a130
fix(): Replenish license
Rawven a9467cc
Merge branch '3.3' into 3.3-triple-cors
Rawven 6151c67
fix(): update test
Rawven e399e92
Merge remote-tracking branch 'origin/3.3-triple-cors' into 3.3-triple…
Rawven b7cb8c7
test(): Refactor the test class and add credential test cases
Rawven db4503b
test(): Refactor the test class and add credential test cases
Rawven 1a9d770
Merge branch '3.3' into 3.3-triple-cors
EarthChen edf9363
fix(rest): revert api HeaderFilter
oxsean 852ad86
fix(): accept sonar issue
Rawven File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change this api?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't notice that this API was introduced in 3.0. indeed shouldn't be modified, I'll revert it later. However, this return value not being used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert have done