Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This document describes how to create a MyProxy Plugin for Joomla 1.7. See "Creating an Authentication Plugin for Joomla 1.5" for details of how-to-create custom authentication plugins.

For this, we need to create five files as following:

  1. myproxy.xml
  2. en-GB.plg_authentication_myproxy.sys.ini
  3. en-GB.plg_authentication_myproxy.ini
  4. myproxy.php
  5. index.html (dummy)

Plug-in Manager's view in Joomla

After deploying the MyProxy plugin into Joomla, we can see the following view via Plug-in Manager. For this view, we create the manifest xml file and two language-files such as 'en-GB.plg_authentication_myproxy.sys.ini' and 'en-GB.plg_authentication_myproxy.ini'.

Create the XML install manifest and language files

The myproxy.xml

Basic options are set from field set name 'basic' in the right side of above figure.

Code Block
<?xml version="1.0" encoding="utf-8"?>
<extension version="1.7" type="plugin" group="authentication">
        <name>plg_authentication_myproxy</name>
        <author>KISTI</author>
        <creationDate>August 2011</creationDate>
        <copyright>Copyright (C) 2011 KISTI Supercomputing Center. All rights reserved.</copyright>
        <license>GNU General Public License version 2 or later; see LICENSE.txt</license>
        <authorEmail>dynam@kisti.re.kr</authorEmail>
        <authorUrl>www.kisti.re.kr</authorUrl>
        <version>0.9.0</version>
        <description>PLG_MYPROXY_XML_DESCRIPTION</description>
        <files>
                <filename plugin="myproxy">myproxy.php</filename>
                <filename>index.html</filename>
        </files>
        <languages>
                <language tag="en-GB">en-GB.plg_authentication_myproxy.ini</language>
                <language tag="en-GB">en-GB.plg_authentication_myproxy.sys.ini</language>
        </languages>
        <config>
                <fields name="params">

                        <fieldset name="basic">
                                <field name="host" type="text"
                                        default="localhost"
                                        description="PLG_MYPROXY_FIELD_HOST_DESC"
                                        label="PLG_MYPROXY_FIELD_HOST_LABEL"
                                        size="20"
                                />

                                <field name="port" type="text"
                                        default="7512"
                                        description="PLG_MYPROXY_FIELD_PORT_DESC"
                                        label="PLG_MYPROXY_FIELD_PORT_LABEL"
                                        size="20"
                                />
                                <field name="lifetime" type="text"
                                        default="12"
                                        description="PLG_MYPROXY_FIELD_LIFETIME_DESC"
                                        label="PLG_MYPROXY_FIELD_LIFETIME_LABEL"
                                        size="20"
                                />
                                <field name="outdir" type="text"
                                        default="/tmp"
                                        description="PLG_MYPROXY_FIELD_OUTDIR_DESC"
                                        label="PLG_MYPROXY_FIELD_OUTDIR_LABEL"
                                        size="20"
                                />
                        </fieldset>

                </fields>
        </config>
</extension>

en-GB.plg_authentication_myproxy.sys.ini

Code Block
PLG_AUTHENTICATION_MYPROXY="Authentication - MyProxy"
PLG_MYPROXY_XML_DESCRIPTION="Handles User Authentication against a MyProxy server <br>
<strong> Warning! You must have at least one authentication plugin enabled or you will lose all access to your site.</strong>"

en-GB.plg_authentication_myproxy.ini

Code Block
PLG_AUTHENTICATION_MYPROXY="Authentication - MyProxy"
PLG_MYPROXY_FIELD_HOST_DESC="For example: myproxy.kisti.re.kr"
PLG_MYPROXY_FIELD_HOST_LABEL="Host"
PLG_MYPROXY_FIELD_PORT_DESC="Default port is 7512"
PLG_MYPROXY_FIELD_PORT_LABEL="Port"
PLG_MYPROXY_FIELD_LIFETIME_DESC="Default lifetime is 12 hours"
PLG_MYPROXY_FIELD_LIFETIME_LABEL="Lifetime"
PLG_MYPROXY_FIELD_OUTDIR_DESC="Default outfile directory is /tmp"
PLG_MYPROXY_FIELD_OUTDIR_LABEL="Outfile Directory"
PLG_MYPROXY_XML_DESCRIPTION="Handles User Authentication against a MyProxy server <br>
<strong> Warning! You must have at least one authentication plugin enabled or you will lose all access to your site.</strong>"

Create myproxy.php file

The plgAuthenticationMyproxy Class

The onUserAuthenticate() Method

Code Block
        function onUserAuthenticate($credentials, $options, &$response)
        {
                // Initialise variables.
                $success = 0;

                // For JLog
                $response->type = 'MYPROXY';
                // MYPROXY does not like Blank passwords (tries to Anon Bind which is bad)
                if (empty($credentials['password']))
                {
                        $response->status = JAUTHENTICATE_STATUS_FAILURE;
                        $response->error_message = JText::_('JGLOBAL_AUTH_PASS_BLANK');
                        return false;
                }

                $myproxy_server = $this->params->get('host');
                $myproxy_port = $this->params->get('port');
                $username = $credentials['username'];
                $passphrase = $credentials['password'];
                $lifetime = $this->params->get('lifetime');
                $outfile = $this->params->get('outdir') . '/x509up_u' . $username;
                $DEBUG = false;
                $success = $this->myproxy_logon($myproxy_server, $myproxy_port, $username, $passphrase, $lifetime, $outfile, $response, $DEBUG);

                if (!$success)
                {
                        if (!strlen($response->status)) $response->status = JAUTHENTICATE_STATUS_FAILURE;                       
                        if (!strlen($response->error_message)) $response->error_message = JText::_('JGLOBAL_AUTH_INCORRECT');
                }
                else
                {
                        // Grab some details from MYPROXY and return them
                        $response->username = $username;
                        $response->email = $username . '@myproxy.server';
                        $response->fullname = $username;

                        // Were good - So say so.
                        $response->status               = JAUTHENTICATE_STATUS_SUCCESS;
                        $response->error_message = '';
                }
        }

The myproxy_logon() Method

We use a myproxyClient.php provided in the MyProxy website. This allows anonymous user to retrieve credentials form a MyProxy Server.

The complete package

plg_myproxylogin-1.7.0.zip