PHPackages                             bevi-webdev-jm/hub-auth-client - 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. bevi-webdev-jm/hub-auth-client

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

bevi-webdev-jm/hub-auth-client
==============================

SSO client package for connecting Laravel apps to the centralized Hub via OAuth2

v1.0.0(1mo ago)05MITPHPPHP ^8.0

Since Jun 4Pushed 1mo agoCompare

[ Source](https://github.com/bevi-webdev-jm/hub-auth-client)[ Packagist](https://packagist.org/packages/bevi-webdev-jm/hub-auth-client)[ RSS](/packages/bevi-webdev-jm-hub-auth-client/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (6)Versions (2)Used By (0)

Hub Auth Client
===============

[](#hub-auth-client)

A Laravel package that provides Single Sign-On (SSO) integration for Laravel applications via OAuth2, connecting them to a centralized Hub authentication server.

Overview
--------

[](#overview)

This package handles the complete OAuth2 flow between your Laravel application and the Hub, including user synchronization, account linking by email, and automatic user provisioning on first login.

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

[](#requirements)

- PHP 8.0+
- Laravel 8.0–12.0
- Laravel Socialite 5.0+

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

[](#installation)

```
composer require bevi-webdev-jm/hub-auth-client
```

The package auto-registers its service provider via Laravel's package discovery.

Setup
-----

[](#setup)

### 1. Publish the configuration

[](#1-publish-the-configuration)

```
php artisan vendor:publish --tag=hub-auth-config
```

### 2. Add environment variables

[](#2-add-environment-variables)

```
HUB_URL=https://hub.yourdomain.com
HUB_CLIENT_ID=your-client-id
HUB_CLIENT_SECRET=your-client-secret
HUB_REDIRECT_URI=https://yourapp.com/login/hub/callback
HUB_DEFAULT_ROLE=default_user
```

### 3. Add `hub_user_id` to your users table

[](#3-add-hub_user_id-to-your-users-table)

```
Schema::table('users', function (Blueprint $table) {
    $table->string('hub_user_id')->nullable()->unique();
});
```

### 4. Add `hub_user_id` to your User model's `$fillable` array

[](#4-add-hub_user_id-to-your-user-models-fillable-array)

```
protected $fillable = [
    'name',
    'email',
    'hub_user_id',
    // ...
];
```

### 5. Add a login link to your template

[](#5-add-a-login-link-to-your-template)

```
Login with Hub
```

Configuration
-------------

[](#configuration)

All options are in `config/hub-auth.php`:

KeyENV VariableDefaultDescription`hub_url``HUB_URL``http://localhost:8000`Base URL of the Hub server`client_id``HUB_CLIENT_ID`—OAuth2 client ID issued by Hub`client_secret``HUB_CLIENT_SECRET`—OAuth2 client secret issued by Hub`redirect``HUB_REDIRECT_URI`—Full callback URL of your application`default_role``HUB_DEFAULT_ROLE``default_user`Role assigned to new users (requires Spatie Permission)`redirect_after_login`—`/home`Where to redirect after successful loginAuthentication Flow
-------------------

[](#authentication-flow)

1. User visits `/login/hub` → redirected to Hub's OAuth2 authorization page
2. User authenticates at Hub
3. Hub redirects back to `/login/hub/callback` with an authorization code
4. Package exchanges the code for a token and fetches the user from Hub's `/api/me`
5. Local user is resolved (created, linked, or retrieved — see below)
6. User is logged into the Laravel session and redirected to `redirect_after_login`

User Resolution
---------------

[](#user-resolution)

The `DefaultHubUserResolver` handles three scenarios on every login:

- **Existing Hub user** — looks up by `hub_user_id`, returns the local user as-is
- **Email match** — links the existing local account to the Hub by setting `hub_user_id`
- **New user** — creates a local account from Hub data with a null password

### Username generation

[](#username-generation)

If your User model has `username` in its `$fillable` array, a username is derived from the email prefix and made unique by appending a counter on collision (e.g., `alice`, `alice1`, `alice2`).

### Role assignment

[](#role-assignment)

If [Spatie Laravel-Permission](https://github.com/spatie/laravel-permission) is installed and the User model uses the `HasRoles` trait, new users are assigned the `HUB_DEFAULT_ROLE` on creation. The role must exist in the database. Role assignment is skipped (with a debug log) if the package or role is not found.

Registered Routes
-----------------

[](#registered-routes)

MethodURINameActionGET`/login/hub``hub.login`Redirect to Hub OAuthGET`/login/hub/callback``hub.callback`Handle Hub callbackCustom User Resolution
----------------------

[](#custom-user-resolution)

To override how Hub users are resolved to local users, bind your own implementation of `ResolvesHubUser` in a service provider:

```
use BeviBeverage\HubAuthClient\Contracts\ResolvesHubUser;

$this->app->bind(ResolvesHubUser::class, MyCustomUserResolver::class);
```

Your class must implement:

```
public function resolve(SocialiteUser $hubUser): Authenticatable;
```

Running Tests
-------------

[](#running-tests)

```
composer test
```

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance90

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% 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

56d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/24f82bbd421e85d21ad9389260d6651d999d4a7953b96c59673fe8133b211d7a?d=identicon)[michael.renon](/maintainers/michael.renon)

---

Top Contributors

[![webdev-jm](https://avatars.githubusercontent.com/u/58458510?v=4)](https://github.com/webdev-jm "webdev-jm (4 commits)")[![bevi-webdev-jm](https://avatars.githubusercontent.com/u/103414522?v=4)](https://github.com/bevi-webdev-jm "bevi-webdev-jm (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/bevi-webdev-jm-hub-auth-client/health.svg)

```
[![Health](https://phpackages.com/badges/bevi-webdev-jm-hub-auth-client/health.svg)](https://phpackages.com/packages/bevi-webdev-jm-hub-auth-client)
```

###  Alternatives

[leantime/leantime

Open source project management system for non-project managers. Simple like Trello, powerful like Jira. Built with neurodiversity in mind.

10.2k4.0k](/packages/leantime-leantime)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[bagisto/bagisto

Bagisto Laravel E-Commerce

27.6k172.1k9](/packages/bagisto-bagisto)[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.7M223](/packages/backpack-crud)[statamic/cms

The Statamic CMS Core Package

4.8k3.6M1.0k](/packages/statamic-cms)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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