Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
multi-tenancy using MySQL
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Christopher Brind  
View profile  
 More options Jun 8 2011, 5:58 am
From: Christopher Brind <bri...@brindy.org.uk>
Date: Wed, 8 Jun 2011 10:58:33 +0100
Local: Wed, Jun 8 2011 5:58 am
Subject: multi-tenancy using MySQL

Hi all,

Just wondering if anyone out there has used Doctrine in a multi-tenancy
application?  That is, you have a single MySQL database, but many users and
want to isolate the user data in a (programmer and injection) safe way.

How have you achieved it and did Doctrine play a big role in facilitating
this (other than just being an ORM)?

Thanks in advance,
Cheers,
Chris


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Pivetta  
View profile   Translate to Translated (View Original)
 More options Jun 8 2011, 6:17 am
From: Marco Pivetta <ocram...@gmail.com>
Date: Wed, 8 Jun 2011 12:17:01 +0200
Local: Wed, Jun 8 2011 6:17 am
Subject: Re: [doctrine-user] multi-tenancy using MySQL

In an app I'm developing I use an RBAC structure based on roles strictly
connected to specific accessible records, and Doctrine 2 made almost all the
job.
The problem is that I had to rewrite all my customRepositories and avoid any
access to base functionalities of repositories, like findBy and similar
methods ($em->find($entity, $id) can't be used in my app, or at least ist
strongly discouraged!).
It's not completely safe, but I build up all my queries joining with ACL
tables.
Another solution I didn't test is using AST and hints, but I had to run
while I was in the first stages of development, and avoided this kind of
approach...

Here's some example of a custom repository:*
<?php
namespace Deneb\EntityRepository;

/**
 *
 * @author Ocramius
 */
class Location extends \Deneb\AuthConstrainedRepository {

    public function createConstrainedQueryBuilder() {
        $qb = parent::createConstrainedQueryBuilder();
        if($this->_auth->hasIdentity()) {
            $identity = $this->_auth->getIdentity();
            if($identity instanceof \Deneb\Entity\User\Referrer) {
                $customerAlias = \uniqid('cu');
                $companyAlias = \uniqid('c');
                $companyParamAlias = \uniqid('cp');
                $qb
                    ->join($qb->getRootAlias() . '.customer',
$customerAlias)
                    ->join(
                        $customerAlias . '.company',
                        $companyAlias,
                        \Doctrine\ORM\Query\Expr\Join::WITH,
                        $qb->expr()->eq($companyAlias, ':' .
$companyParamAlias)
                    )
                    ->setParameter(
                        $companyParamAlias,
                        $identity->company
                    );
            }else if($identity instanceof \Deneb\Entity\User\Supplier) {
                $qb->where('1 = 0');
                /**
                 * @todo rules for suppliers
                 */
            }
        }
        return $qb;
    }

}*

Not really a masterpiece, but it does the work and I just use the
QueryBuilder it provides me being careful not to replace existing
parameters. That makes stuff so much easier!

Marco Pivetta
http://twitter.com/Ocramius
http://marco-pivetta.com

On 8 June 2011 11:58, Christopher Brind <bri...@brindy.org.uk> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benjamin Eberlei  
View profile  
 More options Jun 8 2011, 7:57 am
From: Benjamin Eberlei <kont...@beberlei.de>
Date: Wed, 08 Jun 2011 13:57:06 +0200
Local: Wed, Jun 8 2011 7:57 am
Subject: Re: [doctrine-user] multi-tenancy using MySQL
 but this doesnt help with protecting associations.

 On Wed, 8 Jun 2011 12:17:01 +0200, Marco Pivetta wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Marco Pivetta  
View profile  
 More options Jun 8 2011, 7:59 am
From: Marco Pivetta <ocram...@gmail.com>
Date: Wed, 8 Jun 2011 13:59:01 +0200
Local: Wed, Jun 8 2011 7:59 am
Subject: Re: [doctrine-user] multi-tenancy using MySQL

Yep, I know...  But I'm too far forward right now to switch back to another
technique :(

Marco Pivetta
http://twitter.com/Ocramius
http://marco-pivetta.com

On 8 June 2011 13:57, Benjamin Eberlei <kont...@beberlei.de> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »