ZF Oauth Provider
Posted by Stas on August 28, 2011
Zend Framework has pretty good OAuth consumer implementation. However, it has no support for implementing OAuth provider, and it turns out that there aren’t many other libraries for it. Most examples out there base on PECL oauth extension, which works just fine, with one caveat – you have to have this PECL extension installed, while ZF implementation does not require that.
So I went ahead and wrote some code that allows to easily add OAuth provider to your ZF-based or ZF-using application. That should make writing OAuth provider easier.
Note that the code does not implement the whole server – just the OAuth protocol wrapper, you’d still have to do all the work of managing tokens/keys/nonces by yourself. See example server in the repository and the wiki on github for more details on how to do it, but the protocol follows what PECL oauth does pretty closely, so many tutorials for it would be mostly applicable to this one too.
Check out Zend_Oauth_Provider on github, if you want to improve it – please fork and submit pull requests.
Joe Devon ® (@joedevon) said
Good work Stas. This was needed for some time. Glad you stepped in.
Smith said
Nice work ! You might want to try to use php 5.3 namespace and the Zend\Oauth from zf2 repository
PHPDeveloper.org: Stas Malyshev's Blog: ZF Oauth Provider said
[...] a new post Stas Malyshev has shared some code for an OAuth provider he's written up to work specifically with Zend Framework applications. Zend Framework has pretty [...]
Matthew Weier O'Phinney said
Any chance you’ll propose this for official inclusion in either ZF1 or ZF2? /me pokes…
Stas said
I thought I already did, some time ago…
I could write a formal proposal though.
Jan said
Can this also be used as a 2 legged oauth provider ?
Stas said
I do not see why not.
Warren said
Can you write a blog post explaining how to use Zend_Oauth_Provider? Documentation in wiki is quite limited. Hope this will be included in official ZF soon.
Stas said
Check out Rasmus’ tutorial here: http://toys.lerdorf.com/archives/55-Writing-an-OAuth-Provider-Service.html
It is based on PECL extension, but Zend_Oauth_Provider has similar API. Also, check out example server in the git repo.
Warren said
Can you provide some documentation for Zend_Oauth_Provider? The link you provided and your example server are not very clear. Thanks.
James said
Is this OAuth 2.0 or 1.0?
Stas said
Oauth 1.0.
James said
Do you know where i can get OAuth 2?