|
Cookbook /
AuthPhpbb2SsoSummary: Single Sign On for PmWiki and phpBB2
Version: 080401
Prerequisites: Working phpBB2 installation on the same server
Status: Release candidate
Maintainer: Jantah
Questions answered by this recipe
DescriptionAuthPhpbb2Sso uses phpBB2 to authenticate users, and the standard AuthUser functions for PmWiki authorization. This recipe provides 100% integration of the phpBB authentication and session management. This is achieved by including the relevant scripts from the phpBB installation and calling the appropriate functions. The phpBB2 session is kept alive while the user is browsing the wiki. No hacks into the phpBB scripts are required. This recipe has been tested with PmWiki version 2.2.0-beta65 and phpBB2 version 2.0.23. This recipe will not function on phpBB3. The recipe has yet to be installed on a live system, I've already put it here for feedback. Installation
Note: the PhpbbRootPath should point to the path of your phpBB2 installation.
Main featuresAfter installing the recipe as described above, user and group information from phpBB can be used to setup authorization of the various PmWiki pages. The standard AuthUser function is used to setup authorization, but obviously, the SiteAdmin.AuthUser page is not required, since user and group administration is done in phpBB. By default, there are no restrictions, except for PmWiki admin pages. PmWiki admin pages are restricted to phpBB users that are assigned the "Administrator" user level. All other authorization can be set up as required. Check AuthUser and Passwords for details, but find some examples below:
Other featuresAuthorThe author name will be set to the phpBB username. Since it is not possible to overrule this from the edit page, you may choose to delete the Author field from your Site.EditForm page: (:input e_author:)
Page compressionIf set in phpBB, and the client supports this feature, pmWiki pages will be compressed before being sent to the client. This usually saves around 80% in bandwidth. Recognizing administratorsSite administrators are marked in phpBB with a separate "User level", which cannot be used in PmWiki. This recipe automatically assigns the PmWiki group "siteadmin" to members that have user level "Administrator", so it can be used for PmWiki authorization. If you want to use another group name, add the following line to your local/config.php, before including AuthPhpbb2Sso: $PhpbbAdminGroup='wikiadmin';
Replace 'wikiadmin' with the name you would like to use. Group moderatorsEvery group in phpBB has one group moderator. This is propagated to PmWiki by assigning a group membership of the group name + "Moderator" to the group moderator. So, for example, the moderator of the phpBB group "Wiki" will also be member of the PmWiki group "WikiModerator". If you want to use a different suffix, add the following line to your local/config.php, before including AuthPhpbb2Sso: $PhpbbGroupModSuffix='Mod';
Replace 'Mod' with the suffix you would like to use. Redirect to phpBB login pageIf access to a certain page is denied, by default the PmWiki password page will be displayed. To obtain a tighter integration with phpBB, add the following line to your local/config.php: RedirectOnDeny ();
If a client tries to acces a privileged page, the response will now depend on whether the user is signed in or not:
The message and action can be modified by setting the $AuthPromptMemberFmt and $AuthPromptAnonymousFmt variables before calling RedirectOnDeny(), for example: $AuthPromptMemberFmt=array(&$PageStartFmt , 'Sadly, you are not allowed to access this page' , &$PageEndFmt); $AuthPromptAnonymousFmt=array(&$PageStartFmt , "You may need to <a href='$PhpbbUrl/login.$phpEx'>login</a> to access this page." , &$PageEndFmt); RedirectOnDeny (); Template variablesThe recipe also sets a couple of variables that can be used in the PmWiki templates to visually integrate PmWiki and phpBB:
Link to phpBB profileBy default, the " Markup ('[[~', '<links','/\\[\\[~(.*?)\\]\\]/e', "PhpbbUserProfile('$1')");
This will also work with the current user tag (three tildes) and from the recent changes page. Time and date format, timezoneSince the time and date format and timezone are also set in the phpBB2 and user configuration, these can be retrieved and used in PmWiki. To enable this, add the following line to your local/config.php: UsePhpbbDateSettings ();
This will also change the format of the new entries written to the RecentChanges page. The time of the change is now entered as Detailed descriptionThis recipe includes a couple of scripts from the phpBB installation to enable it's session management in PmWiki. The basic goal of the whole exercise, the holy grail if you will, is to call the following phpBB2 function, which will take care of the entire session management: $userdata = session_pagestart($user_ip, -20);
To achieve this, the following steps are performed:
And that's it. We can now call the session_pagestart() function and take it from there. Limitations
Future Enhancements
Release Notes
See Also
ContributorsComments2008-02-20 - I just tried this, but it looks like a slash is missing when directed to the login page. I got to mydomain.comforum/login.php instead of mydomain.com/forum/login.php. I just can't seem to find where I should put that slash ;-) - blader_se 2008-02-21 - This was probably caused because your phpBB setting "script_path" did not start with a slash. Uploaded version 080221, which handles the settings similar to phpBB. Also made a couple of tweaks in the section that adds the session identifier for clients with cookies disabled. - Jantah 2008-03-17 - This script is wonderful. Is there any way however to give PHPBB users specific page privileges. I'm trying to make it so each user can edit their own specific page. The id:user in action=attr doesn't seem to work however. ~ Sarif 2008-03-18 - Not yet possible, I've copied the authorization function from AuthPhpBB2, and only slightly modified it. It distinguishes between guests, registered users and admins, but no more. I am working on extending that to phpBB groups and user-specific authorization. Stay tuned. - Jantah 2008-03-22 - Should have known it was not that hard in PmWiki. Just set the $AuthId, populate the $AuthList array and let AuthUser take care of the rest. I called this a release candidate, need some feedback (here, or by email from my profile page) to be certain about the stability. - Jantah 2008-03-30 - Right now, I'm setting up a site for a game (just a small mud) I'm staff at with pmwiki/phpbb and your recipe. I haven't installed the latest version yet, however, but it's been working well for user contributions. Within the next week or so, we'll probably be installing your latest release and making PmWiki/phpbb the main portion of our site. When we get the site up and working, skinned, and all that, I'll post a link for you. Great work on the recipe. It's saved me a lot of headaches and expanded on what we can easily provide for our players. Players will have personal pages, and pages for their characters and be able to contribute to various in-game groups they're a part of, without much work in terms of authentication that we've been integrating between our game and phpbb2 already. You rock. ~ Sarif 2008-04-01 - Will there be any support for calling group moderators in a separate group? Like @mod-foo would call the moderators for group foo? ~ Sarif 2008-04-01 - That seems like a good one. Group moderators may need additional privileges in areas where the group has certain rights. I've opted for a name suffix, because this results in a more descriptive group name. The moderator of the phpBB group "@Foo" will automatically be member of the PmWiki group "@FooModerator". - Jantah 2008-07-12 - Does anyone have a perspective on revising this code to work with phpbb3. I already have phpbb3 active and want to bring up a complementary PmWiki. What scale of debug/changes am I going to have to attempt? -Chris C |