Author Topic: Simple multiple domains login  (Read 9914 times)

Offline chaky

  • Newbie
  • *
  • Posts: 2
Simple multiple domains login
« on: November 03, 2009, 10:50:45 AM »
I have server with about 30 mail domains on it.
I wanted my users to use simple logins, not the FQDN ones.
In earlier versions I had to edit some core functionality to allow that, but with plugin API introduction, it became very easy.
So, I share my solution with community. Hope that helps someone.

1) All domains should have the same subdomain for webmail page address.
My ones look like mail.domain.com, mail.domain1.com and so on.
This is because the domain part being extracted from the page URL. If you want to use another subdomain, or don't use subdomain at all - open the domain_login.php file, find the string
Code: [Select]
$dhost = substr($_SERVER['HTTP_HOST'],5);
and change the 5 ("mail.") to your subdomain's length + 1 (for dot)
So, if no subdomain is used, change it to
Code: [Select]
$dhost = $_SERVER['HTTP_HOST'];
2) In Apache virtual host configuration for RoundCube webmail page you should have something like:
Code: [Select]
ServerName mail.domain.com
ServerAlias mail.domain1.com
ServerAlias mail.domain2.com


And so on. Don't forget to add ServerAlias directive for every your new domain.
3) Download the attached file and unzip to the plugins/ directory
4) Edit your config/main.inc.php file to enable the plugin called 'domain_login'
Code: [Select]
$rcmail_config['plugins'] = array('domain_login');

When plugin enabled, user can visit the page http://mail.domain.com and enter his localpart login - the domain part is extracted from the page URL and added to user's login to form the FQDN login, which is used to authenticate. Plugin checks for the "@" symbol in user's login, so if the FQDN login was entered then nothing will be added - thus plugin doesn't brake the FQDN-style authentication for those who doesn't need short logins.

P.S. RoundCube rocks! :D

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Simple multiple domains login
« Reply #1 on: November 03, 2009, 10:56:22 AM »
Nice! I was thinking about doing something like this myself, you saved me the time!

Offline leo85

  • Newbie
  • *
  • Posts: 2
Simple multiple domains login
« Reply #2 on: December 11, 2009, 06:21:15 AM »
Quote from: chaky;22742

2) In Apache virtual host configuration for RoundCube webmail page you should have something like:
Code: [Select]
ServerName mail.domain.com
ServerAlias mail.domain1.com
ServerAlias mail.domain2.com



Where exactly is this page? Sorry, I'm new to this.

This is just what I was looking for, thanks.

Offline jmorrow

  • Newbie
  • *
  • Posts: 3
Simple multiple domains login
« Reply #3 on: December 16, 2009, 11:28:29 AM »
The aliases he speaks of are in your webserver configuration...

Offline jmorrow

  • Newbie
  • *
  • Posts: 3
Enhancement To Plugin
« Reply #4 on: December 16, 2009, 11:36:53 AM »
Last night I wrote a simple enhancement to this login in plugin. In my version instead of trimming the url from the front you specify the number of domain elements you want, i.e. if you specify 2 (the default) elements http://www.testdomain.com and webmail.testdomain2.com would be cut to testdomain.com and test2domain.com respectively.

The nice thing about this is the subdomain of different sites can be different and the plugin still handles it correctly.

In addition to this I changed the plugin so when a user specifies there whole email address it verifies the domain part matches the current url. THis prevents a user from going to domain1 ones webmail screen and logging in with a domain2 email address.

The install is exactly the same as above. Hope this helps someone.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Simple multiple domains login
« Reply #5 on: December 16, 2009, 11:55:46 AM »
Nice upgrade! I like the verification the domain good security, Thanks ;D