PDA

View Full Version : DrupalAuthentication



cooperq
04-04-2008, 09:44 PM
Hi, I have been using the DrupalAuthentication service and the excellent Drupal SSO module written by d00p http://wiki.opengarden.org/User:D00p/Integrating_DekiWiki_and_Drupal. After some nasty bugs at first it is working pretty good now.
However, I still have one problem, which is a huge detriment, I have noticed that when a new user makes an account via drupal, when they sign into drupal they are not signed into dekiwiki.
EDIT: When trying to use the auth service the page that gets returned is:

<?xml-stylesheet+type='text/xsl'+href='/@api/host/resources/error.xslt'?><error><status>401</status><title>Unauthorized</title><message>authentication+failed</message><uri>http://wiki.wikiaudio.org/@api/deki/users/authenticate?authprovider=10</uri></error>

The way to fix this is to sign into dekiwiki with the drupal credentials and then sign out. This puts the drupal user hook into the wikiaudio database and then it works as it should. I would like to have it so that the first (and every) time the user logs in to either service, it logs into both. So the question is, how can I have the user be put into the wikiaudio database instantly. Thanks in Advance.
Cooper

P.S. I am using DekiWiki 1.9.0 (itasca) from source, drupal 5 and ubuntu 7.10

cooperq
04-05-2008, 07:04 PM
Ok, I have patched the drupal module to fix this bug, I will release the patch in a couple of days. (It's still a bit of a dirty hack atm ;) ).

d00p
04-06-2008, 11:43 AM
Hi.
Could you send me the patch? I will upload an updated version of the plugin to the wiki.

SteveB
04-09-2008, 05:51 PM
Please, please, send us the patch so we can fix the issue at the source! :)

oneokayfella
04-30-2008, 10:21 PM
I assure you CooperQ has it and it's working - I know - I'm the one that paid him to do it..... so as a side benefit of you guys giving us your excellent DekiWiki software to use- we return the favor with free development!

See how nice we are!


:)

SteveB
05-03-2008, 02:30 PM
That's wonderful!

When you send it the patch (steveb {at} mindtouch {dot} com), make sure to include your address and t-shirt size preference so I can mail you 2 mindtouch deki wiki t-shirts as a thank you! :)

vince007
06-02-2008, 08:17 PM
We just managed to get it to work on Jay Cooke 8.05 RC1.

But we have to this question. Here's the scenario that now works:

1. Click Log-on on DekiWiki
2. You are redirected to the Drupal Login page
3. You login and then a brand new user is created in DekiWiki regardless of whether that same user name existed or not. It does not authenticate in DekiWiki using the existing DekiWiki account.

For example, if we have user Melinda in both systems, it would create user Melinda1 in DekiWiki - if not, it would create user Melinda instead.

If we want to maintain the same users in both systems with distinct roles - is the recommended scenario to create all these accounts from scratch using the SSO and then add specific roles to the users created by the DrupalAuthentication module ?

That therefore means that we cannot re-use already configured DekiWiki accounts ? My issue is that I already have several dekiwiki accounts created and I'm not sure what to do with them with this SSO module.

ANOTHER QUESTION: With that scenario, how do we log as admin in DekiWiki ? It creates an Admin1 account. I guess we could grant admin privileges to that one - but we have to use the DekiWiki login first and select "local" rather than "drupalAuth" in order to do that.

THX !

vince007
06-09-2008, 05:48 PM
Thanks in advance.

vince007
06-23-2008, 04:17 PM
Ended-up figuring all the SQL to address my issue above.

But we have a remaining issue. If you register/create new account on the Drupal "create new account page", the SSO module does create the account in DekiWiki but does not log the user in. Therefore, when accessing DekiWiki after registering, it says you're not logged-in. So if you click Log-in, your are directed to the Drupal logging page - but Drupal knows you're logged in - the user therefore ends-up in LaLa land.

Any suggestion ?

MaxM
06-23-2008, 06:37 PM
Vince, are you using post:users/authenticate with an apikey to create users?

If so, that should return an authtoken cookie that you need to set on the client's browser.

rajarak
06-26-2008, 08:17 PM
MaxM,

I use the same but i get 401 status.
Any idea..

when i use username and password i get authtoken,but when i use username and apikey i get 401 status.

Please let me know if you have some info.

Thanks!!

MaxM
06-26-2008, 08:20 PM
when i use username and password i get authtoken,but when i use username and apikey i get 401 status.


To get an authtoken back with a username/apikey you need to have trusted auth enabled.

check out: http://wiki.developer.mindtouch.com/MindTouch_Deki/Specs/Trusted_Authentication

vince007
06-27-2008, 04:45 PM
Thanks MaxM the DekiWiki SSO module actually does post:users/authenticate with an apikey to create users as shown below. The module works perfectly when an existing Drupal user logs in to Drupal. The user is logged in to Deki Wiki as well.

Currently, a user who creates a new account in Drupal would be logged into Drupal after the registration process. However, the associated Deki Wiki account will not be created, therefore the user would have to log out of Drupal then log back in before DekiWIki SSO will allow automatic login to Deki Wiki.

I am looking for a solution to login the user to Deki Wiki without forcing the user to logout and then log back in again.

Here is the function dekiwiki_user from DekiWikiSSO module. You would notice that the only cases are login and logout. We need this same code to apply when a user creates a new account. I have tried a case ‘register’, which did not work. I have tried case ‘load’, which creates the Deki Wiki user in the Deki Wiki database, but does not log in the user to Deki Wiki until the user logs out of Drupal, hence defeats the purpose.
Please advise as to the best way to allow users who just created their Drupal account to login to Deki Wiki automatically without being forced to log out of Drupal and log in again.

function dekiwiki_user($op, &$edit, &$user, $category = NULL) {
$server = variable_get('dekiwiki_wikidnsname','wiki.server.c om');
$domain = variable_get('dekiwiki_wikidomainname','.server.co m');
switch ($op) {
case 'login':

// If this is Drupals main admin we dont set cookies
if($edit['uid'] == 1 || $user->uid == 1) {
drupal_set_message('(The superuser is never logged into dekiWiki)', 'status');
return;
}

$url = "http://" . $edit['name'] .":" . $edit['pass'] ."@". $server ."/@api/deki/users/authenticate?authprovider=11";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "");
$response = curl_exec($ch);
curl_close($ch);
#echo $url;
#echo "Valor de la cookie:" . $response;
setcookie("authtoken", $response,time()+3600*24*30,"/",$domain);
break;

case 'logout':
setcookie("authtoken", "", time()+3600*24*30,"/",$domain);
break;
}
}