SimpleMachines / smf-mw-auth

SMF MediaWiki Authentication
https://www.simplemachines.org
Other
23 stars 18 forks source link

Problem Authenticating to MW 1.40.0 from SMF 2.1.4 #25

Closed vonCorax closed 9 months ago

vonCorax commented 10 months ago

I am attempting to enable SSO with SMF 2.1.4 and MediaWiki 1.40.0. The installation instructions in README.md seem incomplete, so what I did was to download the repo, rename the root folder from smf-mw-auth-main to ForumSsoProvider, upload the folder to my wiki/extensions directory, and then make the suggested edits to LocalSettings.php. When I reload the wiki page I get a blank page.

Is this a bug, or am I simply doing something wrong?

jdarwood007 commented 10 months ago

I haven't tested against 1.40. Last release that was tested is 1.39 LTS. Sounds like your using it right, but MediaWiki may have changed a API that we are using and it will need to be addressed.

jdarwood007 commented 10 months ago

I just did a test and MW 1.40 does seem to work ok. Might be a PHP error. You can check your PHP error logs

You can also add this to your LocalSettings.php

    $wgShowExceptionDetails = true;
    $wgShowSQLErrors = true;
    $wgDebugDumpSql  = true;
    $wgShowDBErrorBacktrace = true;

It will enable debugging in MediaWIki and should show you what errors it is getting.

vonCorax commented 10 months ago

Found the first problem — I skipped a semicolon. :0 Still not working, though; I can log in to the forum, but when I access the wiki I'm not logged in there, and when I click the "Log in" link I get kicked back to the forum.

My php error log shows the following:

[10-Sep-2023 21:29:16 America/Toronto] PHP Warning:  Undefined array key "boardurl" in /home/brassgog/public_html/wiki/extensions/ForumSsoProvider/ForumProvider/smf2.1.php on line 43
[10-Sep-2023 21:29:16 America/Toronto] PHP Warning:  Undefined array key "auth_secret" in /home/brassgog/public_html/wiki/extensions/ForumSsoProvider/ForumProvider/smf2.1.php on line 45

So, progress. :P

jdarwood007 commented 10 months ago

You are not pointed to the right location for your forum root. Ensure $wgFSPath points to your forum root, where your Settings.php is.

vonCorax commented 10 months ago

When I changed the variable name from $wgFSPath to $wgFSPPath I stop getting errors, and can log into the wiki. I'm waiting for some of my other users to test it, and will report back.

jdarwood007 commented 9 months ago

That looks right, documentation issue.

vonCorax commented 9 months ago

We still aren't quite there. I had my co-Admin and one of my Moderators try to log in to the wiki, as well as my own sock puppet user. The Admin was able to edit the wiki under their own account, but neither the Mod nor my sock puppet were able to do so. What have I overlooked?

Here is the relevant block from LocalSettings.php:

$wgFSPPath = "/home/brassgog/public_html/forum";
$wgFSPSoftware = 'smf2.1';
$wgFSPAllowGroups = array(5);
$wgFSPAdminGroups = array(1, 3);
$wgFSPSuperGroups = array(1);
$wgFSPInterfaceGroups = array(1);
$wgFSPSpecialGroups = array(
    3 => 'special',
);
$wgFSPEnableBanCheck = true;
$wgGroupPermissions['*']['createaccount']     = false;
$wgGroupPermissions['*']['read']              = true;
$wgGroupPermissions['*']['edit']              = false;
$wgGroupPermissions['*']['createtalk']        = false;
$wgGroupPermissions['*']['createpage']        = false;
$wgGroupPermissions['*']['writeapi']          = false;
$wgGroupPermissions['user']['move']           = true;
$wgGroupPermissions['user']['read']           = true;
$wgGroupPermissions['user']['edit']           = true;
$wgGroupPermissions['user']['upload']         = true;
$wgGroupPermissions['user']['autoconfirmed']  = true;
$wgGroupPermissions['user']['emailconfirmed'] = true;
$wgGroupPermissions['user']['createtalk']     = true;
$wgGroupPermissions['user']['createpage']     = true;
$wgGroupPermissions['user']['writeapi']       = true;

wfLoadExtension('ForumSsoProvider');
jdarwood007 commented 9 months ago

The SMF moderator group (3) is a special ad-hoc group. Users only get this group when they are in the board granting them moderator permissions. You will need a regular or post group instead. As you are using $wgFSPAllowGroups and I see its ID 5, that is a post group by default in SMF. All your users would need to be in that group to be allowed to use the wiki. If you are wanting to use wgFSPAllowGroups, I would recommend then using a regular group and adding your users to this group. If your looking for dynamically allowing users, I would recommend instead of using wgFSPDenyGroups if you are looking to restrict total edit access on the wiki. We use that on wiki.simplemachines.org, to block users with a low post count on the forum from editing the wiki. Which acts as a spam control by centralizing our efforts and usually after users pass the post count they are most likely not spammers and will make good contributions.

vonCorax commented 9 months ago

I copied those values from README.md without any idea what they mean. Could you point me toward the relevant documentation, please?

jdarwood007 commented 9 months ago

The readme is the documentation currently, it just could use some improvement it seems.

$wgFSPAllowGroups - Users must be in this group to login/edit the wiki $wgFSPAdminGroups - Users in these groups are granted the wiki admin rights $wgFSPSuperGroups - Users in these groups are granted the super user wiki rights $wgFSPInterfaceGroups - Users in these groups are granted the interface wiki user rights $wgFSPSpecialGroups - This is a special configuration. You can define SMF member groups and custom wiki groups they are assigned to. You won't need this if you don't have any special/custom wiki groups.

vonCorax commented 9 months ago

Actually I was wondering about the SMF side of things ie. how the user groups are numbered &c.

jdarwood007 commented 9 months ago

If you go to the ACP > Membergroups Click modify on any. In the url you will see group=### That number is the group id.

vonCorax commented 9 months ago

I see. Thank you.

So what number is the "Regular Users" group? README.md says 2, but on my forum that's Global Moderators.

jdarwood007 commented 9 months ago

That is also a pseudo group. So it doesn't exist. If your looking to allow everyone, you don't need to specify $wgFSPAllowGroups.

vonCorax commented 9 months ago

One of my regular users has just confirmed that they can create/edit wiki pages, so I think we can call this closed. Thanks for your assistance.