mirror of
https://github.com/elyby/accounts.git
synced 2024-12-02 03:31:05 +05:30
Обновлены роуты в соответствие с тем, как они в итоге будут прописаны в документации
В nginx добавлена конфигурация, отвечающая за проксирование сессионных запросов со старого домена Версия nginx обновлена с 1.9 до 1.11 В тестах сессионного сервера больше не используется генерация url
This commit is contained in:
parent
6e15522140
commit
8eb6a595c0
@ -9,7 +9,7 @@ $params = array_merge(
|
|||||||
return [
|
return [
|
||||||
'id' => 'accounts-site-api',
|
'id' => 'accounts-site-api',
|
||||||
'basePath' => dirname(__DIR__),
|
'basePath' => dirname(__DIR__),
|
||||||
'bootstrap' => ['log', 'authserver', 'sessionserver'],
|
'bootstrap' => ['log', 'authserver'],
|
||||||
'controllerNamespace' => 'api\controllers',
|
'controllerNamespace' => 'api\controllers',
|
||||||
'params' => $params,
|
'params' => $params,
|
||||||
'components' => [
|
'components' => [
|
||||||
@ -56,7 +56,7 @@ return [
|
|||||||
'class' => \api\modules\authserver\Module::class,
|
'class' => \api\modules\authserver\Module::class,
|
||||||
'baseDomain' => $params['authserverDomain'],
|
'baseDomain' => $params['authserverDomain'],
|
||||||
],
|
],
|
||||||
'sessionserver' => [
|
'session' => [
|
||||||
'class' => \api\modules\session\Module::class,
|
'class' => \api\modules\session\Module::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -7,4 +7,9 @@ return [
|
|||||||
'/oauth2/v1/<action>' => 'oauth/<action>',
|
'/oauth2/v1/<action>' => 'oauth/<action>',
|
||||||
|
|
||||||
'/account/v1/info' => 'identity-info/index',
|
'/account/v1/info' => 'identity-info/index',
|
||||||
|
|
||||||
|
'/minecraft/session/join' => 'session/session/join',
|
||||||
|
'/minecraft/session/legacy/join' => 'session/session/join-legacy',
|
||||||
|
'/minecraft/session/hasJoined' => 'session/session/has-joined',
|
||||||
|
'/minecraft/session/legacy/hasJoined' => 'session/session/has-joined-legacy',
|
||||||
];
|
];
|
||||||
|
@ -4,6 +4,7 @@ namespace api\modules\authserver;
|
|||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\BootstrapInterface;
|
use yii\base\BootstrapInterface;
|
||||||
use yii\base\InvalidConfigException;
|
use yii\base\InvalidConfigException;
|
||||||
|
use yii\web\NotFoundHttpException;
|
||||||
|
|
||||||
class Module extends \yii\base\Module implements BootstrapInterface {
|
class Module extends \yii\base\Module implements BootstrapInterface {
|
||||||
|
|
||||||
@ -23,6 +24,16 @@ class Module extends \yii\base\Module implements BootstrapInterface {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function beforeAction($action) {
|
||||||
|
if (!parent::beforeAction($action)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->checkHost();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \yii\base\Application $app the application currently running
|
* @param \yii\base\Application $app the application currently running
|
||||||
*/
|
*/
|
||||||
@ -40,4 +51,17 @@ class Module extends \yii\base\Module implements BootstrapInterface {
|
|||||||
Yii::info($message, 'legacy-authserver');
|
Yii::info($message, 'legacy-authserver');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Поскольку это legacy метод и документации в новой среде для него не будет,
|
||||||
|
* нет смысла выставлять на показ внутренние url, так что ограничиваем доступ
|
||||||
|
* только для заходов по старому домену
|
||||||
|
*
|
||||||
|
* @throws NotFoundHttpException
|
||||||
|
*/
|
||||||
|
protected function checkHost() {
|
||||||
|
if (Yii::$app->request->getHostInfo() !== $this->baseDomain) {
|
||||||
|
throw new NotFoundHttpException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,24 +2,13 @@
|
|||||||
namespace api\modules\session;
|
namespace api\modules\session;
|
||||||
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\BootstrapInterface;
|
|
||||||
|
|
||||||
class Module extends \yii\base\Module implements BootstrapInterface {
|
class Module extends \yii\base\Module {
|
||||||
|
|
||||||
public $id = 'session';
|
public $id = 'session';
|
||||||
|
|
||||||
public $defaultRoute = 'session';
|
public $defaultRoute = 'session';
|
||||||
|
|
||||||
/**
|
|
||||||
* @param \yii\base\Application $app the application currently running
|
|
||||||
*/
|
|
||||||
public function bootstrap($app) {
|
|
||||||
$app->getUrlManager()->addRules([
|
|
||||||
// TODO: define normal routes
|
|
||||||
//$this->baseDomain . '/' . $this->id . '/auth/<action>' => $this->id . '/authentication/<action>',
|
|
||||||
], false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function info($message) {
|
public static function info($message) {
|
||||||
Yii::info($message, 'session');
|
Yii::info($message, 'session');
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM nginx:1.9
|
FROM nginx:1.11
|
||||||
|
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
COPY nginx.conf /etc/nginx/nginx.conf
|
||||||
COPY account.ely.by.conf.template /etc/nginx/conf.d/account.ely.by.conf.template
|
COPY account.ely.by.conf.template /etc/nginx/conf.d/account.ely.by.conf.template
|
||||||
|
@ -4,7 +4,6 @@ server {
|
|||||||
set $root_path '/var/www/html';
|
set $root_path '/var/www/html';
|
||||||
set $api_path '${root_path}/api/web';
|
set $api_path '${root_path}/api/web';
|
||||||
set $frontend_path '${root_path}/frontend/dist';
|
set $frontend_path '${root_path}/frontend/dist';
|
||||||
set $authserver_host '${AUTHSERVER_HOST}';
|
|
||||||
|
|
||||||
root $root_path;
|
root $root_path;
|
||||||
charset utf-8;
|
charset utf-8;
|
||||||
@ -12,15 +11,19 @@ server {
|
|||||||
etag on;
|
etag on;
|
||||||
|
|
||||||
set $request_url $request_uri;
|
set $request_url $request_uri;
|
||||||
if ($host = $authserver_host) {
|
set $host_with_uri '${host}${request_uri}';
|
||||||
|
|
||||||
|
if ($host_with_uri ~* '^${AUTHSERVER_HOST}/auth') {
|
||||||
set $request_url '/api/authserver${request_uri}';
|
set $request_url '/api/authserver${request_uri}';
|
||||||
|
rewrite ^/auth /api/authserver$uri last;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($host_with_uri ~* '^${AUTHSERVER_HOST}/session') {
|
||||||
|
set $request_url '/api/minecraft${request_uri}';
|
||||||
|
rewrite ^/session /api/minecraft$uri last;
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
if ($host = $authserver_host) {
|
|
||||||
rewrite ^ /api/authserver$uri last;
|
|
||||||
}
|
|
||||||
|
|
||||||
alias $frontend_path;
|
alias $frontend_path;
|
||||||
index index.html;
|
index index.html;
|
||||||
try_files $uri /index.html =404;
|
try_files $uri /index.html =404;
|
||||||
|
@ -9,22 +9,22 @@ use yii\codeception\BasePage;
|
|||||||
class SessionServerRoute extends BasePage {
|
class SessionServerRoute extends BasePage {
|
||||||
|
|
||||||
public function join($params) {
|
public function join($params) {
|
||||||
$this->route = ['sessionserver/session/join'];
|
$this->route = '/minecraft/session/join';
|
||||||
$this->actor->sendPOST($this->getUrl(), $params);
|
$this->actor->sendPOST($this->getUrl(), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function joinLegacy(array $params) {
|
public function joinLegacy(array $params) {
|
||||||
$this->route = ['sessionserver/session/join-legacy'];
|
$this->route = '/minecraft/session/legacy/join';
|
||||||
$this->actor->sendGET($this->getUrl(), $params);
|
$this->actor->sendGET($this->getUrl(), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasJoined(array $params) {
|
public function hasJoined(array $params) {
|
||||||
$this->route = ['sessionserver/session/has-joined'];
|
$this->route = '/minecraft/session/hasJoined';
|
||||||
$this->actor->sendGET($this->getUrl(), $params);
|
$this->actor->sendGET($this->getUrl(), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function hasJoinedLegacy(array $params) {
|
public function hasJoinedLegacy(array $params) {
|
||||||
$this->route = ['sessionserver/session/has-joined-legacy'];
|
$this->route = '/minecraft/session/legacy/hasJoined';
|
||||||
$this->actor->sendGET($this->getUrl(), $params);
|
$this->actor->sendGET($this->getUrl(), $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user