Menu

#16 Virtualhosting mode

open
Tony Kay
New Feature (7)
5
2007-11-09
2007-11-09
No

Hello,

I'm likely going to be hacking on this shortly, and I'll try to make my code clean and generic for submission as a patch, but I wanted to at least open a ticket in case you have any suggestions.

The problem is this: Our company has a single IMAP server that has many virtualhosts on it. Logins are the full email address, and we don't actually care what domain a person is trying to log in to, as long as it only connects to the single IMAP server.

What I'm thinking is an alternate mode to the current MX feature, where instead of login: at the front page, it's email:, with a reversal of the current javascript '@' check, and the various other small issues created by joining the username and MX.

Any suggestions?

I'll comment here with any progress/updates.

Discussion

  • Tony Kay

    Tony Kay - 2007-11-10

    Logged In: YES
    user_id=1651837
    Originator: NO

    Hmmm. I guess we need to add a config parameter. Something that would change the nature of the login page slightly, but allow for the current behavior. You'd still use the imap config parameter, just with one entry. There's not much to it really. The back end should be perfectly happy with login names that contain @.

     
  • Graham Forest

    Graham Forest - 2007-11-10

    Logged In: YES
    user_id=1194294
    Originator: YES

    I've got the trivial frontend changes done and in, and I can indeed log in the virtualhosting style, but a slight problem arises from a few places in the code where your email address is figured out by using the username@mx. I'm still going over the code trying to determine if it would be easiest to "fix" the username post login, or cause the user@mx concatenation to only happen when there isn't an @ in the username. Suggestions?

     
  • Graham Forest

    Graham Forest - 2007-11-10

    Logged In: YES
    user_id=1194294
    Originator: YES

    File Added: index-virtualhosting.diff

     
  • Graham Forest

    Graham Forest - 2007-11-10

    Current index.html diff

     
  • Tony Kay

    Tony Kay - 2007-11-11

    Logged In: YES
    user_id=1651837
    Originator: NO

    Oh. That's probably going to hose you significantly. I just realized that there are numerous places in the code where it assumes the user name is before the @, and it pastes @ and the MX on the end.

    This is probably going to take some redesign effort to keep it from being a mess. Problem areas will exist in lib/AlphaMail/Message.pm (and others). Everything from settings to read are probably affected.

    I may have time to look at this within a few days, but not really today.

    Basically, it is probably going to work best to set some variables in the user's session object, and remove all of the logic code that derives things from "user" from the rest of the app.

     
  • Nobody/Anonymous

    Logged In: NO

    Yeah, I see a small handful of places that directly concatenate the username and the mx. The best solution so far that I've seen would be to add the reply to address as part of the first login page so that it is guaranteed to be populated, then put a bit more logic in there and the relevant prefs page so that usernames with @'s are handled correctly. The remaining problem that I'm trying to think around at the moment is that the mx isn't actually valuable in this case, unless you ignore the IMAP->mx mapping, or replace the mx with the last half of the username upon login. I definitely don't know how the backend will handle that, though.

    More thinking soon.

     
  • Tony Kay

    Tony Kay - 2007-11-12

    Logged In: YES
    user_id=1651837
    Originator: NO

    Hey,

    I just looked at the code. It looks like I can put in vhosting mode by primarily creating two substitute modules in the libraries to sub in for User and IMAPAuth. Other than that, the login page and config files are all that will have to change.

    I'll give you an update soon.

     
  • Tony Kay

    Tony Kay - 2007-11-12

    An approximation of vhosting support. Not tested.

     
  • Tony Kay

    Tony Kay - 2007-11-12

    Logged In: YES
    user_id=1651837
    Originator: NO

    OK, here is the idea. No new config parameter was needed in the central config file. Instead, make the following changes to your parameters:

    In alphamail_config:

    imap_servers: virtual=server.example.com[prefix]
    username_maxchars: 40

    In the apache settings for alphamail:

    change:
    PerlSetVar SiteControlMethod IMAPAuth

    to

    PerlSetVar SiteControlMethod VIMAPAuth

    And add:
    PerlSetVar SiteControlUser VIMAPUser

    The following is an approximate list of changes:

    - patched the site control system to allow customized user classes.
    - added separate attribute to user object (imap_auth_name)
    - $user->getUsername still returns the mailbox (before the @) (used for bunches of stuff)
    - Change middleware to use the user object directly (extracts imap_auth_name now)
    - Changed creation sites of middleware to use new calling convention
    - Had to make Middleware::new morphing...there were a few call sites where the old calling convention really was required
    - Modified login page (index.html) to morph according to mode

    I do not have a virtual imap server, nor time to play much more with this. I am attaching the patch. This should be pretty much complete, but I'm sure something still needs help :)

    Good luck.
    File Added: vhost.patch

     
  • Tony Kay

    Tony Kay - 2007-11-12

    Logged In: YES
    user_id=1651837
    Originator: NO

    Added an svn branch for this feature. Any future patches should be generated via "svn diff" against this version.

    Check it out with:

    svn co https://alphamail.svn.sourceforge.net/svnroot/alphamail/src/alphamail-vhost

    then try:

    autoreconf -i

    to build the configure script and makefile inputs.

    A diff should be generated with:

    svn diff > my.patch

    in the top-level directory.

    Thanks!

     
  • Graham Forest

    Graham Forest - 2007-11-13

    Syntax error fixes for vhost branch

     
  • Graham Forest

    Graham Forest - 2007-11-13

    Logged In: YES
    user_id=1194294
    Originator: YES

    I've attached a patch to fix some syntax errors in the vhost branch. After the fixes, the index page works, but logging in fails without touching the imap server and no messages logged for the UI.

    I can spend time soonish figuring out exactly why, I'll let you know.
    File Added: vhost-fixes.diff

     
  • Dido

    Dido - 2007-11-26

    Logged In: YES
    user_id=1941361
    Originator: NO

    Hi Guys,
    I'm trying to run vhost feature, but can't succeed.
    I'm doing svn co https://alphamail.svn.sourceforge.net/svnroot/alphamail/src/alphamail-vhost , and when I try to start init.pl have errors:

    perl init.pl
    "my" variable $server masks earlier declaration in same scope at /usr/local/lib/alphamail/AlphaMail/Middleware.pm line 72.
    syntax error at /usr/local/lib/alphamail/AlphaMail/Middleware.pm line 74, near ") {"
    Global symbol "$user" requires explicit package name at /usr/local/lib/alphamail/AlphaMail/Middleware.pm line 75.
    Global symbol "$user" requires explicit package name at /usr/local/lib/alphamail/AlphaMail/Middleware.pm line 76.
    Global symbol "$user" requires explicit package name at /usr/local/lib/alphamail/AlphaMail/Middleware.pm line 77.
    Global symbol "$user" requires explicit package name at /usr/local/lib/alphamail/AlphaMail/Middleware.pm line 78.
    syntax error at /usr/local/lib/alphamail/AlphaMail/Middleware.pm line 79, near "} else"
    Compilation failed in require at /usr/local/lib/alphamail/AlphaMail/Message.pm line 11.
    BEGIN failed--compilation aborted at /usr/local/lib/alphamail/AlphaMail/Message.pm line 11.
    Compilation failed in require at init.pl line 24.
    BEGIN failed--compilation aborted at init.pl line 24.

    Any ideas how to fix this are more then welcome.

     
  • Graham Forest

    Graham Forest - 2007-11-26

    Logged In: YES
    user_id=1194294
    Originator: YES

    I'll be updating that branch to compile (and hopefully work, which is a step I have not yet started) within the next few days. I'll be making note of my progress here, so stay tuned.

     
  • Graham Forest

    Graham Forest - 2007-12-30

    Logged In: YES
    user_id=1194294
    Originator: YES

    Just a status, I haven't had time to continue this due to other demands, but it is still on my list. I'll be spending some time trying to get a better environment set up to debug the current revision of this branch now.

     
  • Graham Forest

    Graham Forest - 2008-01-12

    Logged In: YES
    user_id=1194294
    Originator: YES

    Ok, I've got all the login preventing bugs worked out of the vhost branch, save two. Firstly, IMAPUser.pm, VIMAPAuth.pm, and VIMAPUser.pm are not installed correctly. I'm not terribly familiar with the behind the scenes usage of autotools, so I'm not sure how to fix this. Secondly, VIMAPUser or IMAPUser need use'd in init.pl, depending on what you're doing. I'm not sure if it's easy to check which is being asked for in the apache conf and use that one when it runs, or if it's easier to just use them both and ignore the 1k of RAM wastage. Currently if you want to try this you'll just have to add "use VIMAPUser;" to init.pl, manually copy the previously mentioned files to the correct place, and follow Tony's previous instructions.

    This could use some heavy testing, which I will be working on.

     
  • Tony Kay

    Tony Kay - 2008-01-13

    Logged In: YES
    user_id=1651837
    Originator: NO

    Installation is done by just including the names in the correct Makefile.am. Do a grep and look for the one containing other pm files. After you do that, autoreconf is in order, which will regenerate all of the configure files and such.

    If you want to update the RPM config files, just add the new files to be installed in them as well (in aux/build/...).

    Go ahead and throw all of them in the template version of init.pl. Memory is such a non-issue.

     
  • Tony Kay

    Tony Kay - 2008-01-20

    Logged In: YES
    user_id=1651837
    Originator: NO

    I merged the source for this back into the trunk. I ran the regression tests, and it didn't break any of the old code as far as I can tell. I looked at the source, and it looks golden.

    Looks like I still need to do a few things before making the next release:
    1. Fix up the Makfile.am files to include the new stuff
    2. Update the change log
    3. Other stuff I'm probably forgetting, but will remember as I go :)

     
  • Graham Forest

    Graham Forest - 2008-04-12

    Logged In: YES
    user_id=1194294
    Originator: YES

    Just a status, completing this is still in the plans, it has just been pushed into the future by some other projects.

    Stay tuned.

     

Log in to post a comment.

MongoDB Logo MongoDB