PHPackages                             maenbn/openamauth-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. maenbn/openamauth-laravel

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

maenbn/openamauth-laravel
=========================

OpenAM Authentication driver for Laravel

02.3k[2 issues](https://github.com/maen-bn/openamauth-laravel/issues)PHP

Since Oct 18Pushed 8y ago2 watchersCompare

[ Source](https://github.com/maen-bn/openamauth-laravel)[ Packagist](https://packagist.org/packages/maenbn/openamauth-laravel)[ RSS](/packages/maenbn-openamauth-laravel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

OpenAM Authentication
=====================

[](#openam-authentication)

This is a provider for adding a OpenAM driver to your authentication system in Laravel 5

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

[](#installation)

To install the package run the following composer command

```
composer require maenbn/openamauth
```

You will also need to register the service provider by going into `config/app.php` and add the following to the `providers` key:

```
Maenbn\OpenAmAuthLaravel\Providers\OpenAmServiceProvider::class,
```

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

[](#configuration)

You'll need to configure the package for your OpenAM server. First publish the vendor assets:

```
$ php artisan vendor:publish
```

which will create a `config/openam.php` file in your app where you can modify it to reflect your OpenAM server.

Finally make sure to change the value for the `driver` key to `openam` in `config/auth.php`.

### Eloquent model

[](#eloquent-model)

There is also an option to use an Eloquent model as the user object for OpenAM authentication. This is useful if you want to authenticate against OpenAM but want to control authorisation within Laravel e.g. using [Entrust](https://github.com/Zizaco/entrust) package.

Ideally the default `App\User` class found in a new install of Laravel is perfect for this. Modify the `eloquentModel` key to refer to the Eloquent class you want and the `eloquentUid` key to store the OpenAM uid into your user table column in the `config/openam.php` file e.g.

```
'eloquentModel' => App\User::class,

'eloquentUidName' => 'username',
```

Finally, modify your Eloquent model to use the OpenAM `Authenicatable` trait and extend off the Laravel `Model` class instead of the `Authenticable` class like below:

```
namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Database\Eloquent\Model;
use Maenbn\OpenAmAuthLaravel\Authenticatable

class User extends Model
{
    use Notifiable, Authenticatable;
    ..........
```

Middleware
----------

[](#middleware)

If you require your app to set a cookie to hold the OpenAM token, you can utilise the middleware available in this package. Add it to your `app/Http/Kernel.php` as a middleware group:

```
protected $middlewareGroups = [
    ...............
    \Maenbn\OpenAmAuthLaravel\Middleware\SetOpenAmCookie::class,
];
```

You have to also make sure you add your OpenAM cookie name into the `except` array found in the middleware `app/Http/Middleware/EncryptCookies.php` so the token value isn't encrypted as it will need to be validated during authentication attempts.

You can either hard code it or do the following in `app/Http/Middleware/EncryptCookies.php` making sure you import the `Closure` class into the middleware:

```
namespace app\Http\Middleware;

use Closure;
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;

class EncryptCookies extends BaseEncrypter
{
    /**
     * The names of the cookies that should not be encrypted.
     *
     * @var array
     */
    protected $except = [
    ];

    public function handle($request, Closure $next)
    {
        $this->except[] = config('openam.cookieName');
        return parent::handle($request, $next);
    }
}
```

\##Usage Now your Auth driver is using OpenAM you will be able to use the Laravel's `Auth` class to authenticate users.

\###Examples

```
//Authenticating using the OpenAM TokenID from a cookie
Auth::attempt();

//Authenticating using user input
$input = Input::only('username', 'password');
Auth::attempt($input);

//Retrieving the OpenAM attributes of a logged in user
$user = Auth::user();
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

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/a9584c3343f91b023d5109fb84e2ad0406e1d79e48308337fc5797ab0c075bb5?d=identicon)[maen-bn](/maintainers/maen-bn)

---

Top Contributors

[![maen-bn](https://avatars.githubusercontent.com/u/8006284?v=4)](https://github.com/maen-bn "maen-bn (3 commits)")

### Embed Badge

![Health badge](/badges/maenbn-openamauth-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/maenbn-openamauth-laravel/health.svg)](https://phpackages.com/packages/maenbn-openamauth-laravel)
```

###  Alternatives

[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)[illuminate/auth

The Illuminate Auth package.

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

A flexible, driver based Acl package for PHP 5.4+

870304.7k2](/packages/beatswitch-lock)[amocrm/amocrm-api-library

amoCRM API Client

182728.5k6](/packages/amocrm-amocrm-api-library)[vonage/jwt

A standalone package for creating JWTs for Vonage APIs

424.1M4](/packages/vonage-jwt)

PHPackages © 2026

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