I have a Django application which I now want to integrate it with Kibana. So when authenticated users click on a link, they will be directed to Kibana. But this option should not be available to anonymous users.
My stack is Psql + Django + mod_wsgi + Apache. The solution I came up with was restricting access to Kibana via Apache, and authenticating users in Django before giving them access. This HowTo in Django website says how you can authenticate against Django from Apache, but that one uses Basic authentication. When I use this approach, even for users who already have an active session in my Django app, they will be asked to enter their username/password in a browser dialog!
I was hoping the authentication to happen using the current Django active sessions. I believe for that I need to use AuthType form
and mod_session
, instead of AuthType Basic
. Is this correct? If yes, it seems mod_wsgi
does not support mod_session
yet (as discussed here). what would be the alternative then?
<Location "/admin">AuthFormProvider fileAuthUserFile "conf/passwd"AuthType formAuthName "/admin"AuthFormLoginRequiredLocation "http://example.com/login.html"Session OnSessionCookieName session path=/Require valid-user</Location>
<Location "/admin">AuthFormProvider wsgiWSGIAuthUserScript /some/path/auth.py application-group=%{GLOBAL}AuthType formAuthName "/admin"AuthFormLoginRequiredLocation "http://example.com/login.html"Session OnSessionCookieName session path=/Require valid-user</Location>
<Location /dashboard/kibana>
AuthType Form
AuthFormProvider wsgi
AuthName "test"
ErrorDocument 401 /rel/path/to/httdp_signin/signin.html
WSGIAuthUserScript /path/to/wsgi/wsgi.py
WSGIAuthGroupScript /path/to/wsgi/wsgi.py
<RequireAll>
Require wsgi-group myGroup
Require valid-user
</RequireAll>
Session On
SessionCookieName httpdsessionid path=/
</Location>
On 27 Oct 2017, at 10:29 am, Mohammad Hashemian <m.has...@gmail.com> wrote:Thanks a lot, Graham. Very helpful. I actually could make it work. As you said, I added this to my httpd.conf:<Location /dashboard/kibana>
AuthType Form
AuthFormProvider wsgi
AuthName "test"
ErrorDocument 401 /rel/path/to/httdp_signin/signin.html
WSGIAuthUserScript /path/to/wsgi/wsgi.py
WSGIAuthGroupScript /path/to/wsgi/wsgi.py
<RequireAll>
Require wsgi-group myGroup
Require valid-user
</RequireAll>
Session On
SessionCookieName httpdsessionid path=/
</Location>Now how it works is like this:1. User is logged in Django app and clicks to access the second app (in this case, Kibana)2. Kibana is protected by Apache's authentication, and user is not authenticated with Apache, so error 401 will navigate the user to the signin.html page3. User has to enter username/password again (not ideal but a lot better than alternatives I've found so far)
4. A new session/cookie is created for the user, which as you said, is different than the session user had with Django.5. Now the user can navigate to KibanaThis is now working, but I don't know much about embedded vs. daemon mode, unfortunately. I will have to read a bit about those and make sure that setting is also done correctly.Thanks again for your time,Mohammad
--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at https://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/d/optout.