Protected DB connexion

Discussion relating to version 1.3.x and 1.4.x

Protected DB connexion

Postby Domyck » Tue Jun 26, 2012 3:48 pm

After the validation of the connexion form, Symfony knows the user, then the profile (ADM or STD) and set the credentials :
Code: Select all
   if ($prof=='ADM') $this->getUser()->addCredential('ADM');
   elseif ($prof=='STD') $this->getUser()->addCredential('STD');


Is it useful, for security reasons, to connect to the database with login/password acoording to the profile.
In this view, I have defined two connexions in the database.yml file :
Code: Select all
all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'pgsql:host=localhost;dbname=geodatabase'
      username: standuse
      password: ****

  doctrine_adm:
    class: sfDoctrineDatabase
    param:
      dsn: 'pgsql:host=localhost;dbname=geodatabase'
      username: admuse
      password: ****


But, how to use these possibilities :
- in a Doctrine query ?
Code: Select all
   if ($this->getUser()->hasCredential('ADM'))    $q = Doctrine_Query::create()->from('Produit');// ...??? doctrine_adm connexion
   elseif ($this->getUser()->hasCredential('STD')) $q = Doctrine_Query::create()->from('Produit');// ...??? doctrine connexion
   $prods = $q->execute();

- in a view generated with the generator.yml ?
With many thanks
Domyck
Junior Member
 
Posts: 14
Joined: Tue Dec 01, 2009 9:52 am
Location: Grenoble

Return to symfony 1.3 and 1.4

Who is online

Users browsing this forum: No registered users and 5 guests