uhi67/yii2-eduid

EduID SP login for Yii2

Installs: 5

Dependents: 0

Suggesters: 0

Type:yii2-extension

1.1.3.1 2019-01-14 22:20 UTC

README

Login helper to EduiID using preinstalled SimplesamlPHP SP instance for Yii2 applications

Prerequisites

  • yii2 >= 2.0.13
  • php >= 5.6
  • SimpleSamlPHP >= 1.14

Installation

The preferred way to install this extension is through composer.

To install, either run

    composer require uhi67/yii2-eduid "1.*" 

or add

"uhi67/yii2-eduid" : "1.*"

or clone form github

    git clone https://github.com/uhi67/yii2-eduid

Usage

Settings in config file (web.php)

'components' => [
    'saml' => [
            'class' => 'uhi67\eduidsp\Saml',
            'simpleSamlPath' => '/usr/share/simplesamlphp/',
            'authSource' => 'default-sp'
    ]
]

Usage in code

$saml = Yii::$app->saml;
//check is authenticated
$saml->isAuthenticated();
//Login
$saml->requireAuth();
$saml->attributes;
$saml->logout();

Usage in views

For normal login button, use eduid-login class, for light version use eduid-login eduid-light classes.

<?php
use uhi67\eduidsp\SamlAsset;

/* @var yii\web\View $this */
SamlAsset::register($this);
?>
<?= Html::a(Yii::t('app', 'Login'), ['saml'], ['class' => 'btn btn-primary eduid-login eduid-light']) ?>