|
I am deploying osqa for my drupal site. How to auhenticate an user for osqa when the user logs in to the drupal site? Which modules to change? I have read all the questions related to this but can't find a clear answer. Do i need to implement a authentication backend? |
|
Pre-setup. I set up my mysql server to have a read only user coming from the osqa side. This is given read access on the drupal user and session tables. It also involved setting up multiple django database connections in settings_local.py (I think only django 1.2+ can do this and I'm using 1.2.6 (or similar). I created a forum/middleware/drupal folder containing a backend.py and remote.py file. In backend.py I have 3 classes:
It basically gets the data and checks for the drupal session and user info. If there it see's if there's a local mapped osqa user for the drupal user. If so it authenticates if they logged in to drupal. If not then it uses the drupal info and generates a local user and then does the usual authentication. Anything else fails. In remote.py I have a class called DrupalUserMiddleware that extends RemoteUserMiddleware and has a process_request function which checks for user authentication. It does this by calling the backend.py code. I then modded settings.py (MIDDLEWARE_CLASSES) to include 'forum.middleware.drupal.remote.DrupalUserMiddleware' (after the AuthenticationMiddleware line). Extra: If you want to play with cookie setting etc then you'll also need to look at using django_cookies.py ('forum.middleware.django_cookies.CookiePreHandlerMiddleware' and 'forum.middleware.django_cookies.CookiePostHandlerMiddleware' at the beginning and end of the MIDDLEWARE_CLASSES list). That's the basic jist anyways :) Si-- |
|
I've recently done what matt suggested above. I set drupal up so that when they log in there and go to the osqa site (bearing in mind mine are sub-domains which means its easier to share session info), osqa looks for a relevant session id and then queries the drupal database to see if there is an active session with an associated user. If so I check to see if we have a matching osqa user and if they exist set them to authenticated. If they don't exist locally then I create a new osqa user and set them as authenticated. The second part I implemented was having a custom login screen in osqa so that the user can log in on that site and this auto logs them into the drupal site. This was a mod of the localauth module already present with ideas and concepts taken from the ldap authentication posts on this site. Instead of using XML-RPC or similar as matt suggests I wrote a custom connector just because I was interested in writing something from scratch. Whichever way you choose you can use this to take the user login details and authenticate with drupal. As before I check for a matching osqa lcoal user and if present authenticate them. If not then it simply fails authentication. All registrations need to go through the drupal site so that this last bit works ok. I don't know if I can post anything out as it is currently an internal project but I'll see about giving some pointers as a I make some code mods. Hi, thanks. Can you tell what modules you changed in osqa? I am having trouble locating which module to change.
(24 Jun '11, 07:28)
Balaji
What browser are the end users using?
(24 Jun '11, 07:48)
kedar_apte
Any browser.
(24 Jun '11, 08:01)
Balaji
How is the performance of drupal in IE 8 & IE 9...Is it acceptable in terms of the content rendering properly or it is just ok?
(24 Jun '11, 08:20)
kedar_apte
1
Hi, I'll have a look when back in work but off the top of my head I have a custom middleware drupal module that has a backend and remote py file. I also have a modified extended user py file that links with a custom 'drupalauth' module (like a modded cross between localauth and the ldap auth module that people have set up). That allows the user to login via drupal and get auto logged in to osqa or alternatively log in via the osqa login page but actually get logged in to both drupal and osqa. If the user registers on drupal and then goes to osqa then it checks to see if the user is currently authenticated and if there isn't a local osqa user it creates it before logging them in. I have disabled registration via osqa and just link to the drupal registration page.
(25 Jun '11, 18:59)
T1ckL35
|
|
Hi there. My guess is that you'll need to write a custom authenticator that looks for some marker that Drupal has the user currently signed in. The other option is to write a module that pings a Drupal XML-RPC or Rest API to see if there's a user for the session, etc. If you want to have OSQA users be able to login with their Drupal username and password then you will definitely need an authentication backend. Hope that helps! Thanks for your help. I have written a backend, but i am having trouble merging it with osqa. What i want to do is remove login/logout link from osqa because the user is logged in from the drupal site. How to go about it? I have successfully removed the login/logout links by editing url.py file and want to automatically create the user object when any part of osqa is accessed using drupal's login information. How to do this?
(24 Jun '11, 07:06)
Balaji
Will modifying ExtendedUser to authenticate from the drupal site work?
(24 Jun '11, 09:01)
Balaji
|
I've seen many similar questions, (even I have asked one) is there any "generic" way to do so, perhaps this is a question from django/drupal people to answer...