I’m writing my own authentification library with PHP. I want to implement not only old-style Login/Pass authorization, but also OAuth and OpenID services (maybe others too) as drivers. These drivers will work with different data (tokens or simple array or any else), so I need to create separated tables for drivers + one main table for basic user information (ID, Screenname etc).
So, how do implement (or use existing) Auth libraries? I’m not asking for help with coding, just want to collect ideas, howtos and other best practices.
If I am understanding this correctly, you want to create a library that will support all of these at the same time? So User A can be logged in via OAuth and User B logged in via OpenID? And the library you are creating is to be used for providing simple “1 way calls”?
I implemented something like that (for short url drivers) in a simple framework for XenForo. I did it by creating a generic class with a function called “shorten($url, $method)” and dynamically checked to make sure that the method’s driver existed in the specified directory (XenForo has Zend Framework’s AutoLoading, so we utilize that) and build function calls. I then pass necessary information on (only $url) and let the driver fetch the information.
If you are storing all necessary information with the user, you could have an “extraData” database field with all necessary information for the specified “method” serialized or stored in a uniform manner that can be passed to the driver.
My co-developer and I chose to abstract it enough that we would be able to release it and any other developer could easily add & install new drivers for the framework. I can provide sample code if you’d like, but it includes several XenForo specific items. Speaking of which, I like the way it worked, and may implement it in a non-XenForo specific method.