Download the PHP package admad/cakephp-social-auth without Composer

On this page you can find all versions of the php package admad/cakephp-social-auth. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cakephp-social-auth

CakePHP SocialAuth Plugin

Total Downloads

A CakePHP plugin which allows you authenticate using social providers like Facebook/Google/Twitter etc. using SocialConnect/auth social sign on library.

Installation

Run:

Setup

Load the plugin by running following command in terminal:

Database

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

Usage

Middleware config

The plugin provides a \ADmad\SocialAuth\Middleware\SocialAuthMiddleware which handles authentication process through social providers.

You can configure the middleware in your Application::middleware() method as shown:

Login links

On your login page you can create links to initiate authentication using required providers. E.g.

We use a POST link here instead of a normal link to prevent search bots and other crawlers from following the link. If you prefer using GET you can still do so by configuring the middleware with 'requestMethod' => 'GET'. In this case it's advisable to add nofollow attribute to the link.

Authentication process

Depending on the provider name in the login URL the authentication process is initiated.

Once a user is authenticated through the provider, the middleware gets the user profile from the identity provider and using that tries to find the corresponding user record using the user model. If no user is found it calls the getUser method of your user model. The method recieves social profile model entity and session instance as argument and must return an entity for the user.

Instead of adding a getUser method to your UsersTable you can also setup a listener for the SocialAuth.createUser callback and return a User entity from the listener callback, in a similar way as shown above.

Upon successful authentication the user identity is persisted to the session under the key you have specified in the middleware config (Auth.User by default).

After that the user is redirected to protected page they tried to access before login or to the URL specified in loginRedirect config.

In case of authentication failure the user is redirected back to login URL.

Events

SocialAuth.createUser

After authentication from the social auth provider if a related use record is not found then SocialAuth.createUser is triggered. As an alternative to adding a new createUser() method in your UsersTable as mentioned above you can instead use this event to return an entity for a new user.

SocialAuth.afterIdentify

Upon successful authentication a SocialAuth.afterIdentify event is dispatched with the user entity. You can setup a listener for this event to perform required tasks. The listener can optionally return a user entity as event result.

SocialAuth.beforeRedirect

After the completion of authentication process before the user is redirected to required URL a SocialAuth.beforeRedirect event is triggered. This event for e.g. can be used to set a visual notification like flash message to indicate the result of the authentication process to the user.

Here's an e.g. listener with callbacks to the above method:

Attach the listener in your Application class:

Extend with custom providers

In order to enable custom providers (those not pre-included with SocialConnect/Auth) you can extend the middleware configuration with collectionFactory and passing in your own instance of SocialConnect\Auth\CollectionFactory.

For e.g. create your custom provider at src/Authenticator/MyProvider.php. Check the providers in vendor/socialconnect/auth/src/(OAuth1|OAuth2|OpenIDConnect)/Provider/ for examples.

Create an instance of CollectionFactory.

Then set the factory instance in the middlware config shown above:

Copyright

Copyright 2017-Present ADmad

License

See LICENSE


All versions of cakephp-social-auth with dependencies

PHP Build Version
Package Version
Requires cakephp/cakephp Version ^5.0
socialconnect/auth Version ^3.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package admad/cakephp-social-auth contains the following files

Loading the files please wait ....