Y
Y
Yuliaka2019-02-19 06:50:46
Yii
Yuliaka, 2019-02-19 06:50:46

Yii2, how to make pass-through authorization with another application or give away authorization?

Good afternoon!
Please tell me how to make pass-through authorization
Roughly speaking, there is localhost
when we go to this address, the YII2 application is launched with authorization , we
authorize and everything is OK
, but at the address localhost / app2 is no longer Yii2,
how can I transfer authorization from YII2 to app2?
tried the following
in app2 call do

// .. куча разного кода 
// ..

defined('YII_ENV_DEV') or define('YII_ENV_DEV', false);
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');
$yii_home_dir = __DIR__ . '/../_yii/'.DIRECTORY_SEPARATOR;
require $yii_home_dir . 'vendor/yiisoft/yii2/Yii.php';
require $yii_home_dir . 'systembid/common/config/bootstrap.php';


$config = require($yii_home_dir . 'system1/frontend/config/config.php');
$r = new yii\web\Application($config);
echo '<pre>21'; print_r($r->runAction('auth/index'));die;[/code]

In 'auth/index' code
class AuthController extends \yii\rest\Controller
{
    public function actionIndex(){
        if(\Yii::$app->getUser()->isGuest)
            return false;
        return \Yii::$app->getUser()->identity;
    }
}

so in app2 I don't see anything ( localhost/app2/index.php)
in
localhost/auth/index I
see authorized user data

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey S., 2019-02-19
@Yuliaka

How is authorization in localhost/app2? Where is the authorization token stored? If in the session, then you can cock the sign of authorization in the session in Yii2, and then throw it on app2. It all depends on the app2 organization

D
Dmitry, 2019-02-19
@Astatroth

As a starting point , for example. Well, or OAuth .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question