PHPackages                             agriserv/sso - 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. agriserv/sso

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

agriserv/sso
============

A package to integrate with Agriserv SSO.

v2.0.1(1mo ago)1449MITPHP

Since Nov 12Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/Mamdouh95/ag-sso)[ Packagist](https://packagist.org/packages/agriserv/sso)[ RSS](/packages/agriserv-sso/feed)WikiDiscussions main Synced 1w ago

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

AgriServ SSO
============

[](#agriserv-sso)

Easily integrate your application with **AgriServ SSO**.

---

v2.0
----

[](#v20)

v2.0 strengthens the login flow: the callback authenticates to the SSO server when exchanging the one-time login token, and the handshake carries a single-use `state` value that is verified when the user returns to `auth/callback`.

### Upgrading from v1.x

[](#upgrading-from-v1x)

1. Upgrade the package: `composer require agriserv/sso:^2.0`. No changes to your published `LoginSsoController` are needed.
2. The SSO server must be running its matching v2 release.
3. After verifying login works, ask the SSO Administrator to enable **Require Authenticated Exchange** for your application.

> Logins started from the SSO portal's app tiles are transparently restarted as app-initiated logins (one extra redirect). This is expected.

---

Installation Steps
------------------

[](#installation-steps)

### 1. Install the Package

[](#1-install-the-package)

Add the package to your Laravel application via Composer:

```
composer require agriserv/sso
```

### 2. Publish the Configuration and Controller

[](#2-publish-the-configuration-and-controller)

```
php artisan vendor:publish --provider="Agriserv\SSO\AgriservSsoServiceProvider" --tag="config"
```

This will create a config/sso.php file in your application.

```
php artisan vendor:publish --provider="Agriserv\SSO\AgriservSsoServiceProvider" --tag="sso-controller"
```

This will publish a controller to your application at: app/Http/Controllers/LoginSsoController.php.

### 3. Set Up an Application in AgriServ SSO

[](#3-set-up-an-application-in-agriserv-sso)

Ask the AgriServ SSO Administrator to generate an application for you. Provide them with the following details: CALL\_BACK\_URI: Your application's callback URL — this is always `https://your-app.example.com/auth/callback` (the `auth/callback` route registered by this package).

### 4. Configure the .env File

[](#4-configure-the-env-file)

Add the following variables to your .env file:

```
SSO_BASE_URI="https://sso.agriserv.sa"
SSO_ID="APP_ID" # Replace with the Application ID provided by AgriServ Admin
SSO_SECRET_KEY="SECRET_KEY" # Replace with the Secret Key provided by AgriServ Admin
SSO_REDIRECT_URI="https://your-app.example.com/auth/callback" # Must be the auth/callback route, and must match the redirect URI registered with the AgriServ Admin exactly
SSO_LOGOUT_URL="https://sso.agriserv.sa/auth/logout" # The SSO portal's logout route
```

> **Important:** `SSO_REDIRECT_URI` must point at the package's `auth/callback` route, not your application root. If it points anywhere else the one-time login token is never exchanged and the user bounces between your app and the SSO portal.

> **Important:** `SSO_LOGOUT_URL` must point at the SSO portal's `auth/logout` route. Without it, logging out only ends your app's local session — the portal session survives and silently signs the user back in on the next protected page, making logout appear broken.

### 5. Override the handleUserInfo Method

[](#5-override-the-handleuserinfo-method)

Once the LoginSsoController is published, you can override the handleUserInfo method to handle the logic for processing user data from SSO.

Example: Handling User Info Open the `app/Http/Controllers/LoginSsoController.php` file, and modify the `handleUserInfo` method as needed:

```
 $userInfo['id'],
        ], [
            'email' => $userInfo['email'] ?? null,
            'name' => $userInfo['full_name'] ?? null,
        ]);

        // Dynamically assign roles
        $this->syncUserRoles($user, $userInfo['roles'] ?? []);

        // Log the user in with a fresh session id to prevent session fixation
        Auth::login($user);
        request()->session()->regenerate();

        // Redirect back to the page the user originally requested
        return redirect()->to(session()->pull('previousUrl', '/'));
    }

    /**
     * Sync roles with the local user.
     */
    private function syncUserRoles($user, array $roles)
    {
        if (method_exists($user, 'syncRoles')) {
            try {
                $user->syncRoles($roles);
            } catch (\Exception|\Throwable $e) {
                Log::warning("Failed to sync roles: " . $e->getMessage());
            }
        }
    }
}
```

### 6. Test Your Integration

[](#6-test-your-integration)

Test your SSO integration by navigating to the SSO login route (e.g., `/auth/sso`). Ensure users are logged in and synchronized correctly with your application.

### 7. Add Middleware for the protected routes

[](#7-add-middleware-for-the-protected-routes)

```
Route::middleware('sso_auth')->group(function () {
// Add routes
}

```

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance94

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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.

###  Release Activity

Cadence

Every ~41 days

Recently: every ~125 days

Total

16

Last Release

30d ago

Major Versions

v1.2 → v2.02026-07-18

### Community

Maintainers

![](https://www.gravatar.com/avatar/235bc6542e9b444197dc96c8a60cb6597681ff1fd9712ca7d94399bd9fdfd36d?d=identicon)[Mamdouh95](/maintainers/Mamdouh95)

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/agriserv-sso/health.svg)

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

###  Alternatives

[backpack/crud

Quickly build admin interfaces using Laravel, Bootstrap and JavaScript.

3.4k3.8M228](/packages/backpack-crud)[statamic/cms

The Statamic CMS Core Package

4.9k3.8M1.2k](/packages/statamic-cms)[unopim/unopim

UnoPim Laravel PIM

10.8k2.5k](/packages/unopim-unopim)[leantime/leantime

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

11.3k4.0k](/packages/leantime-leantime)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

353.6k](/packages/eslazarev-wildberries-sdk)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

793.9k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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