PHPackages                             sathomsen/cakephp-facebook-auth - 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. sathomsen/cakephp-facebook-auth

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

sathomsen/cakephp-facebook-auth
===============================

CakePHP plugin for authenticating via facebook tokens

v0.0.6(9y ago)036MITPHPPHP &gt;=5.5.9

Since Feb 15Pushed 9y ago2 watchersCompare

[ Source](https://github.com/SAThomsen/cakephp-facebook-auth)[ Packagist](https://packagist.org/packages/sathomsen/cakephp-facebook-auth)[ Docs](http://github.com/SAThomsen/cakephp-facebook-auth)[ RSS](/packages/sathomsen-cakephp-facebook-auth/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (0)

CakePHP Facebook Authentication plugin
======================================

[](#cakephp-facebook-authentication-plugin)

Intro
-----

[](#intro)

The plugin allows for easy authorization via facebook using the auth component of CakePHP. The plugin includes an AuthComponent authentication class as well as a facebook wrapper component. The facebook token is transmitted to the application via the authorization header.

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

[](#requirements)

- CakePHP 3.1+

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

[](#installation)

You can install this plugin into your CakePHP application using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require SAThomsen/FacebookAuth v0.0.2
```

\##Configuration

### Bootstrap

[](#bootstrap)

The plugin reads app details via the config/boostrap.php file in your application. Add the following lines to your bootstrap and fill in the details from your facebook app. The fields specify the information you are requesting from the graph. When generating the token frontend the same fields should be requested.

```
Configure::write('facebook.appId', 'REPLACE WITH APP ID');
Configure::write('facebook.appSecret', 'REPLACE WITH APP SECRET');
Configure::write('facebook.graphVersion', 'v2.8'); //The api version you intend to use.
Configure::write('facebook.fields', 'id,name,first_name,middle_name,last_name,gender,email');
```

To run the tests agains you're own facebook account, you will have to enter the account identifier in your bootstrap too:

```
Configure::write('facebook.identifier', 'REPLACE WITH FACEBOOK IDENTIFIER'));
```

You can also go declare environment variables using the .env file in the /tests/config. Alternatively, you declare them globally in you local environemnt. I have provided a template in /tests/config.

### Association:

[](#association)

In order for the authentication to work, an association should be added to the table representing a user. It defaults to "Users".

```
$this->hasMany('SocialProfiles', [
    'className' => 'SAThomsen/FacebookAuth.SocialProfiles',
    'foreignKey' => 'user_id',
    'dependent' => true,
]);
```

### Component config:

[](#component-config)

The component should be added to the authentication config of your AppController.

```
$this->loadComponent('Auth', [
    'authenticate' => [
        'SAThomsen/FacebookAuth.Facebook',
    ],
]);
```

The plugin works out of the box. Below is shown the available fields with their defaults:

```
// Specifies the username field of the finder
'fields' => [
    'username' => 'email'
],
// Specifies the finder method
'finder' => 'authFB',
// Specifies the header used to transfer token
'header' => 'authorization',
// specifies the identifying prefix used
'prefix' => 'facebook',
// specifies the query parameter to look for in the URL, will be ignored if empty
'parameter' => '',
// specifies the exeption to throw
'unauthenticatedException' => '\Cake\Network\Exception\UnauthorizedException',
// specifies where to find the finder method
'userModel' => 'SAThomsen/FacebookAuth.SocialProfiles',
```

If in doubt on how the configuration works, here is an example of how you would configure the field the finder looks for:

```
$this->loadComponent('Auth', [
    'authenticate' => [
        'SAThomsen/FacebookAuth.Facebook' => [
            'fields' => [
                'username' => 'username'
            ],
        ],
    ],
]);
```

### Load facebook component:

[](#load-facebook-component)

The facebook component can be loaded in controllers via the following line. This is useful when adding a new user, or linking an already existing user account with a social profile.

```
$this->loadComponent('SAThomsen/FacebookAuth.Facebook');
```

### Migrate

[](#migrate)

The database schema of SocialData can be imported via the migration file.

```
cake migrations migrate -p SAThomsen/FacebookAuth
```

Testing
-------

[](#testing)

To execute tests successfully make sure to be authenticated with the app that you wish to test against. Furthermore you should modify tests/bootstrap.php, with the credentials of your app and your own account.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Recently: every ~33 days

Total

6

Last Release

3288d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11570929?v=4)[Sebastian Aleksander Thomsen](/maintainers/sathomsen)[@SAThomsen](https://github.com/SAThomsen)

---

Top Contributors

[![SAThomsen](https://avatars.githubusercontent.com/u/11570929?v=4)](https://github.com/SAThomsen "SAThomsen (36 commits)")

---

Tags

authenticationcakephpcakephp-pluginfacebookstatelessfacebookAuthenticationcakephpauthenticate

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sathomsen-cakephp-facebook-auth/health.svg)

```
[![Health](https://phpackages.com/badges/sathomsen-cakephp-facebook-auth/health.svg)](https://phpackages.com/packages/sathomsen-cakephp-facebook-auth)
```

###  Alternatives

[cakedc/users

Users Plugin for CakePHP

523918.4k18](/packages/cakedc-users)[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

131237.3k13](/packages/dereuromark-cakephp-tinyauth)[admad/cakephp-jwt-auth

CakePHP plugin for authenticating using JSON Web Tokens

160717.9k8](/packages/admad-cakephp-jwt-auth)[cakedc/auth

Auth objects for CakePHP

31656.2k3](/packages/cakedc-auth)[xety/cake3-cookieauth

A simple Cake3 plugin to authenticate users with Cookies.

1856.1k2](/packages/xety-cake3-cookieauth)[bedita/manager

BEdita Manager - official admin webapp for BEdita4 API

131.1k](/packages/bedita-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
