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

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

maenbn/openamauth
=================

OpemAmAuth is a client for authenticating against OpenAM in PHP

v4.0.2(8y ago)28.3k↓50%[1 issues](https://github.com/maen-bn/openamauth/issues)MITPHPPHP &gt;=5.6

Since Apr 8Pushed 8y ago2 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (16)Used By (0)

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

[](#openam-authentication)

[![Build Status](https://camo.githubusercontent.com/f961312d5679b64fcf5e0778af4ee5fc8bfe9b90738a0d7d5926109a3135b13e/68747470733a2f2f7472617669732d63692e6f72672f6d61656e2d626e2f6f70656e616d617574682e7376673f6272616e63683d342e30)](https://travis-ci.org/maen-bn/openamauth)[![Codecov](https://camo.githubusercontent.com/acc21946597349459d9c20499f7887fa1ea5e1cc00f91880a4bd4d34a102196e/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6d61656e2d626e2f6f70656e616d617574682e737667)](https://codecov.io/gh/maen-bn/openamauth)[![Code Climate](https://camo.githubusercontent.com/c37667331c32f8a3824dafc92d366d6fce990d6fe656693cada49ecdd2eafd61/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6769746875622f6d61656e2d626e2f6f70656e616d617574682e737667)](https://codeclimate.com/github/maen-bn/openamauth)[![Code Climate](https://camo.githubusercontent.com/8d6a3b100e1535fbecac2bce70ed8ee40e046d1c9f52f5017fa0e559544c793e/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6973737565732f6769746875622f6d61656e2d626e2f6f70656e616d617574682e737667)](https://codeclimate.com/github/maen-bn/openamauth)[![Packagist](https://camo.githubusercontent.com/1f2045ac6a61ad18efc416a61ef34817569c89f1e81f4ac009f5b33b8ef87630/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61656e626e2f6f70656e616d617574682e737667)](https://packagist.org/packages/maenbn/openamauth)[![Packagist](https://camo.githubusercontent.com/4142a6218d8b263ca0666771a5510c820b7a0f1dd1297a164b3cf6a0ecc800ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61656e626e2f6f70656e616d617574682e737667)](https://packagist.org/packages/maenbn/openamauth)

This is a PHP library for authenticating users via OpenAM

NOTE: Usage with Laravel
------------------------

[](#note-usage-with-laravel)

This package has been changed to be framework agnostic. If you're using **Laravel 5.1** then continue to use **v1.1.**\* of this package. For later versions of Laravel, a new separate package for Laravel will be created using this package as it's core logic. More information will follow.

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

[](#installation)

The tool requires you have [PHP](https://php.net) 5.6.\*+ and [Composer](https://getcomposer.org).

You will also need a [OpenAM](http://openam.forgerock.org/) server.

To install the package run the following composer command

```
composer require maenbn/openamauth
```

Usage
-----

[](#usage)

### Setup

[](#setup)

To setup an OpenAm object you will need to initialise a config object and pass that to the OpenAm factory:

```
// Construct parameters are address of your OpenAm server, realm (optional), deploy URI (optional)
$config = new \Maenbn\OpenAmAuth\Config('https://myopenam.com', 'people', 'openam');
// OpenAm instance
$openAm = \Maenbn\OpenAmAuth\Factories\OpenAmFactory::create($config);
```

### Authenticating and retrieving the return token ID

[](#authenticating-and-retrieving-the-return-token-id)

```
if($openAm->authenticate('username', 'password'){
   $tokenId = $openAm->getTokenId();
   // Further successful authenication logic ...
}
```

### Validate Token

[](#validate-token)

If an OpenAm instance has ran a successful `authenticate` during the current runtime then you can validate the token id without having to set a token ID on the instance. Other wise use the `setTokenId` setter before validating.

```
// Returns a bool or throws and exception if not token ID is set
$valid = $openAm->setToken($tokenId)->validateTokenId();
```

### Getting users details

[](#getting-users-details)

If an OpenAm instance has ran a successful `authenticate` during the current runtime then you can get the users details return from OpenAM without having to set a token ID and the user ID. Other wise use the `setTokenId`and `setUid` setters before running the `setUser` then `getUser`.

```
// Returns a stdClass with the user's details or null if the token ID and user ID have not been set
  $user = $openAm->setToken($tokenId)->setUid($uid)->setUser()->getUser();

// If successful authenicate has been ran
if($openAm->authenticate('username', 'password'){
   $user = $openAm->getUser();
   // Further successful authenication logic ...
}
```

### Logging out

[](#logging-out)

If an OpenAm instance has ran a successful `authenticate` during the current runtime then you can logout without having to set a token ID. Other wise use the `setTokenId` setter before logging out a user.

```
// Return a bool based of success of log out
$openAm->setTokenId($tokenId)->logout();
```

### Accessing Config object via OpenAm object

[](#accessing-config-object-via-openam-object)

When the `Config` object is injected into the constructor of `OpenAm` it'll modify the `cookieName` and `cookieSecure` property on `Config` if they're set to `null`. This is done by retrieving this information from the OpenAm server. Obviously you may want to retrieve this data in order to set a cookie on your app correctly. Therefore you can access the `Config` object via the `OpenAm` object via the getter:

```
// Will return Config object
$config = $openAm->getConfig();

$cookieName = $config->getCookieName();
$cookieSecure = $cofig->getCookieSecure();
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

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

Recently: every ~0 days

Total

14

Last Release

3230d ago

Major Versions

v1.1.2 → v3.0.02017-05-04

v2.0.0 → v4.0.02017-05-04

PHP version history (5 changes)v1.0PHP &gt;=5.4.0

v1.1.1PHP &gt;=5.5.9

v3.0.0PHP &gt;=5.4

v2.0.0PHP &gt;=5.3

v4.0.0PHP &gt;=5.6

### 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 (31 commits)")

---

Tags

authAuthenticationBen NorcombeBenNorcombeopemam authopenam authenticationOpenAMOpenAmAuth

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[tymon/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

11.5k49.1M350](/packages/tymon-jwt-auth)[league/oauth2-server

A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.

6.6k136.0M248](/packages/league-oauth2-server)[php-open-source-saver/jwt-auth

JSON Web Token Authentication for Laravel and Lumen

8359.8M53](/packages/php-open-source-saver-jwt-auth)[auth0/auth0-php

PHP SDK for Auth0 Authentication and Management APIs.

40820.2M68](/packages/auth0-auth0-php)[kreait/firebase-tokens

A library to work with Firebase tokens

24040.8M14](/packages/kreait-firebase-tokens)[opauth/opauth

Multi-provider authentication framework for PHP

1.6k783.4k58](/packages/opauth-opauth)

PHPackages © 2026

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