PHPackages                             zanichelli/idp-extensions - 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. zanichelli/idp-extensions

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

zanichelli/idp-extensions
=========================

Classes to interact with the Zanichelli identity provider

v3.8.2(1mo ago)06.6k↓22.5%[1 PRs](https://github.com/ZanichelliEditore/idp-extension/pulls)MITPHPCI failing

Since Jun 30Pushed 4d ago3 watchersCompare

[ Source](https://github.com/ZanichelliEditore/idp-extension)[ Packagist](https://packagist.org/packages/zanichelli/idp-extensions)[ RSS](/packages/zanichelli-idp-extensions/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (10)Versions (37)Used By (0)

Zanichelli IDP Laravel Extension packages
=========================================

[](#zanichelli-idp-laravel-extension-packages)

This is Laravel package to use with laravel-jwt-idp (Github: ).

How to integrate package in your project
----------------------------------------

[](#how-to-integrate-package-in-your-project)

### Step 1 - Install by Composer

[](#step-1---install-by-composer)

```
   composer require zanichelli/idp-extensions
```

**`Note:`you should use tag instead of branch-name (e.g. *"zanichelli/idp-extensions:V1.0.0"* or *"zanichelli/idp-extensions:dev-{branch-name}"* )**

### Step 2 - .env file

[](#step-2---env-file)

Add this lines at bottom of your .env file:

```
  IDP_BASE_URL=https://idp.zanichelli.it
  IDP_COOKIE_NAME=token

```

If you need to use your own login form (instead of the IDP one), please add this line too:

```
  IDP_LOGIN_URL=https://idp.zanichelli.it/v4/login

```

### Step 3 - auth.php editing

[](#step-3---authphp-editing)

Edit `config/auth.php` as follow:

- In `'defaults'` array change value of `'guard'` from `'web'` to `'z-session'`

### Step 4 - publish migrations

[](#step-4---publish-migrations)

There are 2 migration from this package, Grants table and Sessions Table.

```
   php artisan vendor:publish
```

and select the "zanichelli/idp-extension" provider

### Step 4.A - publish migrations (BREAKING CHANGES) after v3.0.**\***

[](#step-4a---publish-migrations-breaking-changes-after-v30)

There are 3 migrations from this package:

- Grants table
- Sessions Table
- Grants table key changes (Change role\_id and department\_id to **role\_name** and **department\_name**).

```
   php artisan vendor:publish
```

Using the command below will only apply the changes about role\_id and department\_id

```
   php artisan vendor:publish --tag=grants-by-name-instead-of-id
```

Use

```
   php artisan vendor:publish --tag=grants-by-name-instead-of-id --force
```

if you need to overwrite grants table changes migration.

### Step 5 - create route middleware and protect your routes

[](#step-5---create-route-middleware-and-protect-your-routes)

#### For Laravel up to version 10:

[](#for-laravel-up-to-version-10)

In Kernel.php file add "idp" in your routeMiddleware

```
'idp' => \Zanichelli\IdpExtension\Http\Middleware\IdpMiddleware::class,
```

#### For Laravel from version 11:

[](#for-laravel-from-version-11)

Kernel.php file is no more. Register your middleware in 'bootstrap/app.php'

```
$middleware->alias([
  'idp' => \Zanichelli\IdpExtension\Http\Middleware\IdpMiddleware::class
]);
```

---

The default behaviour also retrieves the user's permissions (`with_permissions`) and remove token from query params (`without_token_url`) You can specify different configuration like this: Avoid to remove token from url

```
  Route::group(['middleware'=>'idp:with_permissions,with_token_url'],function(){
    Route::get('/', function(){
      return view('home');
    });
  });
```

Avoid to retrieve permission

```
  Route::group(['middleware'=>'idp:without_permissions'],function(){
    Route::get('/', function(){
      return view('home');
    });
  });
```

Avoid to remove token from url and retrieve permission

```
  Route::group(['middleware'=>'idp:without_permissions,with_token_url'],function(){
    Route::get('/', function(){
      return view('home');
    });
  });
```

Add to your route file (tipically `web.php`) the new middleware `idp`; code smells like this:

```
  Route::group(['middleware'=>'idp'],function(){
    Route::get('/', function(){
      return view('home');
    });
  });
```

Alternatively, two middlewares read the cookie and, if found, retrieves the user's data and adds it to the request

`IdpApiMiddleware` retrieves user's data from v1 user api call

```
'idp' => \Zanichelli\IdpExtension\Http\Middleware\IdpApiMiddleware::class,
```

`IdpApiJWKSMiddleware` retrieves user's data from jwt token

```
'idp' => \Zanichelli\IdpExtension\Http\Middleware\IdpApiJWKSMiddleware::class,
```

### Extends IDP middleware

[](#extends-idp-middleware)

In order to edit retrive permissions or add extra parameter to user object you can extend default class IDP Middleware.

Class must implement following methods:

- `retrievePermissions`: this method take userId and roles array as input, here role-based permissions must be retrieved to output an array of strings with permissions;
- `addExtraParametersToUser`: this method allow you to add extra parameters to the user object given as input.

After class creation, add in `kernel.php` file the new middleware class in `'$routeMiddleware'` array:

```
  'idp' => \App\Http\Middleware\IdpMiddleware::class,
```

Logout idp
----------

[](#logout-idp)

Create a logout route inside `web.php` file using a ***logout*** method inside the controller. Implement the code as follow:

```
  Route::group(['middleware'=>'idp'],function(){
    Route::get('logout',  'LoginController@logout');
  });
```

Then define **`logout`**:

```
use use Illuminate\Support\Facades\Auth;

class LoginController extends Controller
{
  ...

  public function logout()
  {
    return Auth::logout();
  }
}
```

Basics
======

[](#basics)

With this integration you could use some Laravel's feature that allows to handle users and their authentication. `Auth` is authtentication class that Laravel ships for this purpose and allow access to following methods:

- `Auth::check()`: returns `true` if a user is authenticated, `false` otherwise
- `Auth::guest()`: returns `true` if a user is guest, `false` otherwise
- `Auth::user()`: returns a `ZUser` class instance, `null` otherwise
- `Auth::id()`: returns `userId` if authtenticated, `null` otherwise
- `Auth::hasUser()`: returns `true` if there's a ZUser in our current session, `false` otherwise
- `Auth::setUser($ZUser)`: sets a `Zuser` in session
- `Auth::attempt($credentials, $remember)`: try to login with IDP without using the login form, if success returns `true`, otherwise `false`
- `Auth::logout()`: logout a user, return `redirect`

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance96

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

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

Recently: every ~124 days

Total

23

Last Release

36d ago

Major Versions

v1.0.7 → v2.0.02021-03-12

v2.0.1 → v3.0.02022-03-11

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/30625823?v=4)[Giuseppe Saraceno](/maintainers/gsaraceno92)[@gsaraceno92](https://github.com/gsaraceno92)

---

Top Contributors

[![veronicavannini](https://avatars.githubusercontent.com/u/129746390?v=4)](https://github.com/veronicavannini "veronicavannini (17 commits)")[![AliGamb](https://avatars.githubusercontent.com/u/44899747?v=4)](https://github.com/AliGamb "AliGamb (12 commits)")[![francesco-santi-1](https://avatars.githubusercontent.com/u/103131770?v=4)](https://github.com/francesco-santi-1 "francesco-santi-1 (12 commits)")[![PaoloFrancesco-Marino](https://avatars.githubusercontent.com/u/61237621?v=4)](https://github.com/PaoloFrancesco-Marino "PaoloFrancesco-Marino (11 commits)")[![vpasquino](https://avatars.githubusercontent.com/u/67588501?v=4)](https://github.com/vpasquino "vpasquino (8 commits)")[![mikelina](https://avatars.githubusercontent.com/u/52574539?v=4)](https://github.com/mikelina "mikelina (5 commits)")[![adecastri](https://avatars.githubusercontent.com/u/82823337?v=4)](https://github.com/adecastri "adecastri (3 commits)")[![vonaxl](https://avatars.githubusercontent.com/u/55137395?v=4)](https://github.com/vonaxl "vonaxl (2 commits)")[![amalferpoma](https://avatars.githubusercontent.com/u/31272659?v=4)](https://github.com/amalferpoma "amalferpoma (2 commits)")[![LorenzoEmanuele00](https://avatars.githubusercontent.com/u/140862390?v=4)](https://github.com/LorenzoEmanuele00 "LorenzoEmanuele00 (1 commits)")[![gsiciliano](https://avatars.githubusercontent.com/u/19527368?v=4)](https://github.com/gsiciliano "gsiciliano (1 commits)")[![saldomik](https://avatars.githubusercontent.com/u/55138655?v=4)](https://github.com/saldomik "saldomik (1 commits)")[![attraverso](https://avatars.githubusercontent.com/u/61787646?v=4)](https://github.com/attraverso "attraverso (1 commits)")

### Embed Badge

![Health badge](/badges/zanichelli-idp-extensions/health.svg)

```
[![Health](https://phpackages.com/badges/zanichelli-idp-extensions/health.svg)](https://phpackages.com/packages/zanichelli-idp-extensions)
```

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k294.2M218](/packages/google-auth)[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.6M985](/packages/statamic-cms)[unopim/unopim

UnoPim Laravel PIM

10.5k2.4k](/packages/unopim-unopim)[ellaisys/aws-cognito

Laravel Authentication using AWS Cognito (Web and API)

123256.9k1](/packages/ellaisys-aws-cognito)[firefly-iii/data-importer

Firefly III Data Import Tool.

8035.8k](/packages/firefly-iii-data-importer)

PHPackages © 2026

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