M
M
Maxemp2018-02-02 14:55:53
Yii
Maxemp, 2018-02-02 14:55:53

How to solve the problem of unified authentication not working?

I use advanced app and made a single authentication in my project, then I tried to log in on the frontend, everything seems to be fine, but when the user entered the backend, he was not logged in, I decided to try to log in to the backend to check, but it turned out that the authorization did not work at all, it just redirected to the main page not logged in.
Here is the backend main.php file code (everything related to authentication)

'request' => [
            'csrfParam' => '_csrf-backend',
          'cookieValidationKey' => $params['cookieValidationKey'],
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => [
            	'name' => '_identity',
              'httpOnly' => true,
              'domain' => $params['cookieDomain'],
            ],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => '_session',
          'cookieParams' => [
          	'domain' => $params['cookieDomain'],
            'httpOnly' => true,
          ],
        ],

Here is the frontend main.php file code (everything related to authentication)
'request' => [
            'csrfParam' => '_csrf-frontend',
          'cookieValidationKey' => $params['cookieValidationKey'],
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
            'identityCookie' => [
            	'name' => '_identity',
              'httpOnly' => true,
        'domain' => $params['cookieDomain'],
            ],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the frontend
            'name' => '_session',
          'cookieParams' => [
          	'domain' => $params['cookieDomain'],
            'httpOnly' => true,
          ],
        ],

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
enchikiben, 2018-02-02
@Maxemp

front and back different domains? it is highly likely that the cookie is placed on the front.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question