This plugin implements the OAuth functionality for Symfony 1.4 using PECL OAuth extension.
What's OAuth? Please go to links below for best explanation I've ever seen so far.
- http://developer.yahoo.com/oauth/guide/about.html
- http://developer.yahoo.com/oauth/guide/oauth-auth-flow.html
- PHP 5.3.2+
- Pecl OAuth extension
- http://uk3.php.net/manual/en/book.oauth.php
- http://pecl.php.net/package/oauth
- sfDoctrineGuardPlugin - for now it doesn't work with Propel
So for it has been tested with:
Oauth 1.0:
- Vimeo
Oauth 2.0:
Please go to https://github.com/nixilla/Cacophony and download the Cacophony app. It uses sfCacophonyPlugin. It's a good example of how to use this plugin.
-
mkdir cacophony
-
cd cacophony/
-
mkdir -p lib/vendor
-
cd lib/vendor/
-
svn export http://svn.symfony-project.com/tags/RELEASE_1_4_14 symfony
-
cd ../..
-
php lib/vendor/symfony/data/bin/symfony generate:project cacophony
-
cd plugins/
-
svn export http://svn.symfony-project.com/plugins/sfDoctrineGuardPlugin/trunk/ sfDoctrineGuardPlugin
- svn export https://svn.github.com/nixilla/sfCacophonyPlugin.git sfCacophonyPlugin
- cd ../
- vim config/databases.yml
- vim config/ProjectConfiguration.class.php
- vim config/doctrine/schema.yml
- ./symfony doctrine:build --all
- ./symfony generate:app frontend
- vim web/frontend_dev.php
- vim apps/frontend/config/app.yml
- vim apps/frontend/config/settings.yml
- vim apps/frontend/config/filters.yml
- vim apps/frontend/lib/myUser.class.php
Lines 1 to 11 - we're setting up standard symfony application called cacophony with 2 plugins.
Line 12 - configure your database connection settings
Line 13 - enable 2 new plugins
$this->enablePlugins('sfDoctrinePlugin','sfDoctrineGuardPlugin','sfCacophonyPlugin');
Line 14 - modify sfGuardUser model to accept null for emails, as you won't get emails from some OAuth providers (optional)
sfGuardUser:
columns:
email_address:
type: string(255)
notnull: false
unique: true
Line 15 - build models forms and filters
Line 16 - create frontend app
Line 17 - remove security check from front controller (optional)
Line 18 - add your consumer_key and consumer secret (you must include the .settings: line)
all:
.settings:
cacophony:
providers:
vimeo:
consumer_key: YOUR_KEY
consumer_secret: YOUR_SECRET
twitter:
consumer_key: YOUR_ANOTHER_KEY
consumer_secret: YOUR_ANOTHER_SECRET
Line 19 - enable modules and add sfGuard config
enabled_modules: [default, sfGuardAuth, sfGuardRegister, sfCacophonyConsumer]
login_module: sfGuardAuth
login_action: signin
secure_module: sfGuardAuth
secure_action: secure
Line 20 - add filter
rendering: ~
security: ~
// insert your own filters here
callback_redirect:
class: sfCacophonyFilter
cache: ~
execution: ~
Line 21 - change base class for myUser to sfGuardSecurityUser
class myUser extends sfGuardSecurityUser
{
}
Then ./symfony cc and you're good to go
Navigate to http://your.url/frontend_dev.php/oauth/connect/(vimeo|twitter)
Accept your app on your provider's page
and check your database (sf_guard_user and token tables)
For more information please check out the wiki on Github.