Adding Social Authentication Plugin

2019-05-26 05:00:19+00

Instead of implementing an authentification we will use social authentication. This article described the implementation.

cd .../cakephp3
composer require admad/cakephp-social-auth
Using version ^0.3.2 for admad/cakephp-social-auth ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 4 installs, 0 updates, 0 removals - Installing paragonie/random_compat (v2.0.11): Downloading (100%) - Installing socialconnect/common (1.0.2): Downloading (100%) - Installing socialconnect/auth (1.8.0): Downloading (100%) - Installing admad/cakephp-social-auth (0.3.2): Downloading (100%) paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.) socialconnect/common suggests installing guzzlehttp/guzzle (Allows to use Http\Client\Guzzle, require guzzlehttp/guzzle:~5.3|~6.0.) Writing lock file Generating autoload files > Cake\Composer\Installer\PluginInstaller::postAutoloadDump

In the file config/bootstrap.php we need to load the plugin:

Plugin::load('ADmad/SocialAuth', ['bootstrap' => true, 'routes' => true]);

This plugin requires migration to generate a social_profiles table, and it can be generated via the official Migrations plugin as follows:

bin/cake migrations migrate -p ADmad/SocialAuth

Update src/Application.php

Tag: cakephp3

Previous Chapter: Designing a new start page with accelerated mobile pages (AMP)