PHPackages                             tihloh/prefab-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. tihloh/prefab-auth

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

tihloh/prefab-auth
==================

Standalone, framework-independent authentication building blocks for Prefab PHP.

v0.1.0(yesterday)01↑2900%MITPHPPHP &gt;=8.1

Since Aug 23Pushed yesterdayCompare

[ Source](https://github.com/tihloh/prefab-auth)[ Packagist](https://packagist.org/packages/tihloh/prefab-auth)[ Docs](https://github.com/tihloh/prefab-php)[ RSS](/packages/tihloh-prefab-auth/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Tihloh Prefab Auth
==================

[](#tihloh-prefab-auth)

Framework-independent authentication for PHP applications.

Responsibilities
----------------

[](#responsibilities)

- password login/logout
- current authenticated user/session lookup
- custom user-provider integration
- complete social sign-in flow
- social account linking/unlinking
- OAuth state validation
- password reset/social-account storage schema
- structured log payloads for auth operations
- optional Bootstrap UI recipes

Auth does not own the project user table. Any user model can integrate by implementing `AuthenticatableUserInterface` and being exposed through `AuthUserProviderInterface`.

Standalone password example
---------------------------

[](#standalone-password-example)

```
use Tihloh\Prefab\Auth\Services\AuthManager;
use Tihloh\Prefab\Auth\Session\NativeSessionStore;

$auth = new AuthManager($userProvider, new NativeSessionStore());

$result = $auth->attempt($_POST['identifier'], $_POST['password'], [
    'ip_address' => $_SERVER['REMOTE_ADDR'] ?? null,
    'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? null,
]);

if ($result->success) {
    $logs?->record($result->log);
}
```

Current-user API
----------------

[](#current-user-api)

```
$auth->check();
$auth->id();
$auth->user();
$auth->logout();
```

Social sign-in
--------------

[](#social-sign-in)

Register one or more providers in `SocialProviderRegistry`. A provider may be implemented directly or wrapped through `CallbackSocialProvider`, allowing Laravel Socialite, league/oauth2-client, or another OAuth/OIDC SDK to be used without coupling Prefab Auth to that library.

```
$registry->register($googleProvider);
$registry->register($githubProvider);

$social = new SocialAuthManager(
    $registry,
    new PdoSocialAccountStore($pdo),
    new NativeSessionSocialStateStore(),
    $userProvider,
    $socialUserResolver,
    $auth,
);
```

Start sign-in:

```
header('Location: ' . $social->authorizationUrl('google'));
exit;
```

Handle callback:

```
$result = $social->callback('google', $_GET, [
    'ip_address' => $_SERVER['REMOTE_ADDR'] ?? null,
    'user_agent' => $_SERVER['HTTP_USER_AGENT'] ?? null,
]);

if ($result->success) {
    $logs?->record($result->log);
}
```

`SocialUserResolverInterface` controls what happens when a social account is not linked yet. The host project may find an existing user by verified email, create a new user, require registration, or reject the sign-in.

Management data is available through:

```
$social->providers();
$social->accountsForUser($userId);
$social->unlink($userId, 'google');
```

UI recipes
----------

[](#ui-recipes)

Copy and customize files under `examples/bootstrap/`. They are examples only and are never rendered automatically by the Auth prefab.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

1d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ec00222b22ba37eb69aff9973c5303fe5773cb4c7016bf0e7aae09fe9edb232?d=identicon)[tihloh](/maintainers/tihloh)

---

Top Contributors

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

---

Tags

phpauthAuthenticationoauthmodularprefabframework-independent

### Embed Badge

![Health badge](/badges/tihloh-prefab-auth/health.svg)

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

###  Alternatives

[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

41022.5M98](/packages/auth0-auth0-php)[auth0/login

Auth0 Laravel SDK. Straight-forward and tested methods for implementing authentication, and accessing Auth0's Management API endpoints.

2745.4M3](/packages/auth0-login)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

121269.8k1](/packages/ellaisys-aws-cognito)[maicol07/flarum-ext-sso

SSO for Flarum

468.8k](/packages/maicol07-flarum-ext-sso)[andalisolutions/oauth2-anaf

Anaf OAuth 2.0 support for the PHP League's OAuth 2.0 Client

197.3k](/packages/andalisolutions-oauth2-anaf)

PHPackages © 2026

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