fix #4274 【システム】管理画面URLを変更している場合、ユーザーグループのアクセスルールが正しく機能しない#4395
Open
kaburk wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
管理画面URL(.env の ADMIN_PREFIX / BASER_CORE_PREFIX)を変更している環境で、ユーザーグループのアクセスルール(Permissions)が正しくマッチするようにすることを目的としたPRです。権限URLがDB上では標準プレフィックス(/baser/admin 等)で保存されている前提を、実際のプレフィックスへ変換して照合する方向に寄せています。
Changes:
- URL照合時のプレフィックス変換ロジックを
checkGroup()側からconvertRegexUrl()側へ移動 - DB保存の標準プレフィックス(
/baser/admin,/baser/api/admin)→ 実プレフィックスへの変換処理を追加 - 変換仕様を検証するユニットテストを追加
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| plugins/baser-core/src/Service/PermissionsService.php | 権限URLの正規表現化処理で、標準プレフィックスを実プレフィックスへ変換するよう変更 |
| plugins/baser-core/tests/TestCase/Service/PermissionsServiceTest.php | 標準プレフィックス→実プレフィックス変換のテストケースを追加 |
Comment on lines
+549
to
+563
| $baserCorePrefix = BcUtil::getBaserCorePrefix(); | ||
| $adminPrefix = BcUtil::getAdminPrefix(); | ||
| $apiPrefix = Configure::read('BcApp.apiPrefix'); | ||
| // DB に保存された標準プレフィックス(/baser/api/admin, /baser/admin)を | ||
| // .env の設定値に基づく実際のプレフィックスに変換する | ||
| $url = preg_replace( | ||
| [ | ||
| '/^\/baser\/' . preg_quote($apiPrefix, '/') . '\/admin/', | ||
| '/^\/baser\/admin/', | ||
| ], | ||
| [ | ||
| '/' . $baserCorePrefix . '/' . $apiPrefix . '/' . $adminPrefix, | ||
| '/' . $baserCorePrefix . '/' . $adminPrefix, | ||
| ], | ||
| $url |
| $this->assertEquals($expected, $result); | ||
|
|
||
| $url = '/baser/api/admin/baser-core/contents/index.json'; | ||
| $expected = '/^\/' . preg_quote($baserCorePrefix . '/' . $apiPrefix . '/' . $adminPrefix . '/baser-core/contents/index.json', '/') . '$/is'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
よろしくお願いします。