From c4e81cef5453dc69db7810fc6b49331076457abe Mon Sep 17 00:00:00 2001 From: Chihiro Adachi <8196725+chihiro-adachi@users.noreply.github.com> Date: Fri, 16 Nov 2018 10:59:02 +0900 Subject: [PATCH 1/4] =?UTF-8?q?=E7=AE=A1=E7=90=86=E7=94=BB=E9=9D=A2URL?= =?UTF-8?q?=E3=81=AE=E8=AD=A6=E5=91=8A=E8=A1=A8=E7=A4=BA=E3=81=AE=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Eccube/Controller/Admin/AdminController.php | 7 +++++++ .../Admin/Setting/System/SecurityController.php | 5 +++++ src/Eccube/Form/Type/Install/Step3Type.php | 1 + src/Eccube/Resource/locale/message.ja.yml | 1 + src/Eccube/Resource/template/admin/index.twig | 9 ++++++++- tests/Eccube/Tests/Form/Type/Install/Step3TypeTest.php | 8 ++++++++ 6 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/Eccube/Controller/Admin/AdminController.php b/src/Eccube/Controller/Admin/AdminController.php index aacb93ed80e..1cf831aa7aa 100644 --- a/src/Eccube/Controller/Admin/AdminController.php +++ b/src/Eccube/Controller/Admin/AdminController.php @@ -79,6 +79,12 @@ public function index(Application $app, Request $request) } } + $is_danger_admin_url = false; + // 管理画面URLのチェック + if (isset($app['config']['admin_route']) && $app['config']['admin_route'] == 'admin') { + $is_danger_admin_url = true; + } + // 受注マスター検索用フォーム $searchOrderBuilder = $app['form.factory'] ->createBuilder('admin_search_order'); @@ -188,6 +194,7 @@ public function index(Application $app, Request $request) 'salesYesterday' => $salesYesterday, 'countNonStockProducts' => $countNonStockProducts, 'countCustomers' => $countCustomers, + 'is_danger_admin_url' => $is_danger_admin_url, )); } diff --git a/src/Eccube/Controller/Admin/Setting/System/SecurityController.php b/src/Eccube/Controller/Admin/Setting/System/SecurityController.php index e7c3c9536a5..22edd6b4eec 100644 --- a/src/Eccube/Controller/Admin/Setting/System/SecurityController.php +++ b/src/Eccube/Controller/Admin/Setting/System/SecurityController.php @@ -129,6 +129,11 @@ public function index(Application $app, Request $request) $form->get('force_ssl')->setData((bool)$app['config']['force_ssl']); } + // 管理画面URLのチェック + if (isset($app['config']['admin_route']) && $app['config']['admin_route'] == 'admin') { + $app->addWarning('admin.system.security.admin.url.warning', 'admin'); + } + return $app->render('Setting/System/security.twig', array( 'form' => $form->createView(), )); diff --git a/src/Eccube/Form/Type/Install/Step3Type.php b/src/Eccube/Form/Type/Install/Step3Type.php index 52b79d02aa5..0d00d796138 100644 --- a/src/Eccube/Form/Type/Install/Step3Type.php +++ b/src/Eccube/Form/Type/Install/Step3Type.php @@ -100,6 +100,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'max' => $this->app['config']['id_max_len'], )), new Assert\Regex(array('pattern' => '/\A\w+\z/')), + new Assert\NotEqualTo(array('value' => 'admin', 'message' => 'ディレクトリ名に「admin」を使用することはできません。')), ), )) ->add('admin_force_ssl', 'checkbox', array( diff --git a/src/Eccube/Resource/locale/message.ja.yml b/src/Eccube/Resource/locale/message.ja.yml index fd397f60e0e..f49482b6269 100644 --- a/src/Eccube/Resource/locale/message.ja.yml +++ b/src/Eccube/Resource/locale/message.ja.yml @@ -177,6 +177,7 @@ admin.content.cache.save.complete: キャッシュを削除しました。 admin.system.security.save.complete: セキュリティ設定を保存しました。 admin.system.security.route.dir.complete: 管理画面のURLを変更しましたので再ログインをしてください。 +admin.system.security.admin.url.warning: 管理画面URLは、セキュリティのため推測されにくいものを設定してください。 admin.system.authority.save.complete: 権限設定を保存しました。 diff --git a/src/Eccube/Resource/template/admin/index.twig b/src/Eccube/Resource/template/admin/index.twig index 75cff0b529a..510c3a65dd2 100644 --- a/src/Eccube/Resource/template/admin/index.twig +++ b/src/Eccube/Resource/template/admin/index.twig @@ -44,7 +44,14 @@ $(function(){ {% endblock javascript %} {% block main %} - + {% if is_danger_admin_url %} +