Advertisement:

Author Topic: MediaWiki SMF Bridge not working - No auth, portal removed...  (Read 22043 times)

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
MediaWiki SMF Bridge not working - No auth, portal removed...
« on: February 04, 2012, 08:43:36 AM »
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.
« Last Edit: February 05, 2012, 10:40:54 AM by nyall »

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #1 on: February 04, 2012, 09:15:16 AM »
Follow up: I think .htaccess modifications have something to do with this

Offline NanoSector

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,499
  • Gender: Male
  • VC321xb47@aperture:~#
    • Yoshi2889 on GitHub
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #2 on: February 04, 2012, 09:53:05 AM »
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."


Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #4 on: February 04, 2012, 01:01:07 PM »
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.
« Last Edit: February 04, 2012, 01:07:54 PM by nyall »

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #5 on: February 04, 2012, 01:30:37 PM »
OK, so I know now:

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

Quote
RewriteRule ^/*$ /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

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #6 on: February 04, 2012, 02:30:10 PM »
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.
« Last Edit: February 04, 2012, 02:52:42 PM by nyall »

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #7 on: February 04, 2012, 03:37:15 PM »
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
« Last Edit: February 04, 2012, 04:06:42 PM by nyall »

Offline Andre N

  • Jr. Member
  • **
  • Posts: 362
  • Gender: Male
  • My facebook friend tally has recently skyrocketed
    • R2bconcepts
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #8 on: February 04, 2012, 06:22:33 PM »
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?"

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #9 on: February 04, 2012, 06:49:08 PM »
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
« Last Edit: February 04, 2012, 07:35:59 PM by nyall »

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #10 on: February 04, 2012, 07:35:20 PM »
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

« Last Edit: February 04, 2012, 07:40:56 PM by nyall »

Offline Andre N

  • Jr. Member
  • **
  • Posts: 362
  • Gender: Male
  • My facebook friend tally has recently skyrocketed
    • R2bconcepts
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #11 on: February 04, 2012, 09:09:32 PM »
I 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.

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?"

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #12 on: February 04, 2012, 09:23:23 PM »
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)

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #13 on: February 05, 2012, 10:40:38 AM »
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?
« Last Edit: February 05, 2012, 11:01:26 AM by nyall »

Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #14 on: February 05, 2012, 11:07:58 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!
« Last Edit: February 05, 2012, 11:14:02 AM by nyall »

Offline ajbaldwin

  • Newbie
  • *
  • Posts: 3
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #15 on: February 07, 2012, 01:54:09 PM »
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:

Quote
The 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.


Offline nyall

  • Semi-Newbie
  • *
  • Posts: 26
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #16 on: February 07, 2012, 05:59:55 PM »
@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)
« Last Edit: February 07, 2012, 06:03:07 PM by nyall »

Offline Danoth

  • Newbie
  • *
  • Posts: 3
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #17 on: February 11, 2012, 04:47:24 PM »
Here you go anyone wanting to use this :D

Go to around line 247

comment out the following

Code: [Select]
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

Offline soloron

  • Newbie
  • *
  • Posts: 1
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #18 on: February 15, 2012, 09:29:17 PM »
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:

Quote
I 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:// github.com/SimpleMachines/smf-mw-auth) 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.)





Offline Aleksi "Lex" Kilpinen

  • A Peculiar Finn
  • Lead Support Specialist
  • SMF Super Hero
  • *
  • Posts: 18,541
  • Gender: Male
  • Don't worry, I'm n00b friendly
    • Aleksi.Kilpinen on Facebook
    • LexArma on GitHub
    • aleksi-kilpinen on LinkedIn
    • There's No Place Like 127.0.0.1
Re: MediaWiki SMF Bridge not working - No auth, portal removed...
« Reply #19 on: March 10, 2012, 05:34:00 AM »
Hi nyall, any updates on this? :)
A Finnish Support Specialist
 Happily running multiple SMF 2.0 installations.
  Fooling around with an i7 990X @ 3,47Ghz / 12Gb / Win 10 x64 / 3840x2160


How you can help SMF

"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