anli/yii2-auth0 Yii2 Auth0

extension

anli\auth0

Yii2 Auth0

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist anli/yii2-auth0 "*"

or add

"anli/yii2-auth0": "*"

to the require section of your composer.json file.

Run migration with:

php yii migrate/up --migrationPath=@vendor/anli/yii2-auth0/migrations

Configuration

Update the modules section with:

'auth0' => array_merge([
    'class' => 'anli\auth0\Module',
    'adminEmails' => ['anli@simbiosis.com.sg'],
], require(__DIR__ . '/auth0-local.php')),

Create a new file in config/auth0-local.php:

<?php
if (YII_ENV_DEV) {
    return [
        'serviceId' => '',
        'domain' => '',
        'clientId' => '',
        'clientSecret' => '',
        'redirectUrl' => '',
        'apiTokens' => [
            'usersRead' => '',
            'usersUpdate' => '',
        ]
    ];
}

return [
    'serviceId' => '',
    'domain' => '',
    'clientId' => '',
    'clientSecret' => '',
    'redirectUrl' => '',
    'apiTokens' => [
        'usersRead' => '',
        'usersUpdate' => '',
    ]
];

Add to your .gitignore file:

/config/auth0-local.php

Login to auth0 and update the Allowed Callback Urls in your setting page.

Update the components section in the config with:

'user' => [
    'identityClass' => 'anli\auth0\models\User',
    'loginUrl' => ['auth0/user/login'],
],
'tenant' => [
    'class' => 'anli\auth0\components\Tenant',
],

Usage

Update your url section for your login button to [/auth0/user/login].

Update your url section for your logout button to [/auth0/user/logout].

To show the login user, use:

Html::encode(Yii::$app->user->identity->username);

To show the login tenant, use:

Html::encode(Yii::$app->tenant->identity->name);

To auto update the tenant_id, add to the behaviors section of your model with:

use anli\auth0\behaviors\TenantBehavior;
...
'tenant' => [
    'class' => TenantBehavior::className(),
],

FAQs

If you encounter the following error

\JWT not found

Change the firebase/php-jwt version to v2.2.0:

cd @vendor/firebase/php-jwt
git checkout v2.2.0

Update the @vendor/composer/autoload_classmap.php with:

'BeforeValidException' => $vendorDir . '/firebase/php-jwt/Exceptions/BeforeValidException.php',
'JWT' => $vendorDir . '/firebase/php-jwt/Authentication/JWT.php',

If you encounter the following error:

Cannot handle token prior to 2015-08-05T10:42:34+0200

And your system time forward a few minutes.

If you encounter the following error:

cURL error 60: SSL certificate problem: self signed certificate in certificate chain

Download CA to;

C:\xampp\php\ca\cacert.pem

and update C:\xampp\php\php.ini with

curl.cainfo=C:\xampp\php\ca\cacert.pem

Restart your apache2 server.

Changelog

CHANGELOG

1.11.0 [12 Apr 2015]

  • enh Added search by email manual feature

1.10.2 [10 Dec 2015]

  • bug Fixed bug to allow unique validator based on tenant id to work correctly

1.10.1 [9 Dec 2015]

  • bug Fixed bug to display auth0 lock correctly with latest version of chrome

1.10.0 [11 Nov 2015]

  • bug Fixed bug to display sidebar correctly.

1.9.0 [18 Sep 2015]

  • chg Changed rememberLastLogin settings

1.8.0 [17 Sep 2015]

  • enh Added image url function

1.7.0 [3 Sep 2015]

  • bug Fixed bug to remove tenant correctly from Auth0 AppMetadata
  • enh Added UserQuery

1.6.1 [2 Sep 2015]

  • bug Fixed bug to use the latest stable version of yii2-metronic and yii2-helper

1.6.0 [2 Sep 2015]

  • enh Added change tenant feature
  • bug Fixed bug to refresh service admin page correctly after tenant create or update

1.5.0 [1 Sep 2015]

  • chg Changed sidebar to web service params

1.4.0 [31 Aug 2015]

  • enh Added validate tenant function to auth0 model

1.3.0 [28 Aug 2015]

  • enh Added user select2Data function
  • enh Added tenant function
  • chg Changed login action with goBack() function
  • enh Added access control to controller
  • enh Added documentation on admin email configuration
  • enh Added update user feature to admin

1.2.0 [19 Aug 2015]

  • enh Added metronic theme
  • enh Added create action and create form with modal assets
  • enh Added buttons to tenant
  • enh Added login layout
  • enh Added confirmation msg for delete all, added audit log for tenant
  • enh Added users column to tenant portlet
  • enh Added user portlet in tenant admin dashboard with tenants column
  • chg Removed tick and cross in service-admin index
  • chg Changed portlet layout similar to the old design
  • enh Added the import all function in tenant service admin
  • enh Added export function to tenant service admin
  • enh Added session flash feature
  • enh Added checkbox function to gridview in service admin

1.1.0 [12 Aug 2015]

  • enh Added Service Admin index page
  • enh Added Tenant User model

1.0.0 [5 Aug 2015]

  • Initial release

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



1.11.0 is the latest of 15 releases



MIT license
Stats
4 github stars & 5 github forks
0 downloads in the last day
0 downloads in the last 30 days
161 total downloads