PHPackages                             wp-kit/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. wp-kit/auth

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

wp-kit/auth
===========

A wp-kit component that handles authentication

2.0.2(6y ago)67.4kMITPHPPHP &gt;=7.2

Since Sep 18Pushed 6y ago1 watchersCompare

[ Source](https://github.com/wp-kit/auth)[ Packagist](https://packagist.org/packages/wp-kit/auth)[ Docs](https://github.com/wp-kit/auth)[ RSS](/packages/wp-kit-auth/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (3)Dependencies (9)Versions (4)Used By (0)

wp-kit/auth
===========

[](#wp-kitauth)

This is a wp-kit component that handles authentication.

`wp-kit/auth` was built to work with [`Themosis`](http://framework.themosis.com/) as currently there are no authentication middlewares built into `Themosis` however with [`illuminate/routing`](https://github.com/illuminate/routing) built into `Themosis`, we are able to run `Middleware` on `Routes` and `Route Groups`.

`wp-kit/auth` achives compatibility with [`illuminate/auth`](https://github.com/illuminate/auth) by providing a UserProvider that integrates directly with WordPress to authenticate users.

`wp-kit/auth` comes aliased with four types of `Middleware`:

- Authentication (Illuminate): [auth](https://github.com/illuminate/auth/blob/master/Middleware/Authenticate.php)
    - Token Guard (Illuminate): [auth:api](https://github.com/illuminate/auth/blob/master/TokenGuard.php)
    - Session Guard (Illuminate): [auth:web](https://github.com/illuminate/auth/blob/master/SessionGuard.php)
- Basic Authentication (Illuminate): [auth.basic](https://github.com/illuminate/auth/blob/master/Middleware/AuthenticateWithBasicAuth.php)
- Start Session (Illuminate): [start\_session](https://github.com/illuminate/session/blob/master/Middleware/StartSession.php)
- Guest Redirection (WP Kit): [guest](https://github.com/wp-kit/auth/blob/master/src/Auth/Middleware/RedirectIfAuthenticated.php)
- WP Login Authentication (WP Kit): [auth.wp\_login](https://github.com/wp-kit/auth/blob/master/src/Auth/Middleware/WpLoginAuth.php)

`wp-kit/auth` comes with a [`AuthenticatesUsers`](blob/master/src/Auth/Traits/AuthenticatesUsers.php) Trait just like [`wp-kit/foundation`](https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php) so you can use this trait inside [Controllers](https://github.com/laravel/laravel/blob/master/app/Http/Controllers/Auth/LoginController.php) so you can use traditional form authentication just like in Laravel.

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

[](#installation)

Install via [`Composer`](https://getcomposer.org/) in the root of your `Themosis` installation:

```
composer require "wp-kit/auth"
```

Setup
-----

[](#setup)

### Add Service Provider(s)

[](#add-service-providers)

Just register the service provider and facade in the providers config and theme config:

```
//inside theme/resources/config/providers.config.php

return [
    //
    WPKit\Auth\AuthServiceProvider::class
    //
];
```

### Add Config File

[](#add-config-file)

> **Note:** This will be changing to a traditional config file similar to that found in Laravel once the `UserProvider` Guard has been built

The recommended method of installing config files for `wp-kit` components is via `wp kit vendor:publish` command.

First, [install WP CLI](http://wp-cli.org/), and then install this component, `wp kit vendor:publish` will automatically be installed with `wp-kit/utils`, once installed you can run:

`wp kit vendor:publish`

For more information, please visit [`wp-kit/utils`](https://github.com/wp-kit/utils#commands).

Alternatively, you can place the [config file(s)](config) in your `theme/resources/config` directory manually.

### Allowing Headers

[](#allowing-headers)

If using [`BasicAuth`](https://github.com/wp-kit/auth/blob/master/src/Auth/Middleware/BasicAuth.php) middleware, make sure you add the following line to your `.htaccess` file to allow `Authorization` headers:

`RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]`

Usage
-----

[](#usage)

You can activate `Middleware` on the route group or route itself:

### Middleware on Group

[](#middleware-on-group)

```
// inside themosis-theme/resources/providers/RoutingService.php

namespace Theme\Providers;

use Themosis\Facades\Route;
use Themosis\Foundation\ServiceProvider;

class RoutingService extends ServiceProvider
{
    /**
     * Define theme routes namespace.
     */
    public function register()
    {
        Route::group([
	        'middleware' => [
			'start_session',
			'auth',
	        	//'auth.basic',
			//'auth.wp_login',
			//'auth.token'
		],
            	'namespace' => 'Theme\Controllers'
        ], function () {
        	require themosis_path('theme.resources').'routes.php';
        });
    }
}
```

### Middleware on Route

[](#middleware-on-route)

```
// inside themosis-theme/resources/routes.php

Route::get('home', function(Input $request)
{
    return view('welcome');

})->middleware('auth.wp_login');
```

### Using Traits in Controllers

[](#using-traits-in-controllers)

The `AuthenticatesUsers` trait handles everything for logging the user in using a custom form.

```
namespace Theme\Controllers;

use Themosis\Route\BaseController;
use WPKit\Auth\Traits\AuthenticatesUsers;
use WPKit\Auth\Traits\ValidatesRequests;

class LoginController extends Controller
{
    /*
    |--------------------------------------------------------------------------
    | Login Controller
    |--------------------------------------------------------------------------
    |
    | This controller handles authenticating users for the application and
    | redirecting them to your home screen. The controller uses a trait
    | to conveniently provide its functionality to your applications.
    |
    */
    use AuthenticatesUsers, ValidatesRequests;

    /**
     * Where to redirect users after login.
     *
     * @var string
     */
    protected $redirectTo = '/';

    /**
     * Create a new controller instance.
     *
     * @return void
     */
    public function __construct()
    {
        $this->middleware('guest')->except('logout');
    }

}
```

***Make sure you add routes:***

```
// an example in routes.php

Route::get('account', 'Example@showLoginForm');
Route::post('account', 'Example@login');
Route::get('logout', 'Example@logout');
```

***Make sure you add a login form view:***

```

	There was an error with field:

		Username

		Password

```

### Config

[](#config)

Please install and study the default [config file](config/auth.config.php) as described above to learn how to use this component.

Get Involved
------------

[](#get-involved)

To learn more about how to use `wp-kit` check out the docs:

[View the Docs](https://github.com/wp-kit/theme/tree/docs/README.md)

Any help is appreciated. The project is open-source and we encourage you to participate. You can contribute to the project in multiple ways by:

- Reporting a bug issue
- Suggesting features
- Sending a pull request with code fix or feature
- Following the project on [GitHub](https://github.com/wp-kit)
- Sharing the project around your community

For details about contributing to the framework, please check the [contribution guide](https://github.com/wp-kit/theme/tree/docs/Contributing.md).

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

[](#requirements)

Wordpress 4+

PHP 5.6+

License
-------

[](#license)

wp-kit/auth is open-sourced software licensed under the MIT License.

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

3

Last Release

2296d ago

PHP version history (2 changes)2.0.0PHP &gt;=5.6.4

2.0.2PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4cf98026bd84498477fafbfb9648807bf87c5ec9a0a404db2e3b7e2739cc8f9?d=identicon)[terence1990](/maintainers/terence1990)

---

Top Contributors

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

---

Tags

wordpressauthAuthenticationOOPthemosiswp-kit

### Embed Badge

![Health badge](/badges/wp-kit-auth/health.svg)

```
[![Health](https://phpackages.com/badges/wp-kit-auth/health.svg)](https://phpackages.com/packages/wp-kit-auth)
```

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[laragear/two-factor

On-premises 2FA Authentication for out-of-the-box.

339785.3k8](/packages/laragear-two-factor)[maicol07/flarum-ext-sso

SSO for Flarum

468.3k](/packages/maicol07-flarum-ext-sso)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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