PHPackages                             pkj/minibase-plugin-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. pkj/minibase-plugin-auth

ActiveLibrary

pkj/minibase-plugin-auth
========================

The auth plugin implements authentication for your app.

16PHP

Since May 11Pushed 13y ago1 watchersCompare

[ Source](https://github.com/peec/minibase-plugin-auth)[ Packagist](https://packagist.org/packages/pkj/minibase-plugin-auth)[ RSS](/packages/pkj-minibase-plugin-auth/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Auth for Minibase
=================

[](#auth-for-minibase)

Auth is a big and customizable plugin for [Minibase](https://github.com/peec/minibase) framework. It's for PHP 5.4+. If you need authentication for you app look no further. This plugin is cuztomizable, such as the [View customzation](docs/customize_views.md).

Supported authentication mechanisms:
------------------------------------

[](#supported-authentication-mechanisms)

- Normal email/password auth.
- Facebook Oauth login.
- API Authentication (for your resful apis)

Plugin requirements
-------------------

[](#plugin-requirements)

This plugin requires some plugins to be installed. The most important plugin is twig, the twig plugin overrides the default php view handeling of minibase.

- [Doctrine plugin](https://github.com/peec/minibase-plugin-doctrine): ORM
- [Twig plugin](https://github.com/peec/minibase-plugin-twig): Templating engine.
- [Csrf plugin](https://github.com/peec/minibase-plugin-csrfprotection): For security

Install
-------

[](#install)

This plugin must be initialized before Doctrine/Twig plugin.

### Sample integration with JSON:

[](#sample-integration-with-json)

Add the plugins like so in your `app.json` file.

```
	"plugins": [
		{
			"name": "Pkj/Minibase/Plugin/AuthPlugin/AuthPlugin",
			"config": {
				"providers": {
					"facebook": {
						"appId": "APP_ID",
						"secret": "FACEBOOK_SECRET_KEY"
					}
				},
				"api": {
					"ensure_token": true,
					"expire_timeout": "+100 days"
				}
			}
		},
		{
			"name": "Pkj/Minibase/Plugin/TwigPlugin/TwigPlugin",
			"config": {

			}
		},
		{
			"name":"Pkj/Minibase/Plugin/Csrf/CsrfPlugin"
		},
		{
			"name": "Pkj/Minibase/Plugin/DoctrinePlugin/DoctrinePlugin",
			"config": {
				"metadata": "annotation",
				"entityDirs": ["${APP_DIR}/models/"],
				"proxyDir": "${APP_DIR}/cache/proxies",
				"connection": {
					"driver": "pdo_sqlite",
					"path": "${APP_DIR}/cache/db.sqlite"
				}
			}
		}
	]
```

### Update your database schema.

[](#update-your-database-schema)

This plugin introduces some new database tables (for users).

Note, if you already have doctrine models in your app use `orm:schema-tool:update --dump-sql` and import it in your current database.

```
php cli.php orm:schema-tool:create
```

### The routes

[](#the-routes)

#### /login

[](#login)

View used in `AuthPlugin/login.html`, override this in your view folder to add your own login html code.

#### /register

[](#register)

Gives users the possiblity to register.

#### /user/settings

[](#usersettings)

The control panel for the users settings. The user may change his password from this url.

Secure your controller methods.
-------------------------------

[](#secure-your-controller-methods)

This plugin introduces new annotations that you can put on your controllers or controller methods.

`use Pkj\Minibase\Plugin\AuthPlugin\Annotation as Restrict;`

#### @Restrict\\Authenticated

[](#restrictauthenticated)

The user must be authenticated, if not the view `AuthPlugin/must_authenticate.html` is displayed.

#### @Restrict\\NotAuthenticated

[](#restrictnotauthenticated)

The user must NOT be authenticated, if this fails the view `AuthPlugin/must_not_authenticate.html` is displayed.

#### @Restrict\\UserGroups(groups={"admin"})

[](#restrictusergroupsgroupsadmin)

You can restrict any controller or method to only some user groups.

#### Annotation parameters

[](#annotation-parameters)

The `redirect` parameter (eg. `@Restrict\Authenticate(redirect="MyController.heyloginnowplease")` will redirect the user instead of showing the `AuthPlugin/must_authenticate.html`.

API Authentication
------------------

[](#api-authentication)

This plugin aquires some other routes, such as `/api/login` . These calls expects a raw JSON request. the `/api/login` entry point gives you some data back if the posted json was correct, ie. `{"username": "myuser", "password": "mypass"}`. You will get a `authToken` back, this key can be used to authenticate further when needed. You just need to add `?auth_token=KEY` to the URL and you will get access depending on the annotations that was assigned to the entry point.

Events
------

[](#events)

#### auth:register:before (Pkj\\Minibase\\Plugin\\AuthPlugin\\Models\\UserAccount $user)

[](#authregisterbefore-pkjminibasepluginauthpluginmodelsuseraccount-user)

Fires just before the user is persisted to the database. Useful for custom validation of both username and your own fields. Throw `\Exception` if you want not to persist the user to the database.

#### auth:register:after (Pkj\\Minibase\\Plugin\\AuthPlugin\\Models\\UserAccount $user)

[](#authregisterafter-pkjminibasepluginauthpluginmodelsuseraccount-user)

Fires on registration (not provider registration). Allows you to add custom fields to your database when a user is registered.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/88b748fa2f0dcacab307a6305e98032de7adb93f955bbaf3c6fe029a7369ac84?d=identicon)[peec](/maintainers/peec)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/pkj-minibase-plugin-auth/health.svg)

```
[![Health](https://phpackages.com/badges/pkj-minibase-plugin-auth/health.svg)](https://phpackages.com/packages/pkj-minibase-plugin-auth)
```

PHPackages © 2026

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