Skip to content
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

Cors headers #2021

Merged
merged 135 commits into from
Jun 17, 2017
Merged

Cors headers #2021

merged 135 commits into from
Jun 17, 2017

Conversation

naunga
Copy link
Contributor

@naunga naunga commented Oct 20, 2016

This addresses issue #796.

Adds two new top-level configuration options:

  • enable_cors : A boolean value (not a string, so omit the quotes in the config file). Defaults to false, set to true to enable.
  • allowed_origins : A string value that is a regex for origins that are allowed to make cross-origin requests. This defaults to ".*" which will allow all origins, but only applies if enable_cors is set to true.

I made the decision to make this a top-level option, because at the end of the day all CORs does is signal to a browser that the server is willing to communicate with it and which HTTP methods it will accept. It will not have an effect on whether or not stored secrets can be accessed.

Aaron Salvo added 18 commits October 10, 2016 17:58
… are allowed to make cross-origin requests.
@jefferai
Copy link
Member

Thanks for submitting this. As I said in #796, it needs to be determined whether this should be a value configured via Vault's API and stored internally or set in the config file.

@naunga
Copy link
Contributor Author

naunga commented Oct 21, 2016

@jefferai : Yep, and once that's determined I'll be happy to refactors things as needed. I figured though that getting things this far would be helpful.

You know that and I like to write Go. So any chance I get to do that is a win.

Cheers.

@jefferai
Copy link
Member

jefferai commented Nov 7, 2016

Hi @naunga,

We had a discussion internally -- we'd like to have CORS configured via the API so it is authenticated and lives in Vault's barrier, with the configuration endpoint living at sys/config/cors. If you're willing to change your code to behave that way it'd be great!

@naunga
Copy link
Contributor Author

naunga commented Nov 7, 2016

Absolutely. I'm going to be traveling a bit this month. So I'll be slower than I was the first time, but definitely will get it refactored.

@jefferai
Copy link
Member

jefferai commented Nov 7, 2016

Great!

@vishalnayak
Copy link
Member

@moolshankar 0.7.2 does not have these changes. The PR is not yet merged.

@moolshankar
Copy link

@vishalnayak .. Oh okay, May I know when this PR is expected to be merged? If it is soon then we can wait or if it is going to take time, then I might need to add a server side layer as a workaround which I was trying to avoid actually.

Thanks for quick responses :)

@vishalnayak
Copy link
Member

@moolshankar The PR is in good shape. It needs review from other team members as well and all are pretty swamped at the moment. Hopefully this should get through in the next release, which is not very far. Can't promise a precise time frame though.

@moolshankar
Copy link

@vishalnayak .... Cool. Thanks a lot Vishal for your help.

@jefferai
Copy link
Member

@moolshankar You could always build your own Vault binary with this PR merged in locally.

@moolshankar
Copy link

@jefferai .... Thanks for the tip Jeff. I will try that.

@jefferai jefferai modified the milestones: 0.7.3, 0.7.4 Jun 8, 2017

// IsEnabled returns the value of CORSConfig.isEnabled
func (c *CORSConfig) IsEnabled() bool {
c.RLock()
Copy link
Member

Choose a reason for hiding this comment

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

Can we use atomic.(Load,Save)Uint32 instead of locking here? The uints in use can be const values to make for meaningful comparisons.

I'm not sure for AllowedOrigins if it'd be faster to keep the lock or to use atomic.Value.

@@ -62,6 +62,7 @@ func NewSystemBackend(core *Core, config *logical.BackendConfig) (logical.Backen
"replication/primary/secondary-token",
"replication/reindex",
"rotate",
"config/*",
Copy link
Member

Choose a reason for hiding this comment

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

This is too broad. Arguably config/cors*, or nothing.

@jefferai
Copy link
Member

I'm going to make these changes post-merge. Thanks for all the hard work on this!

@jefferai jefferai merged commit 362227c into hashicorp:master Jun 17, 2017
jefferai added a commit that referenced this pull request Jun 17, 2017
@naunga
Copy link
Contributor Author

naunga commented Jun 17, 2017

Cool. It was my pleasure. Now just gotta figure out what to work on next. 🤔

@naunga naunga deleted the cors-headers branch June 19, 2017 14:42
chrishoffman pushed a commit that referenced this pull request Jun 21, 2017
* oss/master: (161 commits)
  update gitignore
  changelog++
  Exclude /sys/leases/renew from registering with expiration manager (#2891)
  More cleanup
  Clarify/fix some configuration info.
  Add a convenience function for copying a client (#2887)
  Better error messages using ListObjects than using HeadBucket. Might be a bigger request but messages are better than BadRequest, how this changes effect the messages are in the issue (#2892)
  Add ACL info to Consul configuration page
  Return error on bad CORS and add Header specification to API request primitive
  Add Zyborg.Vault PowerShell module to libs list (#2869)
  changelog++
  CouchDB physical backend (#2880)
  Fix root paths test
  Add missing datadog vendored lib
  changelog++
  Fix up CORS.
  Cors headers (#2021)
  Address review feedback
  Fix the test error message
  Added utility on router to fetch mount entry using its ID
  ...
@jefferai jefferai modified the milestones: 0.7.4, 0.8.0 Jul 24, 2017
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.

5 participants