Skip to content

DRILL-4690: CORS in REST API#507

Closed
PythonicNinja wants to merge 7 commits intoapache:masterfrom
PythonicNinja:DRILL-4690
Closed

DRILL-4690: CORS in REST API#507
PythonicNinja wants to merge 7 commits intoapache:masterfrom
PythonicNinja:DRILL-4690

Conversation

@PythonicNinja
Copy link
Contributor

@PythonicNinja PythonicNinja commented May 21, 2016

zrzut ekranu 2016-05-22 o 00 33 39

import java.io.IOException;


public class CrossOriginFilter implements Filter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any specific reason on why creating a new filter versus using CrossOriginFilter provided by Jetty? see http://www.eclipse.org/jetty/documentation/current/cross-origin-filter.html for details

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can import, I just didn't want to add dependency to pom.xml. What is your opinion on that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since Drill project is already using jetty, it's probably fine to add this dependency (if not already present)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will update this PR accordingly.

@PythonicNinja
Copy link
Contributor Author

@laurentgo is it ok now? If yes what should be next step?

pom.xml Outdated
<version>4.0.27.Final</version>
</dependency>

<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's probably not the right place to add this dependency. exec/java-exec/pom.xml seems a more appropriate place. Also, you should use the same version as other jetty artifacts. If I remember correctly 9.3.9 is Java8 only whereas Drill still supports Java7.

@laurentgo
Copy link
Contributor

I think the place where the dependency is added should be modified before getting this review merged. Also, I'm a simple commentator, not a committer for the project, so you would have to ping one of those to get it reviewed and merged.

http: {
enabled: true,
ssl_enabled: false,
cors_enabled: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps we should consider extending cors configuration with

http: {
  cors: {
    enabled: true,
    allowedOrigins: ['*.mydomain.com', '*.someother.net'], --> configures Access-Control-Allow-Origin
    allowedMethods: ['option', 'get', 'post', 'some-other'], --> configures  Access-Control-Allow-Methods
    allowedHeaders: ['some-allowed-header'], --> configures Access-Control-Expose-Headers 
    credentials: true | false -- >  configures Access-Control-Allow-Credentials
  }
}

I am probably missing few in the list but I find these options essential.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will extend that configuration.

@hnfgns
Copy link
Contributor

hnfgns commented May 25, 2016

Looks pretty good. I will make another pass once reviews are addressed.

@PythonicNinja
Copy link
Contributor Author

I have updated PR according to your and laurentgo ideas. @hnfgns: Can you check second round of review?

@hnfgns
Copy link
Contributor

hnfgns commented Jun 2, 2016

+1 this looks good to me but can one of you guys take a look, test and commit?
@adeneche @sudheeshkatkam

@PythonicNinja
Copy link
Contributor Author

@hnfgns @adeneche @sudheeshkatkam any udpates?

@sudheeshkatkam
Copy link
Contributor

I am not familiar with CORS. One question: why is this enabled by default?

Also, there is a discussion about not increasing the size of the jdbc-all jar (subject: drill-jdbc-all-1.7.0-SNAPSHOT.jar max size). Any way to avoid that change?

session_max_idle_secs: 3600 # Default value 1hr
session_max_idle_secs: 3600, # Default value 1hr
cors: {
enabled: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would default cors.enabled to false and/or set the access-cotrol-allow-origin to null. Ideally, only the end user should be able to enable CORS for all sites.
Otherwise looks good to me.

reduced size of dependencies (reset maxsize)
parthchandra pushed a commit to parthchandra/drill that referenced this pull request Jul 22, 2016
Added CrossOriginFilter to WebServer based on option HTTP_ENABLE_CORS
Fixed issues related to style
Restricted headers, added run of filterChain
Filter from org.eclipse.jetty.servlets
Enabled configuration, jetty version 9.1.5, restrict filtered paths
CORS by default disabled, reduced size of dependencies (reset maxsize)

This closes apache#507
@asfgit asfgit closed this in 855873e Jul 23, 2016
@chriddyp
Copy link

chriddyp commented Oct 8, 2016

Thanks for adding this! Are there docs anywhere on how to configure this option?

@parthchandra
Copy link
Contributor

Look in drill-override-example.conf that has the example configuration. You'll need to add something similar to your drill-override.conf.

ashevchuk123 pushed a commit to mapr/incubator-drill that referenced this pull request Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants