PHPackages                             mattyg/fb-privacy-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. mattyg/fb-privacy-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

mattyg/fb-privacy-auth
======================

Implement authorisation checks based on the model Facebook uses for privacy controls for content (simple users and groups system).

1.0.1(10y ago)121UnlicensePHPPHP ~5.6.0|~7.0.0

Since Jan 16Pushed 10y ago1 watchersCompare

[ Source](https://github.com/djmattyg007/fb-privacy-auth)[ Packagist](https://packagist.org/packages/mattyg/fb-privacy-auth)[ Docs](https://github.com/djmattyg007/fb-privacy-auth)[ RSS](/packages/mattyg-fb-privacy-auth/feed)WikiDiscussions master Synced 1mo ago

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

```
FB Privacy Auth

This library lets you implement an authorization system in your application
using the same style that Facebook uses for content. Each resource has a
defined list of users and groups that are allowed access to the resource, and
a defined list of users and groups that are not allowed access to the resource.

To use the library, construct an instance of \MattyG\FBPrivacyAuth\AuthChecker,
passing it two arrays. The first is an array where the keys are the identifiers
of each group, and the values are arrays of usernames that are part of each
group. The second is an array where the keys are the identifiers of each
resource, and the values are an array that describes who is allowed access to
each resource. You can see an example of the expected structure in the
"resources.json" file in the tests folder.

When you want to test whether or not a particular user has access to a
particular resource, call the check() function, passing it the identifier of
the given resource, and the username in question. It will then perform the
following checks, in this order:

1. Is this user specifically denied from accessing this resource? If so, DENY.
2. Is this user specifically allowed to access this resource? If so, ALLOW.
3. Is this user a member of a group that is specifically denied from accessing
   this resource? If so, DENY.
4. Is this user a member of a group that is specifically allowed to access
   this resource? If so, ALLOW.
If the user does not match any of the above rules, DENY.

As you can see, the above logic means your application will default towards
being more secure rather than less secure. It is better for a user to be
accidentally locked out of a system than it is to accidentally allow an
unwanted visitor access to the system.

The AuthChecker class also provides a convenient method for retrieving the
identifiers of all resources that a particular user has access to. It does this
by iterating over all resources and checking them one by one with the above
logic. To utilise this, call the getAllowedResourceIds() method and pass it
a username.

Why should you use this, instead of much more established and well-known
solutions such as the Zend Acl or Symfony Security packages? Simplicity. Before
I built this, I evaluated these and a few other potential solutions. I decided
to build my own because of all the things I didn't want out of an authorization
system:

- My resources are not hierarchial, nor are they tied to HTTP routes
- My authentication is already handled elsewhere
- My users have no behaviours or properties associated with them and therefore
  are not objects
- My configuration is in JSON, not YAML
- My priority is speed, not flexibility

I was unable to find an existing solution that fit all of these criteria before
building this.

This software is released into the public domain without any warranty.
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~2 days

Total

2

Last Release

3764d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/29e8622a72b856256e1b0f9e5ba9480444c6391e6e80a48eeb52fc4118eacf06?d=identicon)[djmattyg007](/maintainers/djmattyg007)

---

Top Contributors

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

---

Tags

authauthorizationaclauthorisationgroupsUsersprivacy

### Embed Badge

![Health badge](/badges/mattyg-fb-privacy-auth/health.svg)

```
[![Health](https://phpackages.com/badges/mattyg-fb-privacy-auth/health.svg)](https://phpackages.com/packages/mattyg-fb-privacy-auth)
```

###  Alternatives

[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M247](/packages/league-oauth2-server)[arcanedev/laravel-auth

Laravel Authorization package.

294.8k1](/packages/arcanedev-laravel-auth)[awes-io/auth

Laravel Authentication package with built-in two-factor (Authy) and social authentication (Socialite).

3826.7k1](/packages/awes-io-auth)[saeven/zf3-circlical-user

Complete user entity, rights, and access module for Laminas

3718.7k](/packages/saeven-zf3-circlical-user)[chervand/yii2-oauth2-server

OAuth 2.0 server for Yii 2.0 with MAC tokens support.

1524.2k1](/packages/chervand-yii2-oauth2-server)

PHPackages © 2026

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