-
Notifications
You must be signed in to change notification settings - Fork 265
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 support #501
Comments
+1 |
CORS support for GET requests implemented in PR #846. CORS support for PUT/POST request requires preflight requests through the OPTIONS method and it is deferred to a next PR. |
Onces preflight request will be implemented, edit the answer to these questions in SOF: |
+1 Freeboard (https://www.fiware.org/2015/07/13/fiware-orion-data-source-now-available-for-freeboard/) will not work without it on localhost, unless proxied. |
Hi there! |
The status is "not implemented". If you want to support the implemenation of CORS features in Orion, please use a +1 reaction on this issue. Thanks! |
+1 |
+1 |
In the mean-time, here is a work around: putting Orion behind a proxy.
|
I am working on this issue, can you please assign it to me? Assignment already done on Jira. |
@McMutton is assigned to this issue |
I have been reading the documentation and experimenting with Orion's service routines and I need some guidance before diving into coding. So, on CORS friendly mode, if we receive an
For example, this is what I did to handle the { "GET", ENT, ENT_COMPS_V2, ENT_COMPS_WORD, getEntities }, \
{ "POST", ENT, ENT_COMPS_V2, ENT_COMPS_WORD, postEntities }, \
{ "OPTIONS", ENT, ENT_COMPS_V2, ENT_COMPS_WORD, optionsGetPostOnly }, \
{ "*", ENT, ENT_COMPS_V2, ENT_COMPS_WORD, badVerbGetPostOnly }, \ But this means, we need to do the same for ALL the resources. I don’t see any easier way to do this since allowed methods vary for each resource. So my question is, do you think this is feasible or do we have some other mechanism in Orion which I am not aware of, that would do the same job without touching too many lines of code? |
The Thus, I think you would need to add an "OPTION" entry for each resource to which processing OPTION makes sense (all of them? I'm not sure, I'm not an expert in CORS ;). You are right there are many resources, but adding entries should be quite straighforward. What I'm not so sure if this each new "OPTION" entry involves creating a new handling function. Maybe you could factorize behaviour in one or a small set of handling functions. Actually, this strategy is used in the current code, look how Regarding .test, covering the OPTION case for all the resource could be overhelming (althoug if you want to be exahustive, no problem with it :). My suggestion is to cover a "sample" of them, large enough to be representative, but not too large. Hoping this feedback helps. Maybe @kzangeli could also give some implementation hint, as he is more familiar with the routing logic than me in the code. |
Thanks for your comment @fgalan. Yes, that was my thought, a small set of handling functions would be enough as in badVerb... handlers. My concern was with the new service vector definitions which seems to be inevitable :) And about the tests, I will probably post here again asking about the details of the coverage soon :) |
I have mostly completed the handling of OPTIONS request to the V2 API and the commit (in my fork) is really huge at this point: 21 changed files with 986 additions and 49 deletions. Please note that this does not include the unit and functional tests, so the final commit will include even bigger number of file and lines of code changes. Do you think is it feasible to review a huge PR like this? Should I divide the work between a few commits to have the PR more organized? Any suggestions? |
Yes, it's pretty big... Maybe spliting the work in several PRs, each one covering a small number of V2 API operations e2e (i.e. including the test for such samall number of operations)? |
Ok sure, I will divide the work in several PRs. Now that you mention it for only V2 API operations, I have to ask, are we going to enable CORS for V1 API operations as well? |
Ideally, it should cover both V2 and V1 API. Let's focus in V2 by the moment. Covering also V1 would depend on how much effort you can put on this ;) |
CORS preflight for |
Implemented for all the rest of NGSIv2 URLs in PR #3032 |
Some spin-off issue is pending (in particular, #3030) but I think we can consider CORS basic support completed and this issue (once that SOF questions has been edited) can be closed. At the end I think it doesn't worth the time to implement CORS for NGSIv1. NGSIv1 is fine for legacy integrations (although it would be deprecated sooner or later) but for new functionality (including CORS) let's focus on NGSIv2. |
It would be interesting to have a CLI switch (e.g.
-cors
) so Orion CB behaves in a "CORS friendly" mode, i.e. including theAccess-Request-XXXX
headers in the HTTP responses.The text was updated successfully, but these errors were encountered: