Firefox PHP

Module: External Authentication

Posted by Joe Curia 
Module: External Authentication
November 07, 2008 10:02AM
This module allows authentication to Phorum from external applications. It uses a chosen external application as the authentication master. That external application controls registration and login and passes that information on to Phorum. Only the applications listed below are supported at this time. If yours is not listed, please request it.

Supported Applications:

Apache/LDAP - by Elliot Kendall
Drupal 6.x - www.drupal.org
Elgg 1.1 - www.elgg.org
GroupOffice - www.group-office.com - by hansvd

Installation and Usage:
Depending on the plugin used, this module may only deal with authenticating to Phorum from an external application. Creating an integrated theme, linking to Phorum, and other customizations may be beyond the scope of any particular plugin.

Two downloads are available. The core download contains the module itself without any of the plugins necessary for the external applications supported. The full download contains the module and all available plugins.

This module may have different settings based on the external application you are using. Below is a basic setup example, but please follow your chosen plugin's setup guide if available.

You must first install your external application and Phorum. Next, if you only downloaded the core version of this module, you must download and install the plugin for your external application. The complete plugin folder must be placed in the phorum_root/mods/external_authentication/plugins_bin folder, just as you placed the external_authentication folder in the phorum_root/mods folder
to install this module

Next, you can enable this module and set it to use your external app as the authentication master. You should also input the path to your application. Please note that this is the server path used by PHP to move between Phorum and your application.

While the settings do exist for allowing registration, login, and logout in your Phorum install, it is highly recommended that you disable these. The
registration will not create a user in your external application. Allowing Phorum login would allow users to login to the Phorum even if they have been deleted or banned from your external application.

Please note: It is important that you use, or at least create, a user in your external application with the same username as your Phorum admin. Because the external application is the authentication master, the external user will overwrite the Phorum user's password and assume that user's rights. Thus, if you do not create an external user with the same username as your Phorum admin, another visitor could register with that username and assume the admin role in Phorum.

Developers:

If you would like to develop a plugin to allow authentication from your external application of choice, please refer to the Plugin Development Guide.

Todo:

- Add support for more applications

- Add further features as requested or as they pop into my head


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald




Edited 6 time(s). Last edit at 10/29/2009 12:02PM by Joe Curia.
Attachments:
open | download - external_authentication_v5_2_1_04_Core.zip (14.5 KB)
open | download - external_authentication_v5_2_1_04_Full.zip (71.9 KB)
Elgg 1.1 Plugin for the External Authentication Module
November 07, 2008 10:06AM
This plugin will allow external authentication from Elgg 1.1 to Phorum.

Installation:
Unzip this plugin and place the elgg_1_1 folder with all files in the YOURPHORUM/mods/external_authentication/plugins_bin folder. Go to the External Authentication settings page and select Elgg 1.1 as your external application.

If you would like to still allow registration in Phorum for users that will not register in Elgg, please be sure to copy the included "phorum_mod_external_authentication" folder from the plugin folder to your Elgg installations "mod" folder. You must then go to the Elgg Tool Administration page and enable the phorum_mod_external_authentication tool and enter the path to your Phorum installation in the tools settings (found by clicking the "more info" link). This will allow users to register on Phorum and alert a new user trying to register on Elgg with the same username as a Phorum user, unless their password is the same as the Phorum user's password at which point they are assumed to be one and the same.

This plugin also gives you the option to create a group named "Elgg Users" which will automatically contain any new Elgg users.

If you would like to edit your Phorum template to reference pages or images from your Elgg installation, you can enter the Elgg Base URL in the settings page and use {URL->Elgg_base} in your Phorum template (eg. <img src="{URL->Elgg_base}/images/example.png" />).

FYI, Elgg uses a random string named "salt" to further protect user passwords. This salt is transferred to the Phorum users as well, so an easy way to create custom template or php code shown only to Elgg users is to check for that salt string.
In the templates, you would add:
{IF USER->phorum_mod_external_authentication_elgg_1_1_user_salt}
    Your custom HTML/template code
{/IF}
In other modules or php files (assuming user data is available for the current hook/php file) you would add:
if (!empty($GLOBALS["PHORUM"]["DATA"]["USER"]["phorum_mod_external_authentication_elgg_1_1_user_salt"])) {
    //Your custom php code
}

Please note, this plugin is also available in the latest full download of the External Authentication module.

Changelog:
R4
- Enhancement: Added support for using the {URL->Elgg_base} variable in templates. This URL is entered in the External Authentication module's settings page.
- Bugfix: Elgg users' names are now mapped to the real_name field. Thanks go to Phorum user antonchanning for reporting this bug.

R3
- Enhancement: The Elgg plugin will now automatically update the Phorum database whenever an Elgg user is created or updated.
- Bugfix: Elgg mod now properly uses the assigned Phorum path.
- Enhancement: Added the ability for the admin to automatically add each Elgg user to a Phorum group named "Elgg Users."

R2
- Enhancement: Added an Elgg plugin which detects username conflicts if registration is allowed in Phorum.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald




Edited 3 time(s). Last edit at 03/31/2009 11:23AM by Joe Curia.
Attachments:
open | download - elgg_1_1_external_authentication_plugin_R4.zip (8.3 KB)
Plugin Development Guide for the External Authentication Module
November 08, 2008 01:42PM
This is a short guide to developing a plugin to allow an external application (such as Drupal, Joomla, Wordpress, etc.) serve as the authentication master for Phorum using the External Authentication module. Please remember you can also use the existing plugins to provide examples and the attached base plugin to use as a base to build your plugin. In fact, the base_plugin folder can be easily renamed and each file modified as needed for your plugin.

Create a folder for your plugin in the external_authentication/plugins_bin. This folder will hold all of the files necessary to run your plugin.

Create the info.php file. This file contains the necessary details to integrate your plugin into the module. The base_plugin/info.php file contains examples of the required details. The "required_version" is the version of the External Authentication module which support the necessary hooks and settings for your plugin.

This module currently supports multiple hooks in the Phorum system. To use these or any Phorum hooks, you should create a file for named "hook_THE_HOOK.php" and place the code for your hook to run in that file. Please note the required return data when building your hook.The currently supported hooks are:
  • after_register
  • common_post_user
  • common
  • start_output
  • user_authentication
  • user_delete
  • user_save
  • user_session_restore
If you need new hook support for your plugin, please request it and it will be promptly added to a new version of this module.

The main hook is the user_session_restore hook. This hook is necessary to pass your external application's session data on to Phorum. More info and examples can be found in the base_plugin/hook_user_session_restore.php file.

If you need to present settings to the forum admin, you can use the settings.php and settings_post.php files. These files execute code in the External Authentication module's settings page. Again, info and examples can be found in the base_plugin files.

By default, this module allows the forum admin to disable/enable registration, login, and logut directly in Phorum. If your plugin does not support Phorum registration, login, or logout, you can remove these options from the settings page. Please see the base_plugin/settings_post.php for details on how to remove these options.

The settings_post.php file can also be used to setup a user id synchronization table in the Phorum database. This database can be used to synchronize users when the username cannot be used. This is especially useful in systems where users can change their usernames. Each time a user is created, your code can replicate that user either to Phorum or to the external application.

There are three functions you can use with the synchronization table:
  • phorum_mod_external_authentication_db_add_user($phorum_user_id, $external_user_id)
    • This function adds a user to the synchronization table, linking their Phorum user id and the external applications user id together.
  • phorum_mod_external_authentication_db_get_user($user_id, $source)
    • This function returns the desired user id. The inputs are a user id andeither MOD_EXT_AUTH_GET_EXTERNAL_USER or MOD_EXT_AUTH_GET_PHORUM_USER. For example, If you want to get the Phorum user id for an external user, you might use this line of code:
      Language: PHP
      $phorum_user_id = phorum_mod_external_authentication_db_get_user($external_user_id, MOD_EXT_AUTH_GET_PHORUM_USER);
  • phorum_mod_external_authentication_db_delete_user ($user_id, $source)
    • This function deletes a user from the synchronization table. The inputs are auser id and either MOD_EXT_AUTH_DELETE_EXTERNAL_USER or MOD_EXT_AUTH_DELETE_PHORUM_USER.
If you would like to allow the settings page to search for the external application's server path, you can set the $external_application_path_ids array in the settings_post.php file for your plugin. This array consists of two values:
  • unique_file_name is a file which should be unique to your external application. Please note that if the file is in a sub-directory of the external application, you should include that sub-directory in this field (eg. "includes/misc/myfile.php").
  • unique_string is an optional string to search for in your unique file. If you are sure that your file is unique, you can simply leave this string empty.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald




Edited 2 time(s). Last edit at 03/31/2009 10:54AM by Joe Curia.
Attachments:
open | download - base_plugin_R3.zip (9 KB)
Re: Module: External Authentication
November 09, 2008 01:21PM
Hello there,

Thanks for creating this module. I am wondering about using this module with YACS (Yet Another Community System). Is anyone already working on a specific plug-in for this CMS?

I am happy to begin working on one if no one else is, though I am certainly a noob when it comes to programming.

Thanks,
Jael

- another member of the 'enough information to be dangerous' group
Re: Module: External Authentication
November 10, 2008 09:59AM
I doubt anyone has begun a plugin for YACS so I wish you luck in the endeavor. It is a complex task and I can offer some help along the way, but if you haven't coded much in PHP it may be tough.

If you are willing to wait a while for me to finish my current project, I would be happy to take a crack at a plugin for YACS myself, but it could be a month or more before I can get to it.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: External Authentication
November 15, 2008 11:19PM
Hello Joe,

Thanks for the offer. I just saw your reply today; sorry about the delay. I will let you know if I have any success. No rush on this. I've been annoyed at the YACS interface for almost two years now; another month or so isn't a big deal.

One aspect I was realising might be a bit of an issue is the way the YACS forum collects forum posts and adds them to the listing in the Categories section. I'm not sure how easy that would be to integrate. This was one of the key elements that drew us to YACS in the first place, so that might be something to be considered before much effort gets put into the plug-in. That said, if it was possible to link to the general section and simply have a flag to indicate a new post had been made or with the date of the last post, that might be workable.

And if you're reading that and thinking "of course, that's part of the plug-in", please let me know so I don't spend time on attempting to learn enough PHP to create the plug in, as I am clearly missing too much background to make a usable plug-in.

Thanks!
Jael

- another member of the 'enough information to be dangerous' group
Re: Module: External Authentication
November 16, 2008 12:07AM
Quote
Jael
One aspect I was realising might be a bit of an issue is the way the YACS forum collects forum posts and adds them to the listing in the Categories section. I'm not sure how easy that would be to integrate. This was one of the key elements that drew us to YACS in the first place, so that might be something to be considered before much effort gets put into the plug-in. That said, if it was possible to link to the general section and simply have a flag to indicate a new post had been made or with the date of the last post, that might be workable.

A quick browse through the YACS website left me scratching my head a bit as to where the "Categories" section was, but I would imagine a hook to call the phorum_db_get_recent_messages would give you the message info you need to display a list of messages. If a simple link is fine, I would suggest the Recent Messages module with a link to that module's page of recent messages, however the new flag/last post date would require more interaction.

I wish you the best of luck in tackling the difficult task of integrating apps.


Joe Curia (aka Azumandias)
Modules: l0Admin Mass Email00000000l000000Automatic Time Zones000ll.l00000Enhanced Custom Profiles0.00Google Calendar0000l.l000000Post Previews
000000000Admin Security Suite000000000000Check Modules for Upgrades0000External Authentication000000Group Auto-Email00000.00000Private Message Alerts
000000000Attachment Download Counter0000Custom Attachment Icons000ll.ll00Favorite Forums000000.00000Highlighted Search Terms0000Self-Delete Posts Option
000000000Attachment Watermarks0l00000000Custom Language Database00l.l.0Forum Lockdown00000.00000Ignore Forums0000000000000Threaded Tree View
000000000Automatic Message Pruning00.llll.00Easy Color Scheme Manager0l.l00Forum Subscriptions0000lll000Moderated User Group
Templates:lGeneric Integration000000000 0000Simple Rounded000000 00000000Tabbed Emerald
Re: Module: External Authentication
November 16, 2008 09:02AM
Thank you! I will be reviewing those modules as I embark on this adventure.

The category system in YACS is one of the features that sold me on the system. Categories are a bit like a Site Map, but the Site Map is based on page location and Categories are based on topic or theme. Each item on the site is connected to one or more categories, with the page location being set in a different field. This makes it so you can select one primary topic and then see all related articles, forum posts, chat logs, etc. This is particularly useful when the topics often overlap one another.

Thanks again,
Jael

- another member of the 'enough information to be dangerous' group
Re: Module: External Authentication
December 06, 2008 01:59AM
Hi Bit New to Forum, But I like how it just sits perfectly in Website baker, I no there is not a single forum that works with it, the best I can find is [www.rockurchin.com]

But I'm Just not getting it, all I'm getting is all of the mysql output on top, anyway, its definitely a place you would be worshiped
:) anyway you asked for suggestions her's a great one.

PP
Group-Office 3.0 plugin
January 05, 2009 05:21PM
Based on the base plugin, I have put together a plugin for group-office. (www.group-office.com). I found it hard to write a function that is running in the GO scope and extracts the username. Therefore, I tried --and succeeded (by accident??)-- to pick up the GO session extract the user data from there. As GO doesn't hold the MD5 hash of the user's password in the session, I disabled password synchronisation.

I am new to PHP development and I am unsure whether this (playing around with the session) is the right thing to do. But on my test system (Windows/XAMPP), it's working like a charm. Before anyone deploys this plugin, I would like the Phorum gurus to give their opinion on my piece of art.

I have only made edits to hook_user_session_restore.php and info.php. I left the other files untouched and I am not sure whether I can delete them from the plugin.

Looking forward to your comments.
Attachments:
open | download - groupoffice_plugin.zip (6.8 KB)
Sorry, only registered users may post in this forum.

Click here to login