[eluser]davidbehler[/eluser]
Yesterday I had a brief look at the Zend auth library and I actually liked what I saw. To be more specific I liked the idea of having multiple adapters, all using the same interface that allows for easy switch from one adapter to the other.
Before I actually start working on this library I would like to know what you guys think about this kind of approach:
The library itself would be rather simply, having only the constructor, an init method, and a method for each function we might need like login, logout, check_permission.
Depending on an entry in the config array, let's say $config['adapter'], the init function would include the file of the adapater located in a sub-folder of the library folder (e.g. libraries/auth/database_adapter.php) and instantiate the adapter as $this->adapter.
Now all the functions like login, logout and so on would not process the data themselfs, but rather call the correspondent method in the adapater, e.g.
Code:
$this->adapter->login();
That would allow us to easily add new adapters or change existing ones without having to edit the auth library itself.
Possible adapters:
- Memory: Checks for an identifier/password combination that's set in the config file
- Database: Checks a specified table for an identifier/password combination
- oAuth
- OpenId
- Facebook
We might even define an interface that has to be used by all adapters, but we will have to see into that again later.
So tell me, what do you think? Good idea? Sucks?
I'm looking forward to your comments!
waldmeister