News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

MediaWiki SMF Bridge not working - No auth, portal removed...

Started by nyall, February 04, 2012, 08:43:36 AM

Previous topic - Next topic

nyall

Hi all

Last night I was trying to install the new MW Auth bridge to allow my SMF 2.0.2 forum to be able to integrate a wiki, as used here for documentation.

I installed MediaWiki 1.18.1 in Spanish on the server successfully, and was able to open an account, login and use it without any integration. My SMF 2.0.2 + Simple Portal 2.3.3 forum was working without issues as has been for quite some time now.

I followed the instructions for bridging, copied the required file and did the required modifications. Unfortunately, to no avail.

Now I have everything messed up:

- The Home Page (http://www.domain.com) was managed by SimplePortal, now MediaWiki has overriden this and the Wiki is set as the Home Page

- When you try to login to the wiki, the link (http://www.domain.com/wiki/index.php?title=Especial:Entrar&returnto=P%C3%A1gina+principal) takes me to SMF login page, even if I am already logged in to the forum. If I enter username and password (the same for the user already logged in, or a different one, doesn't matter because it is ignored) I'm taken to the main forum page.

- And of course authentication does not work, I created a new tab in the forum menu for accessing http://www.domain.com/wiki and the link works, but all I get is my IP recognized and the "Login/Register" which, as mentioned, takes me to forum's login form.

What am I doing wrong? What logs or information can I provide to try to identify the root cause for this issue? Any help would be hughly appreciated.

Thanks in advance.

nyall

Follow up: I think .htaccess modifications have something to do with this

NanoSector

As far as I am aware, the MediaWiki bridge is outdated and will not work correctly with SMF 2.0.2. It's possible that I'm wrong though.

Where did you download the bridge? (meh that sounds weird :P)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."


nyall

Thanks for your answers. Right now I'm thinking it has to do with .htaccess and Short URLs.

As per mi initial post, I am using the latest brigde (as downloaded from https://github.com/SimpleMachines/smf-mw-auth ) and since it was released a couple of months ago, I was hoping it is compatible with the newer versions of SMF :-P

Oddly enough, my issue is exactly the same as http://www.simplemachines.org/community/index.php?topic=461612.msg3256089#msg3256089  (but I did not remove the '&' since I'm using PHP 5.2 )

Many thanks in advance.

nyall

OK, so I know now:

- The line causing the issue with the "Login/Register" link was this:

QuoteRewriteRule ^/*$ /w/index.php [L,QSA]

and removing it, the tab added in the menu works, and the Short URLs work more or less.

For example, this "Login/Register" link is show as [...]w/index.php?title=Especial:Entrar&returnto=Página+principal  (as said, it is in Spanish)

Now I need to figure out:

- Why the authentication is still not working. I cannot even login with the admin user and password specified during installation (maybe this is to be expected?  ??? )

- Why some links are using Short URLs correctly, while others don't  (probably can be solved with some .htaccess tweaking)

Any help appreciated

nyall

And more details:

The same behaviour apparently caused by the .htaccess line mentioned (clicking the "Login/Register" link takes me to the forum registration page, even though I am already logged in)  can be replicated if I enable the settings $wgSMFLogin and $wgCookieDomain

And, in that case, entering username and password said that there was an error with cookies and I could not be logged in. (that was because $wgCookieDomain was not properly set, using 'www.domain.com' instead of 'domain.com')

Still cannot make authentication to work.

nyall

OK, maybe a silly question, but: should I install MediaWiki in the same database than SMF? Now I have two databases, one for the forum and I've created another for the wiki.

Just occurred to me that either:

a) Both databases are not talking one to each other ??? Maybe I should have just one database with tables identified by prefix... Going to try that out now.

or

b) Cookies are not being read properly

Maybe both? Any hint? What logs should I check?

As always, any help is highly appreciated

Andre N

MediaWiki 1.18.1 and SMF 2.0.2?
Can I have a link to your site?
Or even better, a temporary ftp account? :)
I see lots of these  auth problems with MediaWiki. Would be nice to figure out what is wrong...
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

nyall

Yes, 1.18.1 and 2.0.2. Sure thing, thanks.

Right now I was about to install MediaWiki using the same database than the forum (scheduled maintenance and all that) and then try.

I will PM you the details after that (if it was not just a DB issue, which I am not sure it is...), if that's OK for you

nyall

And, for the record:

I have reinstalled MediaWiki, this time using the same database than the forum with tables using a different preffix.

I am trying to make it work for now, and will deal with Short URLs later. Still, authentication is not working for some reason  ???

And, even more strange: I was able to login into MediaWiki before the integration using the default user created during installation, now all I get is an "incorrect password" message  :o


Andre N

I changed line 176 of mediawiki/extensions/Auth_SMF.php from

$smf_member_id = $user->getOption('smf_member_id');

to

$smf_member_id =  $user_settings['id_member'];


and the login integration works fine. $user doesn't have any data set up at that point and $smf_member_id is never set so the authentication fails down the line.

As for your account that always redirected you to login, it didn't work for me either; maybe when you reinstalled you forgot to create it? I made my own :D
"Every generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?"

nyall

Amazing, thank you very very much !

I could have never managed to solve it without your assistance. I owe you some "tapas" if you ever come to Spain  8)

nyall

Follow up:

The authentication works (at least, at the main page the account is detected), however:

- I had to INSERT via SQL queries the permissions for the users. SMF Administrator was successfully added as MW Administrator, but since the admin user created during the installation cannot be used to login, I had no other users in the 'bureaucrat' group. I set $wgSMFSpecialGroups at LocalSettings.php but somehow it is ignored ???

- Neither administrator nor bureaucrat nor registered users can edit pages. When I click the "save changes" button, I receive a message that edition was not successful due to loss of session data. It recommends to log off and login again, but that does not help. $wgSMFLogin and $wgCookieDomain are set, to 'true' and to 'http://www.domain.com' respectively.

So, still needs some fine tuning ???

Any idea where to look?

nyall

Quote from: nyall on February 05, 2012, 10:40:38 AM
- Neither administrator nor bureaucrat nor registered users can edit pages. When I click the "save changes" button, I receive a message that edition was not successful due to loss of session data. It recommends to log off and login again, but that does not help. $wgSMFLogin and $wgCookieDomain are set, to 'true' and to 'http://www.domain.com' respectively.

This is solved by setting $wgCookieDomain = 'domain.com' without any prefix such as www or http

@moderators: Still testing and configuring, please do not mark this topic as solved (unless you don't mind me changing the status if required), once I have the integration fully working I will leave it as solved by myself, in the meantime I'd like to have it open to include new comments and discoveries. In addition to that, I think the README would benefit from inclusion of details not so obvious such as the one above. Thanks!

ajbaldwin

Great thread (and I'm glad to hear that I'm not the only one that I'm struggling with this as well).

Here's some of the tracing I've done (keep in mind that I'm not a web developer - I basically know just enough PHP to be dangerous (usually to myself!). This is a cut and paste portion of an e-mail I just sent off about this:

QuoteThe ultimate issue that seems to be triggering my problems is that while
the code is able to derive $ID_MEMBER from the SMF cookie,
$smf_member_id (i.e. the double check from the database) never changes
from its default value of 0, so this bit of code runs:

// We have tried all we can, but the data just doesn't match up.
if (empty($smf_member_id) || $smf_member_id != $ID_MEMBER)
   {
      // TODO: Log errors if the ids don't match?
      if ($user->isLoggedIn())
         $user->logout();   
      return true;
   }

and thus I'm logged out (and if $wgSMFLogin is set to true, my SMF
session is killed as well). I also see the same logic running when
$wgSMFLogin isn't set:

      // No id, you must be unauthorized.
      if ($smf_member_id == 0)
         return false;

So I went hunting for smf_member_id and found it stored properly (i.e.
the value is the same as my account ID in the SMF database) as a BLOB in
the mw_user_properties table. What seems to be broken (at least right
now!) is that the getOption call to get that value never seems to
actually return the value stored in the database. The value (as far as
the bridge code is concerned) remains zero, thus the double check
continuously fails.


nyall

@ajbaldwin, thanks for your input, hopefully we will manage to solve it somehow.

For the record, I have noticed that:

- If I access the forum first, I can login and then, when accessing the wiki, authentication is working (although I am still having an odd behavior with MediaWiki's Short URLs)

- If, on the other hand, I enter the wiki first and then I click the login link, it takes me as expected to the forum's login page. However, it is impossible to login, with the forum always complaining about cookie's settings on my browser.

It seems that:

- The cookie must be created by the forum, and the wiki can read it without problems
- The forum can't overwrite the cookie (or I have not found how)

Danoth

Here you go anyone wanting to use this :D

Go to around line 247

comment out the following


if (empty($smf_member_id) || $smf_member_id != $ID_MEMBER)
{
// TODO: Log errors if the ids don't match?
if ($user->isLoggedIn())
$user->logout();
return true;
}


It'll stop you being logged out  after everything setup. No need to use any other fixes. Keep $smf_member_id = $user->getOption('smf_member_id'); in.

EDIT: Just read above lol. Can't believe i missed that. Ah well ¬¬. Im sure we'll figure out the smf_member_id next :D

soloron

I had this working and then upgraded to Mediawiki 1.18 and SMF 2.0.2 and I ran into the same unable to login / getting redirected to the forums main page.

I got mine (mostly) working again with this fix:

QuoteI changed line 176 of mediawiki/extensions/Auth_SMF.php from
Code: [Select]

$smf_member_id = $user->getOption('smf_member_id');

to
Code: [Select]

$smf_member_id =  $user_settings['id_member'];

and the login integration works fine. $user doesn't have any data set up at that point and $smf_member_id is never set so the authentication fails down the line.

However, there were still some issues.  The new LocalSettings.php seemed to be missing some content:

Quote# NOTE: Make sure to configure the wgCookeDomain below

But the new LocalSettings file (see https:// hxxp:github.com/SimpleMachines/smf-mw-auth [nonactive]) did not seem to contain the line that actually set the wgCookieDomain.  So I had to add that back in from my previous version of LocalSettings.

Quote# Make sure "Enable local storage of cookies" is unchecked in the
# SMF Admin -> Server Settings -> Feature Configuration section
# www . domain . org / wiki and www . domain . org / forums -> www . domain . org
# wiki . domain . org and forums . doman . org -> .domain . org
#$wgCookieDomain = 'www . domain . com';
$wgCookieDomain = 'domain . com';
#$wgCookiePath = '/'; // Optional, defaults to '/'
#$wgCookieSecure = false;  // Optional, only change on scheme mismatch

Also, if I logged in and out from the forums, all was good.

If I logged out from the logout link on the Wiki page, a cookie got set, and then I couldn't log back in at all.  Using the Login/Logout links from the Wiki didn't seem to work.  If I cleared the cookies and used just the login links from SMF, all seemed to work fine.

I borrowed code from http:// www . mediawiki . org / wiki / Extension:AutomaticREMOTE_USER#Disabling_Login_and_Logout_Links to remove the login/logout options from the Wiki page.  So, the user *has* to login/logout from the forums.  This seems to work.

(It wouldn't let me post actual links, so they are broken up with spaces.)





Aleksi "Lex" Kilpinen

Slava
Ukraini!


"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Advertisement: