Git Product home page Git Product logo

sfcacophonyplugin's Introduction

sfCacophonyPlugin

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.

Requirements

So for it has been tested with:

Oauth 1.0:

  • Vimeo
  • Twitter

Oauth 2.0:

  • Facebook
  • Instagram

A Sample application

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.

New application example

Steps

  1. mkdir cacophony
    
  2. cd cacophony/
    
  3. mkdir -p lib/vendor
    
  4. cd lib/vendor/
    
  5. svn export http://svn.symfony-project.com/tags/RELEASE_1_4_14 symfony
    
  6. cd ../..
    
  7. php lib/vendor/symfony/data/bin/symfony generate:project cacophony
    
  8. cd plugins/
    
  9. svn export http://svn.symfony-project.com/plugins/sfDoctrineGuardPlugin/trunk/ sfDoctrineGuardPlugin
    
  10. svn export https://svn.github.com/nixilla/sfCacophonyPlugin.git sfCacophonyPlugin
  11. cd ../
  12. vim config/databases.yml
  13. vim config/ProjectConfiguration.class.php
  14. vim config/doctrine/schema.yml
  15. ./symfony doctrine:build --all
  16. ./symfony generate:app frontend
  17. vim web/frontend_dev.php
  18. vim apps/frontend/config/app.yml
  19. vim apps/frontend/config/settings.yml
  20. vim apps/frontend/config/filters.yml
  21. vim apps/frontend/lib/myUser.class.php

Explanation

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.

sfcacophonyplugin's People

Contributors

nixilla avatar angelsk avatar jimmywong avatar

Stargazers

Anton avatar  avatar  avatar  avatar  avatar Ben Lancaster avatar Tristan Bessoussa avatar Benjamin VIELLARD avatar

Watchers

 avatar James Cloos avatar

Forkers

hollerlondon

sfcacophonyplugin's Issues

Drop sfDoctrineGuardPlugin dependency

This plugin should be only for OAuth authentication, therefore I'm going to drop sfDoctrineGuardPlugin dependency. This will allow to use this plugin with Propel or without database at all. Any comments?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.