imbo/imbo — pull request #289 by christeredvartsen (2014-04-09 06:06:23+00:00)
Title: Support an alternative way of specifying public / private keys

Today the public / private key pairs are stored as an array in the Imbo configuration file:

```php
return array(
'auth' => array(
'public' => 'private',
// 'anotheruser' => 'anotherkey',
// ...
),
);
```

Imbo should support an alternative way of storing this information in some backend. One solution would be to supply an interface that developers can implement and use:

```php
interface UserLookupInterface {
/**
* Get the private key of a public key
*
* @param string $publicKey The public key of the user
* @return null|string Returns the private key if the user exists, or null otherwise
*/
function getPrivateKey($publicKey);
}
```

Developers could implement this interface, and specify the implementation in the configuration instead of the array with keys. The interface might also extend the `Iterator` or `IteratorAggregate` interface so that the implementation can be used in a `foreach` loop for instance.

The configuration will then look something like this:

```php
return array(
'auth' => new MyUserLookup(),
// 'auth' => 'MyUserLookup',
// 'auth' => function() { return new MyUserLookup(); },
);
```

I'm not sure if all three configuration methods needs to be supported, but I included them for sake of consistency.

Could this be a useful addition?