Answer the question
In order to leave comments, you need to log in
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;
}
Answer the question
In order to leave comments, you need to log in
Most likely your server is not on localhost, output somewhere $_SERVER['SERVER_ADDR']
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question