-
Notifications
You must be signed in to change notification settings - Fork 564
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
Fix CorsSupport default behavior #1714
Merged
Merged
Conversation
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
…default behavior Signed-off-by: tim.quinn@oracle.com <tim.quinn@oracle.com>
tjquinno
changed the title
Fix CorsSupport default behavior
WIP - Fix CorsSupport default behavior
May 2, 2020
…ive developers more control over the routing they build; developers need to add CrossOriginConfigs in the order they should be checked
tjquinno
changed the title
WIP - Fix CorsSupport default behavior
Fix CorsSupport default behavior
May 2, 2020
tjquinno
changed the title
Fix CorsSupport default behavior
WIP - Fix CorsSupport default behavior
May 4, 2020
…r OPTIONS but needed to use the method the pre-flight request was asking for
…t not have at least one character to consume
tjquinno
changed the title
WIP - Fix CorsSupport default behavior
Fix CorsSupport default behavior
May 5, 2020
tomas-langer
requested changes
May 5, 2020
microprofile/cors/src/main/java/io/helidon/microprofile/cors/CorsSupportMp.java
Outdated
Show resolved
Hide resolved
webserver/cors/src/main/java/io/helidon/webserver/cors/CorsSupportHelper.java
Outdated
Show resolved
Hide resolved
webserver/cors/src/main/java/io/helidon/webserver/cors/CrossOriginConfig.java
Outdated
Show resolved
Hide resolved
…e defensive about presence or absence of leading / in MP request path
tomas-langer
approved these changes
May 5, 2020
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.
LGTM
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #1713
There are two aspects to this.
A. If the developer creates a
CorsSupport
instance it will provide the default (wild carded) behavior if no specific settings were provided. In particular, passing amissing
config node toCorsSupport.create(Config)
creates a newCorsSupport
instance with the default wildcarding behavior; CORS also logs anINFO
message to this effect in case the developer actually expected the config node to contain something.There is a new
CrossOriginConfig.create()
method which developers can use to include the default wild carded behavior as they build aCorsSupport
instance.(I refactored many methods from
Aggregator
to its newBuilder
inner class so the diffs look deceptively large.)B. All cross-origin info added to a
CorsSupport
instance is now searched sequentially in order of addition to the builder. TheAggregator
which collects the cross-origin information (basically asCrossOriginConfig
instances) used to use a map, keyed by the path expression. This could lead to confusion if the developer provided multipleCrossOriginConfig
objects with the same path (or with no path which is essentially the same thing) because later additions would overwrite earlier ones.This PR changes the internal data structure to a
List
and maintains the order in which the developer supplies theCrossOriginConfig
information. When requests arrive, the Helidon CORS implementation scans the list in order-of-addition and uses the first that matches the request's path and HTTP method.This gives the developer complete control by making sure the order in which the application adds
CrossOriginConfig
s matches the needs of the application, without the Helidon CORS code imposing a "one-setting-per-path" restriction.