PHPackages                             lucidprogrammer/yii2-simplesamlphp - 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. lucidprogrammer/yii2-simplesamlphp

ActiveYii2-extension[Authentication &amp; Authorization](/categories/authentication)

lucidprogrammer/yii2-simplesamlphp
==================================

SAML Service Provider(SP) for Yii2 using simplesamlphp

1.3(8y ago)44855[1 issues](https://github.com/lucidprogrammer/yii2-simplesamlphp/issues)[1 PRs](https://github.com/lucidprogrammer/yii2-simplesamlphp/pulls)BSD-3-ClausePHP

Since Feb 15Pushed 7y agoCompare

[ Source](https://github.com/lucidprogrammer/yii2-simplesamlphp)[ Packagist](https://packagist.org/packages/lucidprogrammer/yii2-simplesamlphp)[ RSS](/packages/lucidprogrammer-yii2-simplesamlphp/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

yii2-simplesamlphp
==================

[](#yii2-simplesamlphp)

SAML Service Provider(SP) for Yii2 using simplesamlphp (yii2 extension). This is useful when you want to act as a Service Provider(SP), where a partner company is acting as a SAML Identity Provider (IDP). User data and their credentials are with the IDP and you are using SAML based login and use those users information in your yii2 application.

This is a very basic implementation where we are not persisting user data coming from the IDP at the Service Provider side for reporting on usage etc. However, those are fairly straightforward additions one can do.

Installation
============

[](#installation)

This is available to be installed via composer. In your yii2 application folder, run the following command.

```
composer require lucidprogrammer/yii2-simplesamlphp

```

This will install the package as a yii2 extension and update the extensions and installs the simplesamlphp project too in the vendor folder.

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

[](#configuration)

### Step 1 - Configuring an alias for /saml in your web server.

[](#step-1---configuring-an-alias-for-saml-in-your-web-server)

In a standard web server configuration like Apache, the DocumentRoot will be pointing to the yii2 application's web folder. Create an alias for /saml pointing to pathto\_my-yii2-app/vendor/simplesamlphp/simplesamlphp/[www](http://www).

In the case of Apache, you may do something like (replace pathto\_my-yii2-app with your real path.)

```
echo "Alias /saml pathto_my-yii2-app/vendor/simplesamlphp/simplesamlphp/www" >> /etc/apache2/apache2.conf
echo " \n Options Indexes FollowSymLinks \n AllowOverride all \n Require all granted \n   " >> /etc/apache2/apache2.conf

```

To explain it visually, following could help.

```
my-yii2-app/
          /web    -> DocumentRoot
          ..
          ..
          /vendor
              ...
              ...
              /lucidprogrammer  (newly created folder in vendor)
              /simplesamlphp    (newly created folder in vendor)
                  /simplesamlphp/wwww      -> [Create an alias /saml pointing to pathto_my-yii2-app/vendor/simplesamlphp/simplesamlphp/www]

```

### Step 2 - Configure yii2 configuration.

[](#step-2---configure-yii2-configuration)

Yii configuration straightforward, just add the following in your config/web.php

```
'user' => [
    'class' => 'lucidprogrammer\simplesamlphp\SamlUser',
    //idAttribute is mandatory
    //for example, if your IDP is sending a SAML payload which has ID, you may do as follows
    'idAttribute' => 'ID',
    //if you want to map IDP provided attributes to something else, you may do additional mappings as name value pairs.
    //following are some examples, not mandatory
    'firstName' => 'givenName',
    'company' => 'companyName',
],

```

ADFS example,

```
'user' => [
    'class' => 'lucidprogrammer\simplesamlphp\SamlUser',
    //for example, if your IDP is ADFS, and you want to use email address as the unique ID
    'idAttribute' => 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress',
],

```

### Note on enabling authentication for a route using yii2

[](#note-on-enabling-authentication-for-a-route-using-yii2)

Let's say you have a rule like the following in your yii2 setting,

```
'access' => [
    'class' => AccessControl::className(),
    'only' => ['index','logout','about'],
    'rules' => [
      [
            'allow' => true,
            'actions' => ['index'],
            'roles' => ['?'],
        ],
        [
            'actions' => ['logout'],
            'allow' => true,
            'roles' => ['@'],
        ],
    ],
  ],

```

After the component is installed, the moment you hit the site/about page, it should redirect you to the configured saml idp login page.

So, if you want to do SAML provided attributes and want to implement a fine grained access control, yii2 makes it easy.

### Note on yii2 login link.

[](#note-on-yii2-login-link)

If your application has links to login, for example, 'site/login', you need to change to *saml/login.*

However, it is best if you use Yii::$app-&gt;user-&gt;loginUrl\[0\], so it will take whatever is the correct loginUrl, so it will work with or without this plugin.

Sample app
----------

[](#sample-app)

Changelog
=========

[](#changelog)

02 March 2018 The class name `Object` is invalid since PHP 7.2, use \[\[BaseObject\]\] instead. \[handle backward compatibility to yii base Object\] Added SamlSettings options for easy configuration. Tested with ADFS 3.0, Windows 2012 R2 &amp; simplesamlphp (IDP)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity19

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

Total

4

Last Release

2998d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f26304cda5ed0f1afbb99757f42491f7e503c830258fdbb8a36d55c231886543?d=identicon)[lucidprogrammer](/maintainers/lucidprogrammer)

---

Top Contributors

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

---

Tags

phpsamlsimplesamlphpyii2-extensionsamlyii2yiisimplesamlphp

### Embed Badge

![Health badge](/badges/lucidprogrammer-yii2-simplesamlphp/health.svg)

```
[![Health](https://phpackages.com/badges/lucidprogrammer-yii2-simplesamlphp/health.svg)](https://phpackages.com/packages/lucidprogrammer-yii2-simplesamlphp)
```

###  Alternatives

[amnah/yii2-user

Yii 2 user authentication module

252225.7k3](/packages/amnah-yii2-user)[hslavich/simplesamlphp-bundle

SimpleSAMLphp Bundle for Symfony

22199.9k](/packages/hslavich-simplesamlphp-bundle)

PHPackages © 2026

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