A
A
Artem2017-05-12 15:03:39
Yii
Artem, 2017-05-12 15:03:39

Exception for as BeforeRequest yii2?

Hello!
In config/main.php there is a block like this:

'as beforeRequest' => [
        'class' => 'yii\filters\AccessControl',
        'rules' => [
            [
                'actions' => ['login', 'error'],
                'allow' => true,
            ],
            [
                'allow' => true,
                'roles' => ['admin'],
            ],
        ],
    ],

Also in the application, I have an api module that does not store sessions, and authorization must take place on each call. But each request to the api is wrapped by this beforeRequest handler, and I, in return for the necessary form of basic http authorization, receive an html response with an authorization form in the application itself. Can you please tell me how to get around this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-05-12
@proudmore

You need to create an exception for AccessControl, for this you need to specify in the except parameter a list of actions to which the filter does not need to be applied

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question