Idea: Get db credentials from project config #44

Closed
barryvdh opened this Issue Jan 12, 2016 · 3 comments

Comments

Projects
None yet
2 participants
@barryvdh

It isn't recommended to put database credentials the git repository, so perhaps we should keep them out of the backup config also? And also, a lot of projects already have defined them anyways somewhere.

An option would be to provide some default project parsers, to load the configuration from the actual project.

Laravel -> Load database.php config file, or from .env directly.
Magento -> Parse local.xml file
Drupal -> Parse sites config file

Etc

@sebastianfeldmann

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Jan 12, 2016

Owner

Great idea.
Let's think of a good way to configure and implement this.

maybe something like

<credentials>
  <provider name="laravel-config" type="Laravel">
    <option name="path" value="path/to/laravel/config"/>
  </provider>
</credentials>

<backup>
   ...
   <source type="mysql" name="CoreDBBackup">
     <option name="credentials.provider" value="laravel-config" />
     <option name="credentials.toUse" valu="mysql" />
   </source>
  ...
</backup>

And inside the Mysql Source class.

if ($this->useCredentialProvider()) {
    $credentials = $this->getCredentials($options);
    $username = $credentials->username;
    $password = $credentials->password;
}

Great idea.
Let's think of a good way to configure and implement this.

maybe something like

<credentials>
  <provider name="laravel-config" type="Laravel">
    <option name="path" value="path/to/laravel/config"/>
  </provider>
</credentials>

<backup>
   ...
   <source type="mysql" name="CoreDBBackup">
     <option name="credentials.provider" value="laravel-config" />
     <option name="credentials.toUse" valu="mysql" />
   </source>
  ...
</backup>

And inside the Mysql Source class.

if ($this->useCredentialProvider()) {
    $credentials = $this->getCredentials($options);
    $username = $credentials->username;
    $password = $credentials->password;
}

@sebastianfeldmann sebastianfeldmann added this to the Version 3.1.0 milestone Jan 18, 2016

@sebastianfeldmann sebastianfeldmann removed this from the Version 3.1.0 milestone Feb 21, 2016

@sebastianfeldmann sebastianfeldmann self-assigned this Nov 15, 2016

@sebastianfeldmann

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Nov 16, 2016

Owner

Had to bump the major version for this but I think it was worth it.

<adapters>
  <adapter name="environment" type="dotenv">
    <option name="file" value=".env" />
  </adapter>
</adapters>

...
  <backup>
   ...
     <source type="mysql" name="CoreDBBackup">
       <option name="user" valu="adapter:environment:DB_USER" />
       <option name="password" value="adapter:environment:DB_PASSWORD" />
     </source>
     ...
  </backup>
...

I'll release version 4.0 as soon as possible.

Owner

sebastianfeldmann commented Nov 16, 2016

Had to bump the major version for this but I think it was worth it.

<adapters>
  <adapter name="environment" type="dotenv">
    <option name="file" value=".env" />
  </adapter>
</adapters>

...
  <backup>
   ...
     <source type="mysql" name="CoreDBBackup">
       <option name="user" valu="adapter:environment:DB_USER" />
       <option name="password" value="adapter:environment:DB_PASSWORD" />
     </source>
     ...
  </backup>
...

I'll release version 4.0 as soon as possible.

@sebastianfeldmann

This comment has been minimized.

Show comment
Hide comment
@sebastianfeldmann

sebastianfeldmann Nov 16, 2016

Owner

I decided to use adapters to manipulate the configuration values
before creating the actual configuration. So the application does
not have to know anything about configuration adapters.

But to actually create adapters while handling the configuration,
I had to change the configuration loader interface in a backwards
incompatible way. So I had to increase the major version.

I decided to use adapters to manipulate the configuration values
before creating the actual configuration. So the application does
not have to know anything about configuration adapters.

But to actually create adapters while handling the configuration,
I had to change the configuration loader interface in a backwards
incompatible way. So I had to increase the major version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment