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

non-SSL requests on https://explorer.continuum.io/seeds #761

Open
ahmadia opened this issue Nov 8, 2015 · 12 comments
Open

non-SSL requests on https://explorer.continuum.io/seeds #761

ahmadia opened this issue Nov 8, 2015 · 12 comments
Labels
Milestone

Comments

@ahmadia
Copy link
Contributor

ahmadia commented Nov 8, 2015

ntent: The page at 'https://explorer.continuum.io/seeds/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://explorer.continuum.io/api/datawake/'. This request has been blocked; the content must be served over HTTPS.

Hot-fixing for now.

@ahmadia ahmadia added the bug label Nov 8, 2015
@ahmadia ahmadia added this to the v0.4 milestone Nov 8, 2015
@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

Note, I've already pulled out BasicAuthentication from the REST configuration, (using Session Authentication):

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework.authentication.SessionAuthentication',
    ),
    'DEFAULT_PERMISSION_CLASSES': (
        'rest_framework.permissions.AllowAny',
    ),
    'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',)
}

Other parts of the REST API work, it's something specific to this page/view.

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

@brittainhard - workaround is to ensure you've got trailing slashes on Django REST endpoints:

See jashkenas/backbone#848 for more details.

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

Please land the following patch when you get a chance:

diff --git a/source/base/static/base/js/backbone/trails_backbone.js b/source/base/static/base/js/backbone/trails_backbone.js
index 0d98dd7..867024a 100644
--- a/source/base/static/base/js/backbone/trails_backbone.js
+++ b/source/base/static/base/js/backbone/trails_backbone.js
@@ -5,7 +5,7 @@


   exports.Trail = Backbone.Model.extend({
-    urlRoot: "/api/datawake",
+    urlRoot: "/api/datawake/",
     defaults: {
       trail_id: 0,
       domain_name: "",
@@ -16,7 +16,7 @@


   exports.TrailsCollection = Backbone.Collection.extend({
-    url: "/api/datawake",
+    url: "/api/datawake/",
     model: exports.Trail,
   });

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

This is fixed in production, but not in our repository.

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

Found another one:

explorer.continuum.io/:1 Mixed Content: The page at 'https://explorer.continuum.io/seeds/datawake_import/' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://explorer.continuum.io/api/seeds_list/1/'. This request has been blocked; the content must be served over HTTPS.

I'm guessing it's the same issue.

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

I've backed it out this far:

source/base/templates/base/edit_seeds.html

  <div class="col-sm-10 col-sm-offset-1 col-md-10 col-md-offset-1">
    <input id="seeds_pk" type="hidden" value="1">
    <div id="seeds"></div>
  </div>

source/base/static/base/js/backbone/edit_seeds_backbone.js

    el: "#seeds",
    form: "#editSeedsForm",
    invalidLines: [],
    template: _.template($("#editSeedsTemplate").html()),
    initialize: function(model){
      this.model = model;
      var that = this;
      this.model.set({id: $("#seeds_pk").val()}).fetch({
        success: function(){
          that.render();
          that.setEditor();
        }
      });
    },

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

Rubber-duckied my way out of this one.

If I understand what's going on correctly:

Backbone composes an incorrect request for a given seeds list using a very slightly incorrect URL:

https://explorer.continuum.io/api/seeds_list/1 instead of https://explorer.continuum.io/api/seeds_list/1/

Now there are actually a couple of ways we should be able to fix this.

Django was sending a 301 redirect back, but it's sending using an 'http' protocol, not https. So I made sure that Django knew that it needed to send HTTPS redirect responses back. This is a two-part operation.

On the nginx configuration:

      proxy_set_header X-Forwarded-Proto $scheme;

In Django settings:

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

Note the security warnings on SECURE_PROXY_SSL_HEADER, but this all looks correct to me.

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

So the patches are to nginx and settings. I think this frees us from having to worry about trailing slashes so long as Django redirects to the correct resource.

@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 8, 2015

I'll close this when the commits are landed to the docker branch and pushed.

@ahmadia ahmadia assigned ahmadia and unassigned brittainhard Nov 8, 2015
@ahmadia
Copy link
Contributor Author

ahmadia commented Nov 11, 2015

punting to 0.5 - this is fixed on explorer.continuum.io

@ahmadia ahmadia modified the milestones: v0.5, v0.4 Nov 11, 2015
@ahmadia ahmadia removed their assignment Dec 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants