Skip to content

Commit

Permalink
管理画面SSL設定を削除
Browse files Browse the repository at this point in the history
  • Loading branch information
seto1 committed Jul 2, 2024
1 parent a660aaf commit 863610b
Show file tree
Hide file tree
Showing 14 changed files with 7 additions and 193 deletions.
1 change: 0 additions & 1 deletion config/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export INSTALL_MODE="true"
export USE_DEBUG_KIT="false"
export SITE_URL="https://localhost/"
export SSL_URL="https://localhost/"
export ADMIN_SSL="true"
export ADMIN_PREFIX="admin"
export BASER_CORE_PREFIX="baser"
export SQL_LOG="false"
Expand Down
5 changes: 0 additions & 5 deletions plugins/baser-core/config/setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,6 @@
*/
'passwordRequestAllowTime' => 1440,

/**
* 管理画面のSSL
*/
'adminSsl' => filter_var(env('ADMIN_SSL', true), FILTER_VALIDATE_BOOLEAN),

/**
* エディタ
*/
Expand Down
8 changes: 0 additions & 8 deletions plugins/baser-core/src/BaserCorePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,6 @@ public function middleware(MiddlewareQueue $middlewareQueue): MiddlewareQueue
->add(new BcFrontMiddleware())
->add(new BcRedirectSubSiteMiddleware());

if (Configure::read('BcApp.adminSsl') && !BcUtil::isConsole() && BcUtil::isAdminSystem() && BcUtil::isInstalled()) {
$config = ['redirect' => false];
if(filter_var(env('TRUST_PROXY', false))) {
$config['trustedProxies'] = !empty($_SERVER['HTTP_X_FORWARDED_FOR'])? [$_SERVER['HTTP_X_FORWARDED_FOR']] : [];
}
$middlewareQueue->add(new HttpsEnforcerMiddleware($config));
}

// APIへのアクセスの場合、セッションによる認証以外は、CSRFを利用しない設定とする
$ref = new ReflectionClass($middlewareQueue);
$queue = $ref->getProperty('queue');
Expand Down
10 changes: 0 additions & 10 deletions plugins/baser-core/src/Model/Table/SiteConfigsTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ public function validationDefault(Validator $validator): Validator
*/
public function validationKeyValue(Validator $validator): Validator
{
$validator->setProvider('siteConfig', 'BaserCore\Model\Validation\SiteConfigValidation');

$validator
->scalar('email')
->email('email', 255, __d('baser_core', '管理者メールアドレスの形式が不正です。'))
Expand All @@ -91,14 +89,6 @@ public function validationKeyValue(Validator $validator): Validator
->scalar('ssl_url')
->regex('ssl_url', '/^(http|https):/', __d('baser_core', 'WebサイトURLはURLの形式を入力してください。'))
->notEmptyString('ssl_url', __d('baser_core', 'WebサイトURLを入力してください。'));
$validator
->scalar('admin_ssl')
->add('admin_ssl', [
'adminSSlSslUrlExists' => [
'rule' => 'sslUrlExists',
'provider' => 'siteConfig',
'message' => __d('baser_core', '管理画面をSSLで利用するには、SSL用のWebサイトURLを入力してください。')
]]);
return $validator;
}

Expand Down
40 changes: 0 additions & 40 deletions plugins/baser-core/src/Model/Validation/SiteConfigValidation.php

This file was deleted.

3 changes: 0 additions & 3 deletions plugins/baser-core/src/Service/SiteConfigsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function get(): SiteConfig
'mode' => Configure::read('debug'),
'site_url' => Configure::read('BcEnv.siteUrl'),
'ssl_url' => Configure::read('BcEnv.sslUrl'),
'admin_ssl' => (int)Configure::read('BcApp.adminSsl'),
]), ['validate' => 'keyValue']);
}
return $this->entity;
Expand Down Expand Up @@ -141,14 +140,12 @@ public function update(array $postData)
if (isset($siteConfig->mode)) $this->putEnv('DEBUG', ($siteConfig->mode)? 'true' : 'false');
if (isset($siteConfig->site_url)) $this->putEnv('SITE_URL', $siteConfig->site_url);
if (isset($siteConfig->ssl_url)) $this->putEnv('SSL_URL', $siteConfig->ssl_url);
if (isset($siteConfig->admin_ssl)) $this->putEnv('ADMIN_SSL', ($siteConfig->admin_ssl)? 'true' : 'false');
}

$siteConfigArray = $siteConfig->toArray();
unset($siteConfigArray['mode'],
$siteConfigArray['site_url'],
$siteConfigArray['ssl_url'],
$siteConfigArray['admin_ssl'],
$siteConfigArray['dummy-site_url'],
$siteConfigArray['dummy-ssl_url']
);
Expand Down

This file was deleted.

1 change: 0 additions & 1 deletion plugins/baser-core/tests/TestCase/PluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public function testBootStrap(): void
export INSTALL_MODE="false"
export SITE_URL="https://localhost/"
export SSL_URL="https://localhost/"
export ADMIN_SSL="true"
export ADMIN_PREFIX="admin"
export BASER_CORE_PREFIX="baser"
export SQL_LOG="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public function testGet()
$this->assertArrayHasKey('mode', $result);
$this->assertArrayHasKey('site_url', $result);
$this->assertArrayHasKey('ssl_url', $result);
$this->assertArrayHasKey('admin_ssl', $result);
}

/**
Expand Down
36 changes: 2 additions & 34 deletions plugins/bc-admin-third/src/js/admin/site_configs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,7 @@

$(function () {

var script = $("#AdminSiteConfigsFormScript");
var isAdminSsl = script.attr('data-isAdminSsl');

$("#BtnSave").click(function () {
if (!isAdminSslCheck(isAdminSsl)) {
return false;
}
$.bcUtil.showLoader();
});

Expand All @@ -25,7 +19,7 @@ $(function () {

// SMTP送信テスト
$("#BtnCheckSendmail").click(function () {
if (!confirm(bcI18n.confirmMessage2)) {
if (!confirm(bcI18n.confirmMessage1)) {
return false;
}
$.bcToken.check(function () {
Expand All @@ -47,7 +41,7 @@ $(function () {
} else {
errorMessage = errorThrown;
}
$("#ResultCheckSendmail").html(bcI18n.alertMessage2 + errorMessage);
$("#ResultCheckSendmail").html(bcI18n.alertMessage1 + errorMessage);
},
complete: function () {
$("#ResultCheckSendmail").show();
Expand All @@ -58,32 +52,6 @@ $(function () {
return false;
});

/**
* 管理画面SSLチェック
* @param isAdminSsl
* @returns {boolean}
*/
function isAdminSslCheck(isAdminSsl) {
if (isAdminSsl === "0" && $("input[name='admin_ssl']:checked").val() === "1") {
if (!$("#SiteConfigSslUrl").val()) {
alert(bcI18n.alertMessage1);
window.location.hash = 'ssl-url';
return false;
}
$.bcConfirm.show({
title: bcI18n.confirmTitle1,
message: bcI18n.confirmMessage1,
defaultCancel: true,
ok: function () {
$.bcUtil.showLoader();
$("#SiteConfigFormForm").submit();
}
});
return false;
}
return true;
}

/**
* エディタ切替時イベント
*/
Expand Down
29 changes: 3 additions & 26 deletions plugins/bc-admin-third/templates/Admin/SiteConfigs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@
$this->BcAdmin->setTitle(__d('baser_core', 'システム基本設定'));
$this->BcAdmin->setHelp('site_configs_form');
$this->BcBaser->i18nScript([
'alertMessage1' => __d('baser_core', '管理システムをSSLに切り替える場合には、SSL用のURLを登録してください。'),
'alertMessage2' => __d('baser_core', 'テストメールを送信に失敗しました。'),
'confirmMessage1' => __d('baser_core', '管理システムをSSLに切り替えようとしています。よろしいですか?<br><br>サーバがSSLに対応していない場合、管理システムを表示する事ができなくなってしまいますのでご注意ください。<br><br>もし、表示する事ができなくなってしまった場合は、 /app/Config/install.php の、 BcEnv.sslUrl の値を調整するか、BcApp.adminSsl の値を false に書き換えて復旧してください。'),
'confirmMessage2' => __d('baser_core', 'テストメールを送信します。いいですか?'),
'alertMessage1' => __d('baser_core', 'テストメールの送信に失敗しました。'),
'confirmMessage1' => __d('baser_core', 'テストメールを送信します。よろしいですか?'),
'infoMessage1' => __d('baser_core', 'テストメールを送信しました。'),
'confirmTitle1' => __d('baser_core', '管理システムSSL設定確認')
], ['escape' => false]);
$this->BcBaser->js('admin/site_configs/index.bundle', false, ['id' => 'AdminSiteConfigsFormScript',
'data-isAdminSsl' => (string)$siteConfig->admin_ssl
]);
$this->BcBaser->js('admin/site_configs/index.bundle', false);
?>


Expand Down Expand Up @@ -139,25 +135,6 @@
</div>
<div class="bca-collapse" id="formAdminSettingBody" data-bca-state="">
<table class="form-table bca-form-table section" data-bca-table-type="type2">
<tr>
<th class="col-head bca-form-table__label">
<?php echo $this->BcAdminForm->label('admin_ssl', __d('baser_core', '管理画面SSL設定')) ?>
</th>
<td class="col-input bca-form-table__input">
<?php echo $this->BcAdminForm->control('admin_ssl', [
'type' => 'radio',
'options' => $this->BcText->booleanDoList(__d('baser_core', 'SSL通信を利用')),
'separator' => ' ',
'legend' => false,
'disabled' => !$isWritableEnv
]) ?>
<i class="bca-icon--question-circle bca-help"></i>
<div class="bca-helptext">
<?php echo __d('baser_core', '管理者ページでSSLを利用する場合は、事前にSSLの申込、設定が必要です。<br>また、SSL用のWebサイトURLの指定が必要です。') ?>
</div>
<?php echo $this->BcAdminForm->error('admin_ssl') ?>
</td>
</tr>
<tr>
<th class="col-head bca-form-table__label">
<?php echo $this->BcAdminForm->label('admin_list_num', __d('baser_core', '管理画面テーマ')) ?>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 863610b

Please sign in to comment.