PHPackages                             ukatama/cakephp3\_opauthlogin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ukatama/cakephp3\_opauthlogin

AbandonedArchivedCakephp-plugin[Authentication &amp; Authorization](/categories/authentication)

ukatama/cakephp3\_opauthlogin
=============================

Authentication plugin by Opauth for CakePHP 3.0.

v0.1alpha3(11y ago)115MITPHPCI failing

Since Oct 12Pushed 11y ago2 watchersCompare

[ Source](https://github.com/ukatama/cakephp3_opauthlogin)[ Packagist](https://packagist.org/packages/ukatama/cakephp3_opauthlogin)[ Docs](https://github.com/ukatama/cakephp3_opauthlogin)[ RSS](/packages/ukatama-cakephp3-opauthlogin/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (4)Used By (0)

Autentication with Opauth plugin for CakePHP 3.0
================================================

[](#autentication-with-opauth-plugin-for-cakephp-30)

Requirements
------------

[](#requirements)

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

Installation
------------

[](#installation)

- Install cakephp3\_opauthlogin, Opauth and Opauth Strategies with composer.

Example:

```
"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
-----

[](#usage)

- Install the plugin.
- Set up config/app.php.

```
$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)

```
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.
    - Options
        - 'fields' (default: \[ 'auth\_provider' =&gt; 'auth\_provider', 'auth\_uid' =&gt; 'auth\_uid' \])

            Database table field's names.
        - 'registrationUrl' (default: null)

            Registration page's url redirected when authoriged user is not found. Set null to disable ridirecting.

```
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.

```
