gaw89 / dash-flask-login

A plugin to integrate Dash and Flask-Login
MIT License
56 stars 17 forks source link

Redirection problems (ciritical) #8

Open xapple opened 6 years ago

xapple commented 6 years ago

When using this library locally, everything works fine, but I have noticed that when deployed to heroku it messes with the callback path. Instead of GET going to _dash-dependencies, they go to login?next=%2F_dash-dependencies after login.

Same for the layout calls. Here is an example from the logs:

2018-08-02T04:48:43.389871+00:00 app[web.1]: 1.2.3.4 - - [02/Aug/2018:04:48:43 +0000] "GET /login?next=%2F_dash-layout HTTP/1.1" 200 392 "https://www.example.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/605.1.14 (KHTML, like Gecko) Version/11.1.1 Safari/605.1.15"
madhu-kt commented 6 years ago

@xapple, I'm running into the same issue. Locally it works out perfectly but deploying on a Webfaction server causes a bunch of invalid GET requests due to bad routing. Were you able to get around this?

xapple commented 6 years ago

No I did not find a way around it (spent about two hours on it), and abandoned dash as a viable stack for making web applications.

natisangarita commented 6 years ago

It is a shame... I agree dash for now it is not a viable stack for web applications. After spending a lot of time developing a dashboard, I have failed making it secure....I should have checked that part first.

shinz4u commented 6 years ago

Is there any workaround for this issue? It would be great to get a flask-login based authentication. I need this in order to host it on our local intranet.

Also, I understand as per dash.plot.ly/authentication

You can have BasicAuth and Plotly OAuth (I don't need this as of now as I am using this dashboard as a test project for our university student research team also no funds too :stuck_out_tongue: )

Is there a way that you can use BasicAuth to provide access through another webpage? I can create a flask login webpage using the underlying flask server i.e server = Flask(__name__)

Then collect the passwords from that webpage and then pass it to BasicAuth to grant basic access?

Can this be done?

xapple commented 6 years ago

Plotly OAuth is a paying service (paid Plotly subscription). I tried HTTP Basic Auth too and it didn't work either. After a few call backs the server would answer 403 consistently.

My attempt at adding flask-login to dash apps can be found here:

https://gist.github.com/xapple/bb8fe6a2adca9cbf86675cb48b59f0be

But that would give me redirect problems.

gaw89 commented 6 years ago

Hi Everyone! I hope to get back to this whole project soon, and this will be one of the first issues I work on. I believe it has something to the NEXT parameter in the HTTP Get requests. I'll post back here when I find a fix.

sciotta commented 6 years ago

I can't validate my login... I'm getting erro like this:

Exception happened during processing of request from ('127.0.0.1', 53153) Traceback (most recent call last): File "C:\Python27\Lib\SocketServer.py", line 596, in process_request_thread self.finish_request(request, client_address) File "C:\Python27\Lib\SocketServer.py", line 331, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python27\Lib\SocketServer.py", line 654, in init self.finish() File "C:\Python27\Lib\SocketServer.py", line 713, in finish self.wfile.close() File "C:\Python27\Lib\socket.py", line 283, in close self.flush() File "C:\Python27\Lib\socket.py", line 307, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 10053]

gaw89 commented 6 years ago

@thiagog3 Are you able to post your code?

sciotta commented 6 years ago

@gaw89 I'm just using your "usage_dash_flask_login.py" with a time.sleep(2) in line 103. It's only a simple test to simulate my issue. This exception is triggered when I try login.

jonatronblah commented 5 years ago

Just curious if there was a fix for this problem. have the same issue trying to deploy on pythonanywhere. thanks.

jonatronblah commented 5 years ago

fyi - i ended up solving this problem by exposing the dash flask view and manually requiring a login there. not sure if this will help others but it was what i needed for my situation. found the solution here: https://stackoverflow.com/questions/52286507/how-to-merge-flask-login-with-a-dash-application