I use a supervisor database to store db credentials to customer databases.
Here is the schematic process (done in a plugin):
- determine which account was used, either from subdomain (account1.webapp.domain.com/... <http://webapp.domain.com/account1/module/controller/action>) or from the URL path (webapp.domain.com/account1/... <http://webapp.domain.com/account1/>) - use the account to query supervisor database (the account is the primary key)
- retrieve the customer database credentials from this supervisor db
- define the default adapter with those credentials

Hope this help
--
Guillaume

Le 23/12/09 23:39, Daniel Latter a écrit :
Hi Guillaume,

How do you handle passwords for your customer databases? do you have a look up list - be it a file, database .. ?

For example if a sub-domain hits the server, how are db credentials gatherd/defined? We can determine username from subdomain part but what about passwords? I just ask as I am thinking about the best approach to take.

Thanks for any advice.
Dan





2009/12/21 Guillaume ORIOL <[email protected] <mailto:[email protected]>>

    Yes, I have exactly one database per customer and one more for
    supervision purpose (where access to customer databases are defined).

    Le 21/12/09 16:08, Daniel Latter a écrit :
    Hi,

    I have a situation very similar to yours, although I am not sure
    about the answer to your question, I have a quesiton for you:
    when you say you have several databases, what do you mean? do you
    mean one per customer/application?

    Thanks
    Dan





    2009/12/21 Guillaume ORIOL <[email protected]
    <mailto:[email protected]>>

        Working on an application that is the same for multiple
        customers, I had to face a design option.
        I wanted to avoid installing the application as many times as
        we had customers (for maintenance reasons).
        Therefore I chose to have a unique code installation but
        several databases.
        Each customer would access its application by adding its
        account name to the application base URL:
        webapp.domain.com/account1/ <http://webapp.domain.com/account1/>
        webapp.domain.com/account2/ <http://webapp.domain.com/account2/>
        etc.

        Following this URL prefix are the regular MVC parameters, ie:
        webapp.domain.com/account1/module/controller/action
        <http://webapp.domain.com/account1/module/controller/action>

        I define a default route replacement in my Bootstrap
        including the account parameter (see below) and retrieve this
        special parameter from a FrontController plugin where I setup
        the default database adapter.

        I encounter a problem with functions that build URLs (for
        instance $view->url(...) or $redirector->gotoRoute(...), etc.).
        All of these functions should add the current account
        parameter at the beginning of the URL, but none of them is
        aware of it.
        (It should also apply to other functions like
        $page->getHref() for Zend_Navigation.)

        What design option would you suggest (overload all of these
        functions, change dynamically the base URL of the application)?

        Thanks for any help
        - - - - -
        Here is the redefined default route:
               $route = new Zend_Controller_Router_Route(
                   ':account/:module/:controller/:action/*',
                   array(
                         'account'    => 'demo',
                         'module'     => 'default',
                         'controller' => 'index',
                         'action'     => 'index')
               );
               $router->addRoute('default', $route);

        I would also like to make
        "webapp.domain.com/account1/module/controller/action
        <http://webapp.domain.com/account1/module/controller/action>"
        equivalent to
        "account1.webapp.domain.com/module/controller/action
        <http://account1.webapp.domain.com/module/controller/action>". I
        guess it is possible with the
        Zend_Controller_Router_Route_Hostname, but did not try already.

        $route = new Zend_Controller_Router_Route_Hostname(
           ':account.webapp.domain.com
        <http://account.webapp.domain.com>',
           array(
               'module'     => 'default',
               'controller' => 'index',
               'action'     => 'index'
           )
        );
--
        Guillaume ORIOL



Reply via email to