Roundcube Community Forum

 

Custom login and logout scripts

Started by pedrusko, February 06, 2009, 04:38:31 AM

Previous topic - Next topic

pedrusko

Hello all,

I think it would be nice to have a custom login and logout scripts.

i.e. a place to change the username or server provided by the uses.

I have now squirrelmail with custom login plugin that matches mail domains to servers, and changes username in a form the server can use.

The user writes his/her mail address as login, and then it is rewited like:

[email protected] -> username = user1, server = server 1
[email protected] -> username = user2.domaind.tld, server = server 2

I use a single page for login to various servers with different configurations.

I think it could be a nice feature.

Thanks to all for this great software :)

oSIRus

Hello pedrusko,

very interesting, because I need to provide similar functionality for our school.

Did you use the plugin architecture?

I already tried to implement the sample plugin (automatic login if on localhost, URL), but it doesn't seem to work. Do you somehow have to activate the plugin architecture in the first place?

Thank you,

oSIRus

pedrusko

Hello,

The plugin is for squirrelmail only :(

Is there a document explaining the plugin interface?
I could adapt the plugin or make a new one if necessary.

I'm working for an academic institution too ;)

Regards,

  Pedro

pedrusko

As seen on roadmap, plugins will not be available until 0.3 :(

Roadmap ? RoundCube Webmail ? Trac

rosali

#4
There is no documentation yet. But you can analize the example plugins ...

/branches/devel-api ? RoundCube Webmail ? Trac
Regards,
Rosali

pedrusko

I have made a sample plugin, not tested yet.

Any suggestions would be apreciated :)


File milogin.php
<?php
// Change username / host based on email address.
// Author: Pedro R. Benito <[email protected]>
// Last modified: 09/02/2009
//
// 1.- User enters email address instead username.
// 2.- Username and host are selected automaticaly.

class milogin extends rcube_plugin
{
    function 
init()
    {
        
$this->add_hook('startup', array($this'startup'));
        
$this->add_hook('authenticate', array($this'authenticate'));
    }

    function 
startup($args)
    {
        
$rcmail rcmail::get_instance();
        
        return  
$args;
    }
    
    function 
authenticate($args)
    {
        
// File containing domain names and associated config.
        // Sample content:
        //
        // <?php
        // $domains = array();
        //
        // $domains['domain1.tld']['type'] = 'simple';
        // $domains['domain1.tld']['host'] = 'host.name.tld';
        // ? >
        
include 'milogin_domains.conf.php';
        
        
// Discover user and domain name.
        // $parts[0] holds login name.
        // $parts[1] holds domain name.
        
$parts explode('@',$args['user']);
        
        switch(
$domains[$parts[1]]['type'])
        {
            case 
'simple':
                
// username = login name
                
$args['username'] = $parts[0];
                break;
            case 
'dotted':
                
// username = loginname.domainname
                
$args['username'] = $parts[0].".".$parts[1];
                break;
                
        }

        
// Extract host from domain config.
        
$args['host'] = $domains[$parts[1]]['host'];
        
        return 
$args;
    }
}

?>

File milogin_domains.conf.php
<?php
$domains 
= array();

$domains['domain1.tld']['type'] = 'simple';
$domains['domain1.tld']['host'] = 'server1.tld';

$domains['domain2.tld']['type'] = 'dotted';
$domains['domain2.tld']['host'] = 'server2.tld';

?>