PHPackages                             rockstoneaidev/auth-bridge-laravel - 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. rockstoneaidev/auth-bridge-laravel

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

rockstoneaidev/auth-bridge-laravel
==================================

Bridge package for Laravel applications to authenticate against the centralized Auth API service.

098PHP

Since Dec 13Pushed 5mo agoCompare

[ Source](https://github.com/rockstoneaidev/auth-bridge-laravel)[ Packagist](https://packagist.org/packages/rockstoneaidev/auth-bridge-laravel)[ RSS](/packages/rockstoneaidev-auth-bridge-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Auth Bridge for Laravel
=======================

[](#auth-bridge-for-laravel)

`rockstoneaidev/auth-bridge-laravel` is a reusable bridge package for Laravel applications that authenticate and authorize via **Firebase Authentication** (recommended) or the centralized [Auth API service](https://github.com/rockstoneaidev/auth-api) (legacy).

It keeps a lightweight local user record in sync with the external identity provider while delegating all token handling, roles, and permissions to the configured provider.

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

[](#requirements)

- PHP 8.4+
- Laravel 12.x
- Firebase Project (for Firebase provider) OR Central Auth API v1 (for Auth API provider)

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

[](#installation)

```
composer require rockstoneaidev/auth-bridge-laravel
```

Publish the configuration (optional) and migrations, then migrate:

```
php artisan vendor:publish --tag=auth-bridge-config
php artisan vendor:publish --tag=auth-bridge-migrations
php artisan migrate
```

Publishing the migration adds the shared `external_*` columns (and `avatar_url` / `last_seen_at`) to your app's `users` table. These columns serve as the local cache of the remote identity (Firebase UID or Auth API UUID).

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

[](#configuration)

### 1. Select Provider

[](#1-select-provider)

Update `.env` to select your authentication provider:

```
# Options: firebase (default/recommended) | auth_api (legacy)
AUTH_BRIDGE_PROVIDER=firebase
```

### 2. Configure Provider

[](#2-configure-provider)

#### Option A: Firebase (Default)

[](#option-a-firebase-default)

Configure your Firebase project details. Use a separate Firebase project for each environment (e.g., `myapp-staging`, `myapp-prod`).

```
FIREBASE_PROJECT_ID=my-app-staging
# Optional: Override defaults
# FIREBASE_JWKS_URL=...
# FIREBASE_ISSUER_PREFIX=...
```

The bridge verifies Firebase ID tokens (JWT) using Google's public keys and maps claims to your local `users` table.

#### Option B: Auth API (Legacy)

[](#option-b-auth-api-legacy)

For apps using the existing centralized Auth API infrastructure:

```
AUTH_BRIDGE_PROVIDER=auth_api
AUTH_BRIDGE_BASE_URL=https://auth.example.com/api/v1
AUTH_BRIDGE_PUBLIC_URL=https://auth.example.com
```

Configure the Guard
-------------------

[](#configure-the-guard)

Update `config/auth.php` with a bridge guard that uses your existing `users` provider:

```
'guards' => [
    'api' => [
        'driver' => 'auth-bridge',
        'provider' => 'users',
        'cache_ttl' => 30,        // seconds (set 0 to disable caching)
    ],
],
```

Point any API routes that rely on remote tokens to this guard:

```
Route::middleware(['auth:api'])->group(function () {
    Route::get('/me', fn () => request()->user());
});
```

The guard automatically:

1. Extracts the Bearer token.
2. Authenticates via the configured provider (Firebase or Auth API).
3. Synchronizes the identity to your local `users` table.
4. Injects the hydrated local user into the request (`request()->user()`)

User Model Setup
----------------

[](#user-model-setup)

Add the provided trait to your `App\Models\User`:

```
use AuthBridge\Laravel\Concerns\HasAuthBridgeUser;

class User extends Authenticatable
{
    use HasAuthBridgeUser;
}
```

Onboarding a New App
--------------------

[](#onboarding-a-new-app)

### With Firebase (Recommended)

[](#with-firebase-recommended)

1. Create a Firebase project at [Firebase Console](https://console.firebase.google.com).
2. Enable Authentication (Email/Password, Google, etc.).
3. Set `AUTH_BRIDGE_PROVIDER=firebase` and `FIREBASE_PROJECT_ID=...` in `.env`.
4. Use the Firebase JS SDK in your frontend to obtain an ID token.
5. Send the token as `Authorization: Bearer ` to your Laravel API.

### With Auth API (Legacy)

[](#with-auth-api-legacy)

Run the onboarding command to register your app and scaffold the OAuth client:

```
php artisan auth-bridge:onboard \
  --app-key=docs \
  --app-name="Docs" \
  --redirect=${APP_URL}/oauth/callback \
  --bootstrap-token=${AUTH_API_BOOTSTRAP_TOKEN}
```

Accessing Remote Context
------------------------

[](#accessing-remote-context)

Use the facade or injected `AuthBridgeContext` service to read the raw payload or check permissions:

```
use AuthBridge\Laravel\Facades\AuthBridge;

if (AuthBridge::hasPermission('documents.write')) {
    // user has permission
}
```

Contributing
------------

[](#contributing)

Issues and PRs are welcome. Please run `composer test` (Pest via Testbench) before opening a PR.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance50

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8228e1b92436619829fdc20a9034ee517f2079e64ff750f424dc0036c6a62209?d=identicon)[rockstoneaidev](/maintainers/rockstoneaidev)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/rockstoneaidev-auth-bridge-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/rockstoneaidev-auth-bridge-laravel/health.svg)](https://phpackages.com/packages/rockstoneaidev-auth-bridge-laravel)
```

###  Alternatives

[namshi/jose

JSON Object Signing and Encryption library for PHP.

1.8k99.6M101](/packages/namshi-jose)[league/oauth1-client

OAuth 1.0 Client Library

99698.8M106](/packages/league-oauth1-client)[bezhansalleh/filament-shield

Filament support for `spatie/laravel-permission`.

2.8k2.9M88](/packages/bezhansalleh-filament-shield)[gesdinet/jwt-refresh-token-bundle

Implements a refresh token system over Json Web Tokens in Symfony

70516.4M35](/packages/gesdinet-jwt-refresh-token-bundle)[league/oauth2-google

Google OAuth 2.0 Client Provider for The PHP League OAuth2-Client

41721.2M118](/packages/league-oauth2-google)[illuminate/auth

The Illuminate Auth package.

9327.3M1.0k](/packages/illuminate-auth)

PHPackages © 2026

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