2017 © Pedro Peláez
 

cakephp-plugin cakephp3_opauthlogin

Authentication plugin by Opauth for CakePHP 3.0.

image

ukatama/cakephp3_opauthlogin

Authentication plugin by Opauth for CakePHP 3.0.

  • Monday, October 13, 2014
  • by R3bm3v0N
  • Repository
  • 2 Watchers
  • 1 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Autentication with Opauth plugin for CakePHP 3.0

Requirements

  • CakePHP 3.0.0 or greater.
  • Opauth 0.4.3 or greater.
  • Opauth Strategies.

Installation

  • Install cakephp3_opauthlogin, Opauth and Opauth Strategies with composer.

Example:, (*1)

"require": {
    "php": ">=5.4.16",
    "mobiledetect/mobiledetectlib": "2.*",
    "cakephp/cakephp": "3.0.*-dev",

    "ukatama/cakephp3_opauthlogin": "*",
    "opauth/opauth": "*",
    "opauth/twitter": "*"
}
  • Load the plugin
Plugin::load('OpauthLogin', ['bootstrap' => false, 'routes' => true]);

Usage

  • Install the plugin., (*2)

  • Set up config/app.php., (*3)

$config = [
    /** Other Configurations **/

    'OpauthStrategy' => [
        'Twitter' => [
            'key' => '(Consumer Key)',
            'secret' => '(Consumer Secret)'
        ]
    ]
];
  • Create user table

"auth_provider" and "auth_uid" is required. (ToDo: Field names to be configuratable), (*4)

CREATE TABLE `users` (
  `id` varchar(45) NOT NULL,
  `name` varchar(45) NOT NULL,
  `auth_provider` varchar(45) NOT NULL,
  `auth_uid` int(11) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`)
);
  • Set up authentication compoonent and OpauthLogin helper., (*5)

    • Options
    • 'fields' (default: [ 'auth_provider' => 'auth_provider', 'auth_uid' => 'auth_uid' ]), (*6)

      Database table field's names., (*7)

    • 'registrationUrl' (default: null), (*8)

      Registration page's url redirected when authoriged user is not found. Set null to disable ridirecting., (*9)

class AppController  extends Controller {
    public $helpers = ['OpauthLogin.OpauthLogin'];

    public $components = [
        'Auth' => [
            'loginAction' => [
                'controller' => 'pages',
                'action' => 'login'
            ],
            'authenticate' => [
                'OpauthLogin.OpauthLogin' => [
                    'fields' => [
                        'auth_provider' => 'auth_provider',
                        'auth_uid' => 'auth_uid',
                    ],
                    'registrationUrl' => ['plugin' => null, 'controller' => 'users', 'action' => 'add']
                ]
            ]
        ]
    ];
  • Create login page.
<!-- Make login link as "Login with Twitter". -->
<?php echo $this->OpauthLogin->login(__('Login with Twitter'), 'twitter', ['class' => 'btn btn-default']); ?>
  • You can use as same as default auth component.

The Versions

13/10 2014

dev-master

9999999-dev https://github.com/ukatama/cakephp3_opauthlogin

Authentication plugin by Opauth for CakePHP 3.0.

  Sources   Download

MIT

The Development Requires

13/10 2014

v0.1alpha3

0.1.0.0-alpha3 https://github.com/ukatama/cakephp3_opauthlogin

Authentication plugin by Opauth for CakePHP 3.0.

  Sources   Download

MIT

The Development Requires

13/10 2014

v0.1alpha2

0.1.0.0-alpha2 https://github.com/ukatama/cakephp3_opauthlogin

Authentication plugin by Opauth for CakePHP 3.0.

  Sources   Download

MIT

The Development Requires

12/10 2014

v0.1alpha1

0.1.0.0-alpha1 https://github.com/ukatama/cakephp3_opauthlogin

Authentication plugin by Opauth for CakePHP 3.0.

  Sources   Download

MIT

The Development Requires