R
R
Ramzesh Halifionakis2019-10-29 19:39:12
Yii
Ramzesh Halifionakis, 2019-10-29 19:39:12

How to organize basic auth in yii2 for third party payment service?

Good day!
I want to tie a third-party payment system service to the site. The site is written in yii2.
After the payment is initialized, the payment service will knock on the endpoint with Basic authorization in the header.
Password and login are fixed.
As far as I know, basic auth can be configured in the behaviors of the controller. In the case of user authorization, implemented from IdentityInterface, there will be no problems. I just need to check static logins with a password that are not tied to a user.
How can you concisely solve the problem?
PS I also want to set a filter by ip, because. I initially know the list of ip from which they will knock on this controller.
I use the code in the controller:

public function behaviors()
    {
        $behaviors = parent::behaviors();

        $behaviors['access'] = [
            'class' => AccessControl::className(),
            'rules' => [
                [
                    'allow' => true,
                    'ips' => $this->params['ips'] //массив с разрешенными ip, внутри есть 127.0.0.1
                ]
            ],
        ];
        return $behaviors;
    }

For some reason, with this filter, he does not let me in from the localhost. What am I doing wrong?
Thanks in advance for your reply!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
enchikiben, 2019-11-01
@EnChikiben

Most likely your server is not on localhost, output somewhere $_SERVER['SERVER_ADDR']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question