2021-11-29 18:21:50 +03:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace frontend\modules\api\controllers;
|
|
|
|
|
|
|
|
|
|
use common\behaviors\GsCors;
|
2022-01-14 17:05:29 +03:00
|
|
|
|
use yii\filters\auth\CompositeAuth;
|
|
|
|
|
use yii\filters\auth\HttpBearerAuth;
|
|
|
|
|
use yii\filters\ContentNegotiator;
|
2021-11-29 18:21:50 +03:00
|
|
|
|
use yii\rest\Controller;
|
2022-01-14 17:05:29 +03:00
|
|
|
|
use yii\web\Response;
|
2021-11-29 18:21:50 +03:00
|
|
|
|
|
2023-04-12 13:14:37 +03:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @OA\Info(
|
|
|
|
|
* version="1.0.0",
|
|
|
|
|
* title="Документация Гильдия",
|
|
|
|
|
* description="Документация для работы с API",
|
|
|
|
|
*
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\PathItem(
|
|
|
|
|
* path="/api"
|
|
|
|
|
* ),
|
|
|
|
|
* @OA\Server(
|
|
|
|
|
* url="https://itguild.info/api",
|
|
|
|
|
* description="Основной сервер",
|
|
|
|
|
* ),
|
|
|
|
|
*
|
|
|
|
|
* @OA\Server(
|
|
|
|
|
* url="https://guild.loc/api",
|
|
|
|
|
* description="Локальный сервер",
|
|
|
|
|
* ),
|
|
|
|
|
*
|
|
|
|
|
* @OA\SecurityScheme(
|
|
|
|
|
* securityScheme="bearerAuth",
|
|
|
|
|
* in="header",
|
|
|
|
|
* name="Authorization",
|
|
|
|
|
* type="http",
|
|
|
|
|
* scheme="bearer",
|
|
|
|
|
* bearerFormat="JWT",
|
|
|
|
|
* ),
|
|
|
|
|
*/
|
2021-11-29 18:21:50 +03:00
|
|
|
|
class ApiController extends Controller
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public function behaviors()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'corsFilter' => [
|
|
|
|
|
'class' => GsCors::class,
|
|
|
|
|
'cors' => [
|
|
|
|
|
'Origin' => ['*'],
|
|
|
|
|
//'Access-Control-Allow-Credentials' => true,
|
|
|
|
|
'Access-Control-Allow-Headers' => [
|
2023-01-13 15:46:15 +03:00
|
|
|
|
'Access-Control-Allow-Origin',
|
2021-11-29 18:21:50 +03:00
|
|
|
|
'Content-Type',
|
2023-01-12 16:12:48 +03:00
|
|
|
|
'Access-Control-Allow-Headers',
|
2021-11-29 18:21:50 +03:00
|
|
|
|
'Authorization',
|
|
|
|
|
'X-Requested-With'
|
|
|
|
|
],
|
|
|
|
|
]
|
|
|
|
|
],
|
2022-01-14 17:05:29 +03:00
|
|
|
|
'authenticator' => [
|
|
|
|
|
'class' => CompositeAuth::class,
|
|
|
|
|
'authMethods' => [
|
|
|
|
|
HttpBearerAuth::class,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'class' => ContentNegotiator::className(),
|
|
|
|
|
'formats' => [
|
|
|
|
|
'application/json' => Response::FORMAT_JSON,
|
|
|
|
|
],
|
|
|
|
|
],
|
2021-11-29 18:21:50 +03:00
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|