shinken-monitoring/mod-webui

Midori doesn't save webui's cookie

Closed this issue · 9 comments

Hello,

I currently use Shinken on wallboards powered by Raspberry Pis and running some carousel script to cycle between tabs with the midori navigator.

The problem seems to be specific to Webui, because other tabs stay logged to their respective website even after restarting the Pi.
I've used a workaround with a javascript to automatically POST the login form, but it redirects me on the /dashboard view, where I'd want to see the /problems view.
As our script kills and restarts itself every 6 hours, I have to manually VNC the Pis to log in...

What I already thought about :

  • instead of using /dashboard as default view, use /problems (I think I saw a line about default page in /var/lib/shinken/modules/webui2, not sure)
  • modifying which page can see an anonymous user (not a good solution, as 3 teams use the wallboards and need to be logged with their account)

Can you see why midori doesn't save the cookie ? It works really fine on my workstation with Chrome & Firefox, but I can't get it to work on my Pis (they run Debian, by the way).
If you need to see config or more information, I'll post it asap
Thanks !

edit: it's late and I think my issue is poorly written. So, to make sure you can picture it correctly :
If I manually log in, close midori and reopen, I have to log again.

I do not know anything about midori ... but what is sure to me is that the WebUI cookie is not specific at all. Thus I do not understand why there is something specific about this ...

What I think is that the cookie expires at the end of the browser session, this will explain the behaviour.

Is WebUI running as a webapp ? I've read something about midori sandboxing webapps, it could explain the cookie expiration

No it is not a WebApp ... but I suppose that the problem is due to the cookie that is configured to expire when the browser exits ...

I can't understand why.. My only solution would be to set the /problems view as the default one. Where can do this ?

Why? Because the default cookie behavior of the underlying Web library used by the WebUI is as is 😉

1/ To change the cookie duration

Edit the plugins/login/login.py file on line 88 and replace

app.response.set_cookie(str(app.session_cookie), cookie_value, secret=app.auth_secret, path='/')

with

app.response.set_cookie(str(app.session_cookie), cookie_value, secret=app.auth_secret, path='/', max_age=3600)

This will set the cookie to expire 3600 seconds after its creation ...

2/ To change the default homepage

Edit the plugins/login/login.py file on line 89 and replace

bottle.redirect(app.get_url("Dashboard"))

with

bottle.redirect(app.get_url("Problems"))

This should set the defalt home page as the Problems page

Note that I did not tested those modifications but I am quite confident there will be no problem with ... please confirm you test results

Thank you ! I was sure I saw this line somewhere :)
I'll try it monday morning, will provide feedback. I'm sure this will work

Have a nice week-end 😉

2016-11-05 16:17 GMT+01:00 Furiml notifications@github.com:

Thank you ! I was sure I saw this line somewhere :)
I'll try it monday morning, will provide feedback. I'm sure this will work


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#553 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACy_zxVXaMZh7qv1Cli5oTNj6TwklPzVks5q7J3-gaJpZM4KpuVk
.

Hello again !

I set the max_age to the maximum value (2147483647), but Midori just doesn't want to save the cookie :-(.
So I replaced the line 89 Dashboard by Problems. Didn't work either.
I kept on replacing more occurrences after this, and it seems like the redirect that is caught after a successful login is line 132 :

else:
            logger.debug("[WebUI]  user '%s' signed in: %s", login, cookie_value)
            bottle.redirect(app.get_url("Dashboard"))

This worked with my javascript login, so my problem is solved :-)
Thanks a lot for your time !

Thanks for the feedback