author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
---|---|---|---|---|---|---|---|---|---|
95,144 |
06.12.2020 16:19:22
| -3,600 |
32514a0f782ee1fc3ec0321cbc1c031dfc2870d8
|
Working on YAML migrations
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"api-platform/core\": \"^2.5\",\n\"babdev/pagerfanta-bundle\": \"^2.5\",\n\"beberlei/doctrineextensions\": \"^1.2\",\n+ \"bobdenotter/yaml-migrations\": \"^1.0\",\n\"bolt/common\": \"^3.0\",\n\"cocur/slugify\": \"^4.0\",\n\"composer/composer\": \"^2.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "symfony.lock",
"new_path": "symfony.lock",
"diff": "\"bobdenotter/weatherwidget\": {\n\"version\": \"1.1.1\"\n},\n+ \"bobdenotter/yaml-migrations\": {\n+ \"version\": \"dev-main\"\n+ },\n+ \"bolt/binary-chromedriver\": {\n+ \"version\": \"dev-master\"\n+ },\n\"bolt/common\": {\n\"version\": \"2.1.5\"\n},\n\"justinrainbow/json-schema\": {\n\"version\": \"5.2.9\"\n},\n+ \"kevinlebrun/colors.php\": {\n+ \"version\": \"0.4.1\"\n+ },\n\"knplabs/doctrine-behaviors\": {\n\"version\": \"v2.0.1\"\n},\n\"myclabs/deep-copy\": {\n\"version\": \"1.9.5\"\n},\n+ \"nategood/commando\": {\n+ \"version\": \"0.4.0\"\n+ },\n\"nelmio/cors-bundle\": {\n\"version\": \"1.5\",\n\"recipe\": {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "yaml-migrations/checkpoint.txt",
"diff": "+1.0.0\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "yaml-migrations/config.yaml",
"diff": "+# location of the files used for the migrations\n+migrations: yaml-migrations\n+\n+# Folder of the source files\n+source: config\n+\n+# Target folder of the processed files. Set this to the same as 'source' to overwrite\n+target: config\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "yaml-migrations/m-2020-12-06-security.yaml",
"diff": "+# Adding the new security config for Bolt 4.2.0\n+file: packages/security.yaml\n+since: 4.2.0\n+\n+add:\n+ security:\n+ firewalls:\n+ main:\n+ remember_me:\n+ remember_me_parameter: login[remember_me]\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "yaml-migrations/m-2020-12-06-security_checker.yaml",
"diff": "+# Adding the new security_checker settings for Bolt 4.2.0\n+file: packages/security_checkerx.yaml\n+since: 4.2.0\n+\n+add:\n+ services:\n+ SensioLabs\\Security\\SecurityChecker:\n+ public: false\n+\n+ SensioLabs\\Security\\Command\\SecurityCheckerCommand:\n+ arguments: ['@SensioLabs\\Security\\SecurityChecker']\n+ tags:\n+ - { name: console.command }\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "yaml-migrations/m-2020-12-06-services.yaml",
"diff": "+# Adding the new services for Bolt 4.2.0\n+file: services.yaml\n+since: 4.2.0\n+\n+add:\n+ services:\n+ _instanceof:\n+ Bolt\\Menu\\ExtensionBackendMenuInterface:\n+ tags: [ 'bolt.extension_backend_menu' ]\n+ Bolt\\Event\\Listener\\UserAvatarLoadListener:\n+ tags:\n+ - { name: doctrine.event_listener, event: postLoad }\n+ Bolt\\Menu\\BackendMenuBuilder:\n+ arguments:\n+ - !tagged_iterator bolt.extension_backend_menu\n+ Bolt\\Validator\\ContentValidatorInterface: '@Bolt\\Validator\\ContentValidator'\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "yaml-migrations/m-2020-12-06-twig.yaml",
"diff": "+# Adding the new Twig config for Bolt 4.2.0\n+file: packages/twig.yaml\n+since: 4.2.0\n+\n+add:\n+ twig:\n+ globals:\n+ 'defaultLocale': '%locale%'\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Working on YAML migrations
|
95,144 |
28.12.2020 18:38:42
| -3,600 |
6898e5b325f858fb379297f2dfa74c9527e71453
|
Put "Reset Password" functionality on Backend controller collection, so it doesn't need changes in routing
|
[
{
"change_type": "MODIFY",
"old_path": "config/packages/security.yaml",
"new_path": "config/packages/security.yaml",
"diff": "@@ -40,6 +40,7 @@ security:\naccess_control:\n# this is a catch-all for the admin area\n# additional security lives in the controllers\n- - { path: '^%bolt.backend_url%/(login||resetpassword|reset-password)$', roles: IS_AUTHENTICATED_ANONYMOUSLY }\n+ - { path: '^%bolt.backend_url%/login$', roles: IS_AUTHENTICATED_ANONYMOUSLY }\n+ - { path: '^%bolt.backend_url%/reset-password', roles: IS_AUTHENTICATED_ANONYMOUSLY }\n- { path: '^%bolt.backend_url%', roles: ROLE_ADMIN }\n- { path: '^/(%app_locales%)%bolt.backend_url%', roles: ROLE_ADMIN }\n"
},
{
"change_type": "MODIFY",
"old_path": "config/routes/bolt.yaml",
"new_path": "config/routes/bolt.yaml",
"diff": "@@ -19,11 +19,6 @@ controllers:\nresource: '../../src/Controller/ImageController.php'\ntype: annotation\n-# Reset Password Form\n-reset_password:\n- resource: '../../src/Controller/ResetPasswordController.php'\n- type: annotation\n-\n# Routes added by Extensions get added here, by Bolt\\Extension\\RoutesLoader\nextensions:\nresource: .\n"
},
{
"change_type": "RENAME",
"old_path": "src/Controller/ResetPasswordController.php",
"new_path": "src/Controller/Backend/ResetPasswordController.php",
"diff": "declare(strict_types=1);\n-namespace Bolt\\Controller;\n+namespace Bolt\\Controller\\Backend;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\User;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Put "Reset Password" functionality on Backend controller collection, so it doesn't need changes in routing
|
95,144 |
28.12.2020 18:41:57
| -3,600 |
ad62ac9d2987525257b8dbb085aa3cdbffc7ffdd
|
Tweaking buttons
|
[
{
"change_type": "MODIFY",
"old_path": "templates/reset_password/request.html.twig",
"new_path": "templates/reset_password/request.html.twig",
"diff": "{{ 'reset_password.request_description'|trans }}\n</div>\n<button class=\"btn btn-primary\">{{ 'reset_password.request_send'|trans }}</button>\n- <a href=\"{{ path('bolt_login') }}\" class=\"btn btn-primary\">\n+ <a href=\"{{ path('bolt_login') }}\" class=\"btn btn-light float-right\">\n<i class=\"fas fa-sign-in-alt\"></i>\n{{ 'reset_password.back-to-login'|trans }}\n</a>\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/security/login.html.twig",
"new_path": "templates/security/login.html.twig",
"diff": "<i class=\"fas fa-sign-in-alt\" aria-hidden=\"true\"></i>\n{{- 'action.log_in'|trans -}}\n</button>\n- <a href=\"{{ path('bolt_forgot_password_request') }}\" class=\"float-right\">\n+ <a href=\"{{ path('bolt_forgot_password_request') }}\" class=\"btn btn-light float-right\">\n<i class=\"fas fa-question-circle\"></i>\n{{ 'login.forgotpassword'|trans }}\n</a>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Tweaking buttons
|
95,144 |
29.12.2020 20:01:41
| -3,600 |
330f36631794e77b2472486f1879856d08582e15
|
Updating YAML migrations
|
[
{
"change_type": "MODIFY",
"old_path": "yaml-migrations/config.yaml",
"new_path": "yaml-migrations/config.yaml",
"diff": "# location of the files used for the migrations\n-migrations: yaml-migrations\n+migrations: vendor/bolt/core/yaml-migrations\n+\n+# location of the checkpoint\n+checkpoint: config/checkpoint.txt\n# Folder of the source files\nsource: config\n"
},
{
"change_type": "MODIFY",
"old_path": "yaml-migrations/m_2020-12-06-security_checker.yaml",
"new_path": "yaml-migrations/m_2020-12-06-security_checker.yaml",
"diff": "# Adding the new security_checker settings for Bolt 4.2.0\n-file: packages/security_checkerx.yaml\n+file: packages/security_checker.yaml\nsince: 4.2.0\nadd:\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Updating YAML migrations
|
95,144 |
30.12.2020 10:37:14
| -3,600 |
920b98db014d10f7bab770cff9aa04bdbd012a79
|
Preparing 4.2.0-beta.3
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/version.js",
"new_path": "assets/js/version.js",
"diff": "// generated by genversion\n-export const version = '4.1.99.2';\n+export const version = '4.1.99.3';\n"
},
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.99.2\",\n+ \"version\": \"4.1.99.3\",\n\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n}\n},\n\"@babel/types\": {\n- \"version\": \"7.12.10\",\n- \"resolved\": \"https://registry.npmjs.org/@babel/types/-/types-7.12.10.tgz\",\n- \"integrity\": \"sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw==\",\n+ \"version\": \"7.12.12\",\n+ \"resolved\": \"https://registry.npmjs.org/@babel/types/-/types-7.12.12.tgz\",\n+ \"integrity\": \"sha512-lnIX7piTxOH22xE7fDXDbSHg9MM1/6ORnafpJmov5rs0kX5g4BZxeXNJLXsMRiO0U5Rb8/FvMS6xlTnTHvxonQ==\",\n\"dev\": true,\n\"requires\": {\n\"@babel/helper-validator-identifier\": \"^7.12.11\",\n\"@babel/helper-compilation-targets\": \"^7.12.5\",\n\"@babel/helper-module-imports\": \"^7.12.5\",\n\"@babel/helper-plugin-utils\": \"^7.10.4\",\n- \"@babel/helper-validator-option\": \"^7.12.11\",\n+ \"@babel/helper-validator-option\": \"^7.12.1\",\n\"@babel/plugin-proposal-async-generator-functions\": \"^7.12.1\",\n\"@babel/plugin-proposal-class-properties\": \"^7.12.1\",\n\"@babel/plugin-proposal-dynamic-import\": \"^7.12.1\",\n\"@babel/plugin-transform-arrow-functions\": \"^7.12.1\",\n\"@babel/plugin-transform-async-to-generator\": \"^7.12.1\",\n\"@babel/plugin-transform-block-scoped-functions\": \"^7.12.1\",\n- \"@babel/plugin-transform-block-scoping\": \"^7.12.11\",\n+ \"@babel/plugin-transform-block-scoping\": \"^7.12.1\",\n\"@babel/plugin-transform-classes\": \"^7.12.1\",\n\"@babel/plugin-transform-computed-properties\": \"^7.12.1\",\n\"@babel/plugin-transform-destructuring\": \"^7.12.1\",\n\"integrity\": \"sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw==\",\n\"dev\": true,\n\"requires\": {\n- \"@babel/helper-validator-identifier\": \"^7.12.11\",\n+ \"@babel/helper-validator-identifier\": \"^7.10.4\",\n\"lodash\": \"^4.17.19\",\n\"to-fast-properties\": \"^2.0.0\"\n}\n}\n},\n\"caniuse-lite\": {\n- \"version\": \"1.0.30001165\",\n- \"resolved\": \"https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001165.tgz\",\n- \"integrity\": \"sha512-8cEsSMwXfx7lWSUMA2s08z9dIgsnR5NAqjXP23stdsU3AUWkCr/rr4s4OFtHXn5XXr6+7kam3QFVoYyXNPdJPA==\"\n+ \"version\": \"1.0.30001171\",\n+ \"resolved\": \"https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001171.tgz\",\n+ \"integrity\": \"sha512-5Alrh8TTYPG9IH4UkRqEBZoEToWRLvPbSQokvzSz0lii8/FOWKG4keO1HoYfPWs8IF/NH/dyNPg1cmJGvV3Zlg==\"\n},\n\"capture-exit\": {\n\"version\": \"2.0.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.99.2\",\n+ \"version\": \"4.1.99.3\",\n\"homepage\": \"https://boltcms.io\",\n\"author\": \"Bob den Otter <bob@twokings.nl> (https://boltcms.io)\",\n\"license\": \"MIT\",\n\"bootbox\": \"^5.5.2\",\n\"bootstrap\": \"^4.5.3\",\n\"browserslist\": \"^4.16.0\",\n- \"caniuse-lite\": \"^1.0.30001165\",\n+ \"caniuse-lite\": \"^1.0.30001171\",\n\"codemirror\": \"^5.58.3\",\n\"dropzone\": \"^5.7.2\",\n\"flagpack\": \"^1.0.5\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Preparing 4.2.0-beta.3
|
95,200 |
30.12.2020 11:48:19
| -3,600 |
8f8fe73060f63a3929da25cd33893a6a57580e93
|
Update routes.yaml
Fixed wrong path to routing docs
|
[
{
"change_type": "MODIFY",
"old_path": "config/routes.yaml",
"new_path": "config/routes.yaml",
"diff": "# This file defines routes for the frontend and control panel of your Bolt\n# website. Check below for examples, or read the documentation at\n-# https://docs.bolt.cm/configuration/routing\n+# https://docs.bolt.cm/4.0/routing\n# ------------------------------------------------------------------------------\n# Place your own routes here, that have a HIGHER priority than the default routes.\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update routes.yaml
Fixed wrong path to routing docs
|
95,144 |
03.01.2021 10:09:25
| -3,600 |
2e68668b36715ba6705671a81c746a4a987ee65d
|
Replace (abandoned) `peterkahl/country-code-to-emoji-flag` package with fork
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"api-platform/core\": \"^2.5\",\n\"babdev/pagerfanta-bundle\": \"^2.5\",\n\"beberlei/doctrineextensions\": \"^1.2\",\n+ \"bobdenotter/country-code-to-emoji-flag\": \"^2.0\",\n\"bolt/common\": \"^2.1.10\",\n\"cocur/slugify\": \"^4.0\",\n\"composer/composer\": \"^2.0\",\n\"miljar/php-exif\": \"^0.6.4\",\n\"nelmio/cors-bundle\": \"^2.1\",\n\"nesbot/carbon\": \"^2.39\",\n- \"peterkahl/country-code-to-emoji-flag\": \"^1.2\",\n\"php-translation/symfony-bundle\": \"^0.12\",\n\"phpdocumentor/reflection-docblock\": \"^4.3\",\n\"psr/event-dispatcher\": \"^1.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Utils/LocaleHelper.php",
"new_path": "src/Utils/LocaleHelper.php",
"diff": "@@ -4,9 +4,9 @@ declare(strict_types=1);\nnamespace Bolt\\Utils;\n+use bobdenotter\\flagMaster\\flagMaster;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Repository\\ContentRepository;\n-use peterkahl\\flagMaster\\flagMaster;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\Intl\\Exception\\MissingResourceException;\nuse Symfony\\Component\\Intl\\Locales;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Replace (abandoned) `peterkahl/country-code-to-emoji-flag` package with fork
|
95,144 |
03.01.2021 10:38:20
| -3,600 |
061c1a3432e5165292344d8f74bc40c2962276cb
|
Better fix: Just bring in the one file with actual code
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"api-platform/core\": \"^2.5\",\n\"babdev/pagerfanta-bundle\": \"^2.5\",\n\"beberlei/doctrineextensions\": \"^1.2\",\n- \"bobdenotter/country-code-to-emoji-flag\": \"^2.0\",\n\"bolt/common\": \"^2.1.10\",\n\"cocur/slugify\": \"^4.0\",\n\"composer/composer\": \"^2.0\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Utils/FlagMaster.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Utils;\n+\n+use Exception;\n+\n+class FlagMaster\n+{\n+ /**\n+ * Converts string of (one) country code to emoji flag (string).\n+ * Makes correction for codes that have no corresponding flag.\n+ * Most flags have 2-letter code, but some have more (eg England=gbeng,\n+ * Scotland=gbsct, Wales=gbwls, etc.).\n+ *\n+ * @param string $code (one or more 2-letter codes)\n+ *\n+ * @throws \\Exception\n+ */\n+ public static function emojiFlag($code): string\n+ {\n+ if (! is_string($code) || mb_strlen($code) < 2) {\n+ throw new Exception('Argument code must be non-empty string');\n+ }\n+ $code = mb_strtolower($code);\n+ $replacement = [\n+ 'uk' => 'gb',\n+ 'an' => 'nl',\n+ 'ap' => 'un',\n+ ];\n+ if (array_key_exists($code, $replacement)) {\n+ $code = $replacement[$code];\n+ }\n+\n+ return self::_code2unicode($code);\n+ }\n+\n+ /**\n+ * Converts country (or region) code to emoji flag. One flag only!\n+ *\n+ * @param string $code (2 or more letter code)\n+ *\n+ * @throws \\Exception\n+ */\n+ private static function _code2unicode($code): string\n+ {\n+ $arr = str_split($code);\n+ $str = '';\n+ foreach ($arr as $char) {\n+ $str .= self::_enclosedUnicode($char);\n+ }\n+\n+ return $str;\n+ }\n+\n+ /**\n+ * Converts a character into enclosed unicode.\n+ *\n+ * @param string $char (one character)\n+ *\n+ * @throws \\Exception\n+ */\n+ private static function _enclosedUnicode($char): string\n+ {\n+ $arr = [\n+ 'a' => '1F1E6',\n+ 'b' => '1F1E7',\n+ 'c' => '1F1E8',\n+ 'd' => '1F1E9',\n+ 'e' => '1F1EA',\n+ 'f' => '1F1EB',\n+ 'g' => '1F1EC',\n+ 'h' => '1F1ED',\n+ 'i' => '1F1EE',\n+ 'j' => '1F1EF',\n+ 'k' => '1F1F0',\n+ 'l' => '1F1F1',\n+ 'm' => '1F1F2',\n+ 'n' => '1F1F3',\n+ 'o' => '1F1F4',\n+ 'p' => '1F1F5',\n+ 'q' => '1F1F6',\n+ 'r' => '1F1F7',\n+ 's' => '1F1F8',\n+ 't' => '1F1F9',\n+ 'u' => '1F1FA',\n+ 'v' => '1F1FB',\n+ 'w' => '1F1FC',\n+ 'x' => '1F1FD',\n+ 'y' => '1F1FE',\n+ 'z' => '1F1FF',\n+ ];\n+ $char = mb_strtolower($char);\n+ if (array_key_exists($char, $arr)) {\n+ return mb_convert_encoding('&#x' . $arr[$char] . ';', 'UTF-8', 'HTML-ENTITIES');\n+ }\n+ throw new Exception('Illegal value argument char');\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Utils/LocaleHelper.php",
"new_path": "src/Utils/LocaleHelper.php",
"diff": "@@ -4,7 +4,6 @@ declare(strict_types=1);\nnamespace Bolt\\Utils;\n-use bobdenotter\\flagMaster\\flagMaster;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Repository\\ContentRepository;\nuse Symfony\\Component\\HttpFoundation\\Request;\n@@ -185,7 +184,7 @@ class LocaleHelper\n$locale = [\n'code' => $localeCode,\n'flag' => $flag,\n- 'emoji' => flagMaster::emojiFlag($flag),\n+ 'emoji' => FlagMaster::emojiFlag($flag),\n];\ntry {\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Better fix: Just bring in the one file with actual code
|
95,144 |
03.01.2021 13:42:58
| -3,600 |
06499dc2ebe777a0e64e3d84cd363a0160545fe6
|
add FlagMaster
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Utils/FlagMaster.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Utils;\n+\n+use Exception;\n+\n+class FlagMaster\n+{\n+ /**\n+ * Converts string of (one) country code to emoji flag (string).\n+ * Makes correction for codes that have no corresponding flag.\n+ * Most flags have 2-letter code, but some have more (eg England=gbeng,\n+ * Scotland=gbsct, Wales=gbwls, etc.).\n+ *\n+ * @param string $code (one or more 2-letter codes)\n+ *\n+ * @throws \\Exception\n+ */\n+ public static function emojiFlag($code): string\n+ {\n+ if (! is_string($code) || mb_strlen($code) < 2) {\n+ throw new Exception('Argument code must be non-empty string');\n+ }\n+ $code = mb_strtolower($code);\n+ $replacement = [\n+ 'uk' => 'gb',\n+ 'an' => 'nl',\n+ 'ap' => 'un',\n+ ];\n+ if (array_key_exists($code, $replacement)) {\n+ $code = $replacement[$code];\n+ }\n+\n+ return self::_code2unicode($code);\n+ }\n+\n+ /**\n+ * Converts country (or region) code to emoji flag. One flag only!\n+ *\n+ * @param string $code (2 or more letter code)\n+ *\n+ * @throws \\Exception\n+ */\n+ private static function _code2unicode($code): string\n+ {\n+ $arr = str_split($code);\n+ $str = '';\n+ foreach ($arr as $char) {\n+ $str .= self::_enclosedUnicode($char);\n+ }\n+\n+ return $str;\n+ }\n+\n+ /**\n+ * Converts a character into enclosed unicode.\n+ *\n+ * @param string $char (one character)\n+ *\n+ * @throws \\Exception\n+ */\n+ private static function _enclosedUnicode($char): string\n+ {\n+ $arr = [\n+ 'a' => '1F1E6',\n+ 'b' => '1F1E7',\n+ 'c' => '1F1E8',\n+ 'd' => '1F1E9',\n+ 'e' => '1F1EA',\n+ 'f' => '1F1EB',\n+ 'g' => '1F1EC',\n+ 'h' => '1F1ED',\n+ 'i' => '1F1EE',\n+ 'j' => '1F1EF',\n+ 'k' => '1F1F0',\n+ 'l' => '1F1F1',\n+ 'm' => '1F1F2',\n+ 'n' => '1F1F3',\n+ 'o' => '1F1F4',\n+ 'p' => '1F1F5',\n+ 'q' => '1F1F6',\n+ 'r' => '1F1F7',\n+ 's' => '1F1F8',\n+ 't' => '1F1F9',\n+ 'u' => '1F1FA',\n+ 'v' => '1F1FB',\n+ 'w' => '1F1FC',\n+ 'x' => '1F1FD',\n+ 'y' => '1F1FE',\n+ 'z' => '1F1FF',\n+ ];\n+ $char = mb_strtolower($char);\n+ if (array_key_exists($char, $arr)) {\n+ return mb_convert_encoding('&#x' . $arr[$char] . ';', 'UTF-8', 'HTML-ENTITIES');\n+ }\n+ throw new Exception('Illegal value argument char');\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
add FlagMaster
|
95,144 |
03.01.2021 16:46:45
| -3,600 |
ff567d8e97d12d3513ada73befbd76a503de8d55
|
Use `placeholder.boltcms.io` for faster fetching of placeholders
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"knplabs/knp-menu-bundle\": \"^3.0\",\n\"league/glide-symfony\": \"^1.0\",\n\"miljar/php-exif\": \"^0.6.4\",\n+ \"nelexa/zip\": \"^3.3\",\n\"nelmio/cors-bundle\": \"^2.1\",\n\"nesbot/carbon\": \"^2.39\",\n\"php-translation/symfony-bundle\": \"^0.12\",\n\"webonyx/graphql-php\": \"^0.13\",\n\"xemlock/htmlpurifier-html5\": \"^0.1.11\"\n},\n+ \"replace\": {\n+ \"paragonie/random_compat\": \"9.99.99\"\n+ },\n\"require-dev\": {\n\"ext-curl\": \"*\",\n\"ext-pdo_sqlite\": \"*\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"baguettebox.js\": \"^1.11.1\",\n\"bootbox\": \"^5.5.2\",\n\"bootstrap\": \"^4.5.3\",\n-<<<<<<< HEAD\n\"browserslist\": \"^4.16.0\",\n\"caniuse-lite\": \"^1.0.30001171\",\n\"codemirror\": \"^5.58.3\",\n-=======\n- \"browserslist\": \"^4.14.6\",\n- \"caniuse-lite\": \"^1.0.30001161\",\n- \"codemirror\": \"^5.59.1\",\n->>>>>>> 4.1\n\"dropzone\": \"^5.7.2\",\n\"flagpack\": \"^1.0.5\",\n\"hotkeys-js\": \"^3.8.1\",\n\"@babel/plugin-transform-regenerator\": \"^7.12.1\",\n\"@babel/plugin-transform-runtime\": \"^7.12.10\",\n\"@babel/polyfill\": \"^7.12.1\",\n-<<<<<<< HEAD\n\"@babel/preset-env\": \"^7.12.10\",\n-=======\n- \"@babel/preset-env\": \"^7.12.11\",\n->>>>>>> 4.1\n\"@fortawesome/fontawesome-free\": \"^5.15.1\",\n\"@symfony/webpack-encore\": \"^0.31.1\",\n\"@vue/test-utils\": \"^1.1.1\",\n\"babel-jest\": \"^25.5.1\",\n\"eslint\": \"^6.8.0\",\n\"eslint-config-prettier\": \"^6.15.0\",\n-<<<<<<< HEAD\n\"eslint-plugin-prettier\": \"^3.2.0\",\n-=======\n- \"eslint-plugin-prettier\": \"^3.3.0\",\n->>>>>>> 4.1\n\"eslint-plugin-standard\": \"^4.1.0\",\n\"eslint-plugin-vue\": \"^6.2.2\",\n\"genversion\": \"^2.2.1\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/BaseFixture.php",
"new_path": "src/DataFixtures/BaseFixture.php",
"diff": "@@ -86,7 +86,7 @@ abstract class BaseFixture extends Fixture\n$glob = '*.{jpg,png,gif,jpeg,webp,avif}';\n$finder = new Finder();\n- $finder->in($fullpath)->depth('< 2')->sortByName()->name($glob)->files();\n+ $finder->in($fullpath)->depth('< 3')->sortByName()->name($glob)->files();\nreturn $finder;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/ImageFetchFixtures.php",
"new_path": "src/DataFixtures/ImageFetchFixtures.php",
"diff": "@@ -8,19 +8,18 @@ use Bolt\\Configuration\\Config;\nuse Bolt\\Configuration\\FileLocations;\nuse Doctrine\\Bundle\\FixturesBundle\\FixtureGroupInterface;\nuse Doctrine\\Persistence\\ObjectManager;\n-use Illuminate\\Support\\Collection;\n+use GuzzleHttp\\Client;\n+use PhpZip\\ZipFile;\nuse Symfony\\Component\\Console\\Helper\\ProgressBar;\nuse Symfony\\Component\\Console\\Output\\ConsoleOutput;\n-use Symfony\\Component\\HttpClient\\HttpClient;\nclass ImageFetchFixtures extends BaseFixture implements FixtureGroupInterface\n{\n- private const URL = \"https://placeholder.boltcms.io/getfiles\";\n+ private const URL = 'https://placeholder.boltcms.io/getfiles';\n/** @var FileLocations */\nprivate $fileLocations;\n- private const AMOUNT = 20;\nprivate const MAX_AMOUNT = 50;\n/** @var array */\n@@ -51,41 +50,36 @@ class ImageFetchFixtures extends BaseFixture implements FixtureGroupInterface\nprivate function fetchImages(): void\n{\n$output = new ConsoleOutput();\n- $progressBar = new ProgressBar($output, self::AMOUNT);\n-\n- $progressBar->start();\n-\n-// for ($i = 1; $i <= self::AMOUNT; $i++) {\n-// $random = $this->urls->random();\n-// $url = $random[1] . random_int(10000, 99999);\n-// $filename = 'image_' . random_int(10000, 99999) . '.jpg';\n-//\n-// $client = HttpClient::create();\n-// $resource = fopen($this->getOutputPath($random[0]) . $filename, 'w');\n-//\n-// $image = $client->request('GET', $url, $this->curlOptions)->getContent();\n-//\n-// fwrite($resource, $image);\n-// fclose($resource);\n-//\n-// $progressBar->advance();\n-// }\n- $client = HttpClient::create();\n- $resource = fopen($this->getOutputPath() . 'placeholders.zip', 'w');\n-\n-\n- $file = $client->request('GET', self::URL, $this->curlOptions)->getContent();\n- fwrite($resource, $file);\n- fclose($resource);\n-//\n-\n- $progressBar->finish();\n+ $resource = fopen($this->getOutputFile(), 'w');\n+\n+ $client = new Client([\n+ 'progress' => function ($total, $downloaded) use ($output, &$progress): void {\n+ if ($total > 0 && $progress === null) {\n+ $progress = new ProgressBar($output, 100);\n+ $progress->setRedrawFrequency(5);\n+ $progress->start();\n+ }\n+\n+ if ($downloaded > 0) {\n+ $progress->setProgress((int) round($downloaded / $total * 80.0));\n+ }\n+ },\n+ 'sink' => $resource,\n+ ]);\n+\n+ $client->request('GET', self::URL, $this->curlOptions);\n+ $progress->finish();\n+\n+ $zipFile = new ZipFile();\n+\n+ $zipFile->openFile($this->getOutputFile())->extractTo($this->getOutputPath());\n+\n$output->writeln('');\n}\nprivate function getOutputPath(): string\n{\n- $outputPath = $this->fileLocations->get('files')->getBasepath() . '/';\n+ $outputPath = $this->fileLocations->get('files')->getBasepath() . '/stock/';\nif (! is_dir($outputPath)) {\nmkdir($outputPath);\n@@ -93,4 +87,9 @@ class ImageFetchFixtures extends BaseFixture implements FixtureGroupInterface\nreturn $outputPath;\n}\n+\n+ private function getOutputFile(): string\n+ {\n+ return $this->getOutputPath() . 'placeholders.zip';\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "symfony.lock",
"new_path": "symfony.lock",
"diff": "\"nategood/commando\": {\n\"version\": \"0.4.0\"\n},\n+ \"nelexa/zip\": {\n+ \"version\": \"3.3.3\"\n+ },\n\"nelmio/cors-bundle\": {\n\"version\": \"1.5\",\n\"recipe\": {\n\"pagerfanta/pagerfanta\": {\n\"version\": \"v2.3.0\"\n},\n+ \"paragonie/random_compat\": {\n+ \"version\": \"v9.99.100\"\n+ },\n\"peterkahl/country-code-to-emoji-flag\": {\n\"version\": \"v1.2\"\n},\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Use `placeholder.boltcms.io` for faster fetching of placeholders
|
95,148 |
05.01.2021 14:22:32
| -3,600 |
02c6297fbbec3b49f943367724273879b738368d
|
Add maxlength attribute and remove pattern attribute for textarea
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/editor/Components/Textarea.vue",
"new_path": "assets/js/app/editor/Components/Textarea.vue",
"diff": ":pattern=\"pattern\"\n:placeholder=\"placeholder\"\n:style=\"{ height: styleHeight }\"\n+ :maxlength=\"maxlength\"\n></textarea>\n</div>\n</template>\n@@ -30,6 +31,7 @@ export default {\npattern: String | Boolean,\nplaceholder: String | Boolean,\nheight: String | Number,\n+ maxlength: String,\n},\ndata() {\nreturn {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Content/FieldType.php",
"new_path": "src/Configuration/Content/FieldType.php",
"diff": "@@ -52,6 +52,7 @@ class FieldType extends Collection\n// 10 rows by default\n'height' => '10',\n'icon' => '',\n+ 'maxlength' => '',\n]);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/_base.html.twig",
"new_path": "templates/_partials/fields/_base.html.twig",
"diff": "{# Set pattern #}\n{% set pattern = field.definition.get('pattern')|default(false) %}\n+{# Set maxlength #}\n+{% set maxlength = field.definition.get('maxlength')|default('') %}\n+\n{% set type_collection = (type in ['collection']) %}\n{% set type_card = (type in ['imagelist', 'filelist', 'set']) %}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/textarea.html.twig",
"new_path": "templates/_partials/fields/textarea.html.twig",
"diff": ":pattern='{{ pattern|json_encode }}'\n:placeholder='{{ placeholder|json_encode }}'\n:height='{{ height|json_encode }}'\n+ :maxlength='{{ maxlength|json_encode }}'\n></editor-textarea>\n{% endblock %}\n"
},
{
"change_type": "MODIFY",
"old_path": "tests/php/Configuration/Parser/ContentTypesParserTest.php",
"new_path": "tests/php/Configuration/Parser/ContentTypesParserTest.php",
"diff": "@@ -17,7 +17,7 @@ class ContentTypesParserTest extends ParserTestBase\npublic const AMOUNT_OF_ATTRIBUTES_IN_CONTENT_TYPE = 26;\n- public const AMOUNT_OF_ATTRIBUTES_IN_FIELD = 26;\n+ public const AMOUNT_OF_ATTRIBUTES_IN_FIELD = 27;\npublic const ALLOWED_LOCALES = 'en|nl|es|fr|de|pl|it|hu|pt_BR|ja|nb|nn|nl_NL|nl_BE';\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add maxlength attribute and remove pattern attribute for textarea
|
95,148 |
06.01.2021 10:52:17
| -3,600 |
0ae3107d1226a36146190ff8cdf38ab23da23502
|
remove pattern attribute on textarea
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/editor/Components/Textarea.vue",
"new_path": "assets/js/app/editor/Components/Textarea.vue",
"diff": ":required=\"required\"\n:readonly=\"readonly\"\n:data-errormessage=\"errormessage\"\n- :pattern=\"pattern\"\n:placeholder=\"placeholder\"\n:style=\"{ height: styleHeight }\"\n:maxlength=\"maxlength\"\n@@ -28,7 +27,6 @@ export default {\nrequired: Boolean,\nreadonly: Boolean,\nerrormessage: String | Boolean,\n- pattern: String | Boolean,\nplaceholder: String | Boolean,\nheight: String | Number,\nmaxlength: String,\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/textarea.html.twig",
"new_path": "templates/_partials/fields/textarea.html.twig",
"diff": ":required='{{ required|json_encode }}'\n:readonly='{{ readonly|json_encode }}'\n:errormessage='{{ errormessage|json_encode }}'\n- :pattern='{{ pattern|json_encode }}'\n:placeholder='{{ placeholder|json_encode }}'\n:height='{{ height|json_encode }}'\n:maxlength='{{ maxlength|json_encode }}'\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
remove pattern attribute on textarea
|
95,144 |
07.01.2021 09:33:52
| -3,600 |
bf5f1d2282eba3c26668efbc7bbe2ec3f66d5cee
|
Preparing 4.2.0-beta.4
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/version.js",
"new_path": "assets/js/version.js",
"diff": "// generated by genversion\n-export const version = '4.1.99.3';\n+export const version = '4.1.99.4';\n"
},
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.99.3\",\n+ \"version\": \"4.1.99.4\",\n\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n\"version\": \"4.3.0\",\n\"resolved\": \"https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz\",\n\"integrity\": \"sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==\",\n+ \"optional\": true,\n\"requires\": {\n\"color-convert\": \"^2.0.1\"\n}\n\"version\": \"4.1.0\",\n\"resolved\": \"https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz\",\n\"integrity\": \"sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==\",\n+ \"optional\": true,\n\"requires\": {\n\"ansi-styles\": \"^4.1.0\",\n\"supports-color\": \"^7.1.0\"\n\"version\": \"2.0.1\",\n\"resolved\": \"https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz\",\n\"integrity\": \"sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==\",\n+ \"optional\": true,\n\"requires\": {\n\"color-name\": \"~1.1.4\"\n}\n\"color-name\": {\n\"version\": \"1.1.4\",\n\"resolved\": \"https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz\",\n- \"integrity\": \"sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==\"\n+ \"integrity\": \"sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==\",\n+ \"optional\": true\n},\n\"emojis-list\": {\n\"version\": \"3.0.0\",\n\"resolved\": \"https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz\",\n- \"integrity\": \"sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==\"\n+ \"integrity\": \"sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==\",\n+ \"optional\": true\n},\n\"fast-deep-equal\": {\n\"version\": \"3.1.3\",\n\"has-flag\": {\n\"version\": \"4.0.0\",\n\"resolved\": \"https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz\",\n- \"integrity\": \"sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==\"\n+ \"integrity\": \"sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==\",\n+ \"optional\": true\n},\n\"hash-sum\": {\n\"version\": \"2.0.0\",\n\"version\": \"2.1.3\",\n\"resolved\": \"https://registry.npmjs.org/json5/-/json5-2.1.3.tgz\",\n\"integrity\": \"sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==\",\n+ \"optional\": true,\n\"requires\": {\n\"minimist\": \"^1.2.5\"\n}\n\"version\": \"2.0.0\",\n\"resolved\": \"https://registry.npmjs.org/loader-utils/-/loader-utils-2.0.0.tgz\",\n\"integrity\": \"sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ==\",\n+ \"optional\": true,\n\"requires\": {\n\"big.js\": \"^5.2.2\",\n\"emojis-list\": \"^3.0.0\",\n\"version\": \"7.2.0\",\n\"resolved\": \"https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz\",\n\"integrity\": \"sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==\",\n+ \"optional\": true,\n\"requires\": {\n\"has-flag\": \"^4.0.0\"\n}\n\"version\": \"npm:vue-loader@16.1.2\",\n\"resolved\": \"https://registry.npmjs.org/vue-loader/-/vue-loader-16.1.2.tgz\",\n\"integrity\": \"sha512-8QTxh+Fd+HB6fiL52iEVLKqE9N1JSlMXLR92Ijm6g8PZrwIxckgpqjPDWRP5TWxdiPaHR+alUWsnu1ShQOwt+Q==\",\n+ \"optional\": true,\n\"requires\": {\n\"chalk\": \"^4.1.0\",\n\"hash-sum\": \"^2.0.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.99.3\",\n+ \"version\": \"4.1.99.4\",\n\"homepage\": \"https://boltcms.io\",\n\"author\": \"Bob den Otter <bob@twokings.nl> (https://boltcms.io)\",\n\"license\": \"MIT\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Preparing 4.2.0-beta.4
|
95,147 |
07.01.2021 10:03:28
| -3,600 |
21870e918153782dff5cfdd9549526f04e8ff3c5
|
Fix welcome command explanation
|
[
{
"change_type": "MODIFY",
"old_path": "src/Command/WelcomeCommand.php",
"new_path": "src/Command/WelcomeCommand.php",
"diff": "@@ -39,9 +39,9 @@ HELP\n$this->outputImage($io);\n- $io->info('Welcome to your new Bolt project. To set up the database, run `bin/console bolt:setup`');\n+ $io->info('Welcome to your new Bolt project. To set up the database, run `bin/console bolt:setup` inside your new project folder.');\n$io->text('For the full setup instructions, and other documentation, visit <href=https://docs.bolt.cm/installation/installation>https://docs.bolt.cm/installation/installation</>');\n- $io->text('To ask questions and learn form our community, join our Slack channel: <href=https://slack.bolt.cm/>https://slack.bolt.cm/</>');\n+ $io->text('To ask questions and learn from our community, join our Slack channel: <href=https://slack.bolt.cm/>https://slack.bolt.cm/</>');\n$io->text('Additional resources and tips are available at <href=https://bolt.tips/>https://bolt.tips/</>');\n$io->info('Happy building!');\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix welcome command explanation
|
95,147 |
07.01.2021 11:26:27
| -3,600 |
136622b00a6f31847b15edbeddd2438609cb20fa
|
Require simplify/package-builder, add reset_password yaml
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"symfony/webpack-encore-bundle\": \"^1.7\",\n\"symfony/yaml\": \"^5.1\",\n\"symfonycasts/reset-password-bundle\": \"^1.1\",\n+ \"symplify/package-builder\": \"^8.0\",\n\"tightenco/collect\": \"^v8.0\",\n\"twig/twig\": \"^3.0\",\n\"ua-parser/uap-php\": \"^3.9\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "yaml-migrations/m_2021-01-07-reset_password.yaml",
"diff": "+# Adding the new services for Bolt 4.2.0\n+file: packages/reset_password.yaml\n+since: 4.2.0\n+\n+add:\n+ symfonycasts_reset_password:\n+ request_password_repository: Bolt\\Repository\\ResetPasswordRequestRepository\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Require simplify/package-builder, add reset_password yaml
|
95,147 |
07.01.2021 13:46:53
| -3,600 |
8d31a197a1d0a72bf2a52fb0d2835969a7f6619b
|
Fix `default` option for select field
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/SelectField.php",
"new_path": "src/Entity/Field/SelectField.php",
"diff": "@@ -90,4 +90,9 @@ class SelectField extends Field implements FieldInterface, RawPersistable\nreturn false;\n}\n+\n+ public function getDefaultValue()\n+ {\n+ return [parent::getDefaultValue()];\n+ }\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix `default` option for select field
|
95,147 |
07.01.2021 13:57:39
| -3,600 |
2a479a055eb9774cd3bf139ae36a2b08b040e1e1
|
Make sure Other Content works on mobile
|
[
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -9,6 +9,7 @@ use Bolt\\Configuration\\Content\\ContentType;\nuse Bolt\\Repository\\ContentRepository;\nuse Bolt\\Twig\\ContentExtension;\nuse Bolt\\Version;\n+use Cocur\\Slugify\\Slugify;\nuse Knp\\Menu\\FactoryInterface;\nuse Knp\\Menu\\ItemInterface;\nuse Knp\\Menu\\MenuItem;\n@@ -329,16 +330,20 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n/** @var ContentType[] $contentTypes */\n$contentTypes = $this->config->get('contenttypes')->where('show_in_menu', '!==', true);\n+ $slugify = new Slugify(['separator' => '-']);\nforeach ($contentTypes as $contentType) {\n$label = $contentType->get('show_in_menu') ?: $t->trans('caption.other_content');\nif (! $menu->getChild($label)) {\n// Add the top level item\n+\n+ $slug = $slugify->slugify($label);\n$menu->addChild($label, [\n+ 'uri' => $this->urlGenerator->generate('bolt_menupage', ['slug' => $slug]),\n'extras' => [\n'name' => $label,\n'icon' => $contentType->get('icon_many'),\n- 'slug' => $label,\n+ 'slug' => $slug,\n],\n]);\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Make sure Other Content works on mobile
|
95,144 |
08.01.2021 14:40:45
| -3,600 |
15e6eab4c1e5779ce1d799dc5cf7f9868b70bd1e
|
Fixing badges in Collections
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/editor/Components/Collection.vue",
"new_path": "assets/js/app/editor/Components/Collection.vue",
"diff": "<div class=\"card-header d-flex align-items-center\">\n<!-- Initial title. This is replaced by dynamic title in JS below. -->\n<i class=\"card-marker-caret fa fa-caret-right\"></i>\n- <i :class=\"[element.icon, 'fas', 'badge badge-secondary']\"> {{ element.label }}</i>\n+ <span class=\"badge badge-secondary inline\" :title=\"element.label\">\n+ <i :class=\"[element.icon, 'fas']\"></i>\n+ </span>\n<div class=\"collection-item-title\" :data-label=\"element.label\">\n{{ element.label }}\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/scss/modules/base/_badges.scss",
"new_path": "assets/scss/modules/base/_badges.scss",
"diff": ".badge.selected {\nfont-weight: bold;\n}\n+\n+.badge.inline {\n+ margin-top: inherit;\n+ padding: 0.3rem;\n+ margin-right: 0.4rem;\n+\n+ i {\n+ margin-right: 0;\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fixing badges in Collections
|
95,144 |
08.01.2021 14:56:07
| -3,600 |
4e1cf4ea73fc7567804e0d223d194d6766739989
|
Fix fixutres: Explicitly require `guzzlehttp/guzzle`
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"embed/embed\": \"^3.4\",\n\"erusev/parsedown\": \"^1.7\",\n\"fakerphp/faker\": \"^1.10\",\n+ \"guzzlehttp/guzzle\": \"^6.5\",\n\"knplabs/doctrine-behaviors\": \"^2.0.3\",\n\"knplabs/knp-menu-bundle\": \"^3.0\",\n\"league/glide-symfony\": \"^1.0\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix fixutres: Explicitly require `guzzlehttp/guzzle`
|
95,115 |
08.11.2020 13:13:25
| -3,600 |
90ef49fd99c82bdce86c83cc70550e46c24fa4af
|
Add impersonation based on Symfony support
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/toolbar/Components/Toolbar.vue",
"new_path": "assets/js/app/toolbar/Components/Toolbar.vue",
"diff": ">\n<img v-if=\"avatar\" :src=\"avatar\" class=\"rounded-circle mr-2\" alt=\"User avatar\" />\n<i v-else class=\"fas fa-user\"></i>{{ labels['general.greeting'] }}\n+ <template v-if=\"isImpersonator\">\n+ <span style=\"font-style: italic;\">({{ labels['general.is_impersonator'] }})</span>\n+ </template>\n</button>\n<div class=\"profile__dropdown dropdown-menu dropdown-menu-right\">\n<ul>\n+ <li v-if=\"isImpersonator\">\n+ <a :href=\"backendPrefix + '?_switch_user=_exit'\">\n+ <i class=\"fas fa-sign-out-alt fa-fw\"></i>\n+ {{ labels['action.stop_impersonating'] }}\n+ </a>\n+ </li>\n<li>\n<a :href=\"backendPrefix + 'profile-edit'\">\n<i class=\"fas fa-user-edit fa-fw\"></i>\n@@ -79,6 +88,7 @@ export default {\nmenu: Array,\nlabels: Object,\nbackendPrefix: RegExp,\n+ isImpersonator: Boolean,\nfilterValue: String,\navatar: String,\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "config/packages/security.yaml",
"new_path": "config/packages/security.yaml",
"diff": "security:\nrole_hierarchy:\n- ROLE_ADMIN: [ROLE_EDITOR, ROLE_USER]\n+ ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]\n+ ROLE_ADMIN: [ROLE_EDITOR, ROLE_USER, ROLE_ALLOWED_TO_SWITCH]\nROLE_EDITOR: [ROLE_USER]\nROLE_USER: []\n@@ -22,6 +23,7 @@ security:\npattern: ^/\nanonymous: true\nuser_checker: Bolt\\Security\\UserChecker\n+ switch_user: true\nguard:\nauthenticators:\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "'about.bolt_documentation': 'about.bolt_documentation'|trans,\n'action.view_site': config.get('general/sitename'),\n'general.greeting': 'general.greeting'|trans({'%name%': user_display_name}),\n+ 'general.is_impersonator': 'general.is_impersonator'|trans,\n'action.logout': 'action.logout'|trans,\n+ 'action.stop_impersonating': 'action.stop_impersonating'|trans,\n'action.edit_profile': 'action.edit_profile'|trans,\n'about.visit_bolt': 'about.visit_bolt'|trans,\n'listing.button_search': 'general.phrase.search'|trans,\n:labels=\"{{ labels }}\"\n:backend-prefix=\"{{ path('bolt_dashboard') }}\"\n:avatar=\"{{ user_avatar|json_encode }}\"\n+ :is-impersonator=\"{{ is_granted('IS_IMPERSONATOR')|json_encode }}\"\nfilter-value=\"{{ filter_value|default('') }}\"\n></admin-toolbar>\n</nav>\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/users/listing.html.twig",
"new_path": "templates/users/listing.html.twig",
"diff": "{% if iteratedUser.status !== 'enabled' %}\n{{ macro.buttonlink('action.enable', path('bolt_user_update_status', {'id': iteratedUser.id, '_csrf_token': csrf_token('useredit'), 'status': 'enabled'}), 'thumbs-up', 'secondary sm') }}\n{% endif %}\n+ {{ macro.buttonlink('action.impersonate', path('bolt_dashboard', {'_switch_user': iteratedUser.username}), 'user-shield', 'secondary sm') }}\n{{ macro.buttonlink('action.delete', path('bolt_user_delete', {'id': iteratedUser.id, '_csrf_token': csrf_token('useredit')}), 'trash', 'danger sm', {'data-confirmation': 'action.confirm_delete'|trans }) }}\n{% endif %}\n</td>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add impersonation based on Symfony support https://symfony.com/doc/current/security/impersonating_user.html
|
95,115 |
10.11.2020 14:58:46
| -3,600 |
80694fe8cac1f113c9c1c6b908abd9cd55616051
|
get permissions from config file - work in progress
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "config/bolt/permissions.yaml",
"diff": "+# This file defines role-based access control for your Bolt site.\n+# Before making any modifications to this file, make sure you've thoroughly\n+# read the documentation at https://docs.bolt.cm/configuration/permissions\n+# and understand the consequences of making uninformed changes to the roles and\n+# permissions.\n+\n+\n+# Now we'll define some permissions. Each permission comes with a list of roles\n+# that grant access.\n+\n+# The first set of permissions are the 'global' permissions; these are not tied\n+# to any content types, but rather apply to global, non-content activity in\n+# Bolt's backend. Most of these permissions map directly to backend routes;\n+# keep in mind, however, that routes do not always correspond to URL paths 1:1.\n+# The default set defined here is appropriate for most sites, so most likely,\n+# you will not have to change it.\n+# Also note that the 'editcontent' and 'overview' routes are special-cased\n+# inside the code, so they don't appear here.\n+global:\n+ about: [ everyone ] # view the 'About Bolt' page\n+ checks: [ admin, developer ]\n+ clearcache: [ admin, developer ]\n+ contentaction: [ editor, admin, developer ]\n+ dashboard: [ everyone ]\n+ dbcheck: [ admin, developer ]\n+ dbupdate: [ admin, developer ]\n+ dbupdate_result: [ admin, developer ]\n+ extensions: [ developer ]\n+ extensions:config: [ developer ]\n+ fileedit: [ admin, developer ]\n+ files:config: [ developer ]\n+ files:hidden: [ developer ]\n+ files:theme: [ developer ]\n+ files:uploads: [ admin, developer, chief-editor, editor ]\n+ files: [ admin, developer, chief-editor, editor ]\n+ prefill: [ developer ]\n+ profile: [ everyone ] # edit own profile\n+ settings: [ admin, developer, everyone ]\n+ translation: [ developer ]\n+ useraction: [ admin, developer ] # enable/disable/delete\n+ useredit: [ admin, developer ] # user settings\n+ users: [ admin, developer ] # view user overview\n+ roles: [ admin, developer ] # view the roles overview\n+ maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n+ omnisearch: [ everyone ]\n+ # Access to the various logs\n+ changelog: [ admin, developer, chief-editor ]\n+ systemlog: [ admin, developer ]\n+ # The following permissions are particularly important: login and postLogin\n+ # determine who may see and use the login form. If you set them to anything\n+ # but 'anonymous', only users will be able to log in that are logged in\n+ # already, which is probably never what you want.\n+ login: [ anonymous ]\n+ postLogin: [ anonymous ]\n+ # Likewise, 'logout' needs to be granted to 'everyone', otherwise people\n+ # cannot log out anymore.\n+ logout: [ everyone ]\n+\n+# For content type related actions, permissions can be set individually for\n+# each content type. For this, we define three groups of permission sets.\n+# The 'contenttype-all' permission sets *overrides*; any roles specified here\n+# will grant a permission for all content types, regardless of the rest of this\n+# section.\n+# The 'contenttype-default' contains rules that are used when the desired\n+# content type does not define a rule for this permission itself.\n+# The 'contenttypes' section specifies permissions for individual content\n+# types.\n+#\n+# To understand how this works, it may be best to follow the permission checker\n+# through its decision-making process.\n+#\n+# First, it checks whether the current user is in the \"root\" role; if so, it\n+# short-circuits and always grants anything unconditionally.\n+#\n+# Otherwise, it checks whether any of the current user's roles match any of the\n+# roles in contenttype-all/{permission}. If so, the search is over, and the\n+# permission can be granted.\n+#\n+# The next step is to find contenttypes/{contenttype}/{permission}. If it is\n+# found, then the permission can be granted if and only if any of the user's\n+# roles match any role in contenttypes/{contenttype}/{permission}.\n+#\n+# If either contenttypes/{contenttype} or\n+# contenttypes/{contenttype}/{permission} is absent, the permission checker\n+# uses contenttype-default/{permission} instead. If any role exists in both the\n+# user's roles and contenttype-default/{permission}, the permission can be\n+# granted.\n+#\n+# Note especially that an *empty* set of roles in the contenttype section means\n+# something else than the *absence* of the permission. If the permission is\n+# defined with an empty role list, it overrides the role list in\n+# contenttype-default; but if the permission is not mentioned, the\n+# corresponding entry in contenttype-default applies.\n+#\n+# The following permissions are available on a per-contenttype basis:\n+#\n+# - edit: allows updating existing records\n+# - create: allows creating new records\n+# - publish: allows changing the status of a record to \"published\", as well as\n+# scheduling a record for future publishing\n+# - depublish: allows changing the status of a record from \"published\"\n+# - delete: allows (hard) deletion of records\n+# - change-ownership: allows changing a record's owner. Note that ownership may\n+# grant additional permissions on a record, so this\n+# permission can indirectly enable users more permissions\n+# in ways that may not be immediately obvious.\n+# - view: allows viewing records in the backend\n+contenttype-all:\n+ edit: [ developer, admin, chief-editor ]\n+ create: [ developer, admin, chief-editor ]\n+ publish: [ developer, admin, chief-editor ]\n+ depublish: [ developer, admin, chief-editor ]\n+ delete: [ developer, admin ]\n+ change-ownership: [ developer, admin ]\n+\n+contenttype-default:\n+ edit: [ editor ]\n+ create: [ editor ]\n+ change-ownership: [ owner ]\n+ view: [ anonymous ]\n+\n+contenttypes:\n+\n+# This is an example of how to define Contenttype specific permissions\n+#\n+# contenttypes:\n+# # Keys in this dictionary map to keys in the contenttypes.yml specification.\n+# showcases:\n+# # Rules defined here *override* rules defined in contenttype-default,\n+# # but *add* to rules in contenttype-all. This means that permissions\n+# # granted through contenttype-all cannot be revoked here, merely\n+# # amended.\n+#\n+# # Only the Admin and Chief Editor are allowed to edit records\n+# edit: [ admin, chief-editor ]\n+# create: [ admin, chief-editor ]\n+# publish: [ admin, chief-editor ]\n+# depublish: [ admin, chief-editor ]\n+# delete: [ admin, chief-editor ]\n+# # Roles that can see the area in the admin section\n+# view: [ developer, admin, chief-editor ]\n+# # Do not expose this content type on the front-end unless user is\n+# logged into the backend\n"
},
{
"change_type": "MODIFY",
"old_path": "config/packages/security.yaml",
"new_path": "config/packages/security.yaml",
"diff": "@@ -44,5 +44,7 @@ security:\n# additional security lives in the controllers\n- { path: '^%bolt.backend_url%/login$', roles: IS_AUTHENTICATED_ANONYMOUSLY }\n- { path: '^%bolt.backend_url%/reset-password', roles: IS_AUTHENTICATED_ANONYMOUSLY }\n- - { path: '^%bolt.backend_url%', roles: ROLE_ADMIN }\n- - { path: '^/(%app_locales%)%bolt.backend_url%', roles: ROLE_ADMIN }\n+ # backend_url: require users to actually be logged in (not remember-me) - detailed permissions are\n+ # handled by Voters\n+ - { path: '^%bolt.backend_url%', roles: IS_AUTHENTICATED_FULLY }\n+ - { path: '^/(%app_locales%)%bolt.backend_url%', roles: IS_AUTHENTICATED_FULLY }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Config.php",
"new_path": "src/Configuration/Config.php",
"diff": "@@ -10,6 +10,7 @@ use Bolt\\Configuration\\Parser\\BaseParser;\nuse Bolt\\Configuration\\Parser\\ContentTypesParser;\nuse Bolt\\Configuration\\Parser\\GeneralParser;\nuse Bolt\\Configuration\\Parser\\MenuParser;\n+use Bolt\\Configuration\\Parser\\PermissionsParser;\nuse Bolt\\Configuration\\Parser\\TaxonomyParser;\nuse Bolt\\Configuration\\Parser\\ThemeParser;\nuse Bolt\\Controller\\Backend\\ClearCacheController;\n@@ -123,6 +124,9 @@ class Config\n$theme = new ThemeParser($this->projectDir, $this->getPath('theme'));\n$config['theme'] = $theme->parse();\n+ $permissions = new PermissionsParser($this->projectDir);\n+ $config['permissions'] = $permissions->parse();\n+\n// @todo Add these config files if needed, or refactor them out otherwise\n//'permissions' => $this->parseConfigYaml('permissions.yml'),\n//'extensions' => $this->parseConfigYaml('extensions.yml'),\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Configuration/Parser/PermissionsParser.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Configuration\\Parser;\n+\n+use Tightenco\\Collect\\Support\\Collection;\n+\n+class PermissionsParser extends BaseParser\n+{\n+ /** @var string */\n+ private $path;\n+\n+ public function __construct(string $projectDir, string $filename = 'permissions.yaml')\n+ {\n+ $this->path = $path;\n+\n+ parent::__construct($projectDir, $filename);\n+ }\n+\n+ /**\n+ * Read and parse the theme.yml configuration file.\n+ */\n+ public function parse(): Collection\n+ {\n+ $theme = $this->parseConfigYaml($this->path . '/theme.yaml', true);\n+\n+ return new Collection($theme);\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/ContentVoter.php",
"new_path": "src/Security/ContentVoter.php",
"diff": "<?php\n+declare(strict_types=1);\nnamespace Bolt\\Security;\n-\n+use Bolt\\Entity\\Content;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\nuse Symfony\\Component\\Security\\Core\\Security;\n@@ -46,14 +47,14 @@ class ContentVoter extends Voter\n// if the attribute isn't one we support, return false\nif (! in_array($attribute, [self::CONTENT_EDIT, self::CONTENT_CREATE, self::CONTENT_PUBLISH,\nself::CONTENT_DEPUBLISH, self::CONTENT_DELETE, self::CONTENT_CHANGE_OWNERSHIP,\n- self::CONTENT_VIEW])) {\n+ self::CONTENT_VIEW, ], true)) {\nreturn false;\n}\n- // only vote on `Post` objects\n-// if (!$subject instanceof Post) {\n-// return false;\n-// }\n+ // only vote on `Content` objects\n+ if (!$subject instanceof Content) {\n+ return false;\n+ }\nreturn true;\n}\n@@ -71,34 +72,33 @@ class ContentVoter extends Voter\n}\n// you know $subject is a Post object, thanks to `supports()`\n- /** @var Post $post */\n- $post = $subject;\n+ /** @var Content $content */\n+ $content = $subject;\nswitch ($attribute) {\ncase self::VIEW:\n- return $this->canView($post, $user);\n+ return $this->canView($content, $user);\ncase self::EDIT:\n- return $this->canEdit($post, $user);\n+ return $this->canEdit($content, $user);\n}\nthrow new \\LogicException('This code should not be reached!');\n-\n}\n- private function canView(Post $post, User $user)\n+ private function canView(Content $content, User $user)\n{\n// if they can edit, they can view\n- if ($this->canEdit($post, $user)) {\n+ if ($this->canEdit($content, $user)) {\nreturn true;\n}\n// the Post object could have, for example, a method `isPrivate()`\n- return !$post->isPrivate();\n+ return ! $content->isPrivate();\n}\n- private function canEdit(Post $post, User $user)\n+ private function canEdit(Content $content, User $user)\n{\n// this assumes that the Post object has a `getOwner()` method\n- return $user === $post->getOwner();\n+ return $user === $content->getOwner();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/GlobalVoter.php",
"new_path": "src/Security/GlobalVoter.php",
"diff": "<?php\n+declare(strict_types=1);\nnamespace Bolt\\Security;\n-\n+use Bolt\\Configuration\\Config;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\nuse Symfony\\Component\\Security\\Core\\Security;\n@@ -11,11 +12,8 @@ use Symfony\\Component\\Security\\Core\\User\\User;\nclass GlobalVoter extends Voter\n{\n- const VIEW_SETTINGS = 'view_settings';\n- const EDIT_SETTINGS = 'edit_settings';\n-\n- const CONTENT_VIEW = 'content_view';\n- const CONTENT_EDIT = 'content_edit';\n+ public const VIEW_SETTINGS = 'view_settings';\n+ public const EDIT_SETTINGS = 'edit_settings';\n/*\n# The first set of permissions are the 'global' permissions; these are not tied\n@@ -68,23 +66,21 @@ global:\n*/\nprivate $security;\n+ private $config;\n- public function __construct(Security $security)\n+ public function __construct(Security $security, Config $config)\n{\n$this->security = $security;\n+ $this->config = $config->get('permissions');\n}\nprotected function supports(string $attribute, $subject)\n{\n// if the attribute isn't one we support, return false\n- if (!in_array($attribute, [self::VIEW_SETTINGS, self::EDIT_SETTINGS, self::CONTENT_VIEW, self::CONTENT_EDIT])) {\n+ if (! in_array($attribute, [self::VIEW_SETTINGS, self::EDIT_SETTINGS], true)) {\nreturn false;\n}\n- // only vote on `Post` objects\n-// if (!$subject instanceof Post) {\n-// return false;\n-// }\nreturn true;\n}\n@@ -101,35 +97,13 @@ global:\nreturn false;\n}\n- // you know $subject is a Post object, thanks to `supports()`\n- /** @var Post $post */\n- $post = $subject;\n-\nswitch ($attribute) {\n- case self::VIEW:\n- return $this->canView($post, $user);\n- case self::EDIT:\n- return $this->canEdit($post, $user);\n- }\n-\n- throw new \\LogicException('This code should not be reached!');\n-\n- }\n-\n- private function canView(Post $post, User $user)\n- {\n- // if they can edit, they can view\n- if ($this->canEdit($post, $user)) {\n+ case self::VIEW_SETTINGS:\n+ return true;\n+ case self::EDIT_SETTINGS:\nreturn true;\n}\n- // the Post object could have, for example, a method `isPrivate()`\n- return !$post->isPrivate();\n- }\n-\n- private function canEdit(Post $post, User $user)\n- {\n- // this assumes that the Post object has a `getOwner()` method\n- return $user === $post->getOwner();\n+ throw new \\LogicException('This code should not be reached!');\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
get permissions from config file - work in progress
|
95,115 |
11.11.2020 22:00:33
| -3,600 |
2b07ccad319be01a270d01d0fdcb44bd3c5244d8
|
work in progress - cleaned up permissionsparser
|
[
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/PermissionsParser.php",
"new_path": "src/Configuration/Parser/PermissionsParser.php",
"diff": "@@ -13,18 +13,16 @@ class PermissionsParser extends BaseParser\npublic function __construct(string $projectDir, string $filename = 'permissions.yaml')\n{\n- $this->path = $path;\n-\nparent::__construct($projectDir, $filename);\n}\n/**\n- * Read and parse the theme.yml configuration file.\n+ * Read and parse the permissions configuration file.\n*/\npublic function parse(): Collection\n{\n- $theme = $this->parseConfigYaml($this->path . '/theme.yaml', true);\n+ $permissionConfig = $this->parseConfigYaml($this->getInitialFilename());\n- return new Collection($theme);\n+ return new Collection($permissionConfig);\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
work in progress - cleaned up permissionsparser
|
95,115 |
13.11.2020 11:59:32
| -3,600 |
707098c76d4569208e41114c5fb6798df20cd812
|
move impersonation message / exit button to its own (top-left) place, and don't include it into the 'normal' menus
|
[
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "'about.bolt_documentation': 'about.bolt_documentation'|trans,\n'action.view_site': config.get('general/sitename'),\n'general.greeting': 'general.greeting'|trans({'%name%': user_display_name}),\n- 'general.is_impersonator': 'general.is_impersonator'|trans,\n'action.logout': 'action.logout'|trans,\n'action.stop_impersonating': 'action.stop_impersonating'|trans,\n'action.edit_profile': 'action.edit_profile'|trans,\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
move impersonation message / exit button to its own (top-left) place, and don't include it into the 'normal' menus
|
95,115 |
13.11.2020 12:02:02
| -3,600 |
c13804cfa43f5d839f5b9a171343e6f8b0839d9f
|
GlobalVoter.php now supports any permission defined in the 'global:' part of permissions.yaml
|
[
{
"change_type": "MODIFY",
"old_path": "src/Security/GlobalVoter.php",
"new_path": "src/Security/GlobalVoter.php",
"diff": "@@ -5,15 +5,14 @@ declare(strict_types=1);\nnamespace Bolt\\Security;\nuse Bolt\\Configuration\\Config;\n+use Bolt\\Entity\\User;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\n+use Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\nuse Symfony\\Component\\Security\\Core\\Security;\n-use Symfony\\Component\\Security\\Core\\User\\User;\nclass GlobalVoter extends Voter\n{\n- public const VIEW_SETTINGS = 'view_settings';\n- public const EDIT_SETTINGS = 'edit_settings';\n/*\n# The first set of permissions are the 'global' permissions; these are not tied\n@@ -66,29 +65,33 @@ global:\n*/\nprivate $security;\n- private $config;\n+ private $globalPermissions;\n+ private $supportedAttributes;\npublic function __construct(Security $security, Config $config)\n{\n$this->security = $security;\n- $this->config = $config->get('permissions');\n+ $this->globalPermissions = $config->get('permissions/global');\n+ if (is_array($this->globalPermissions) || $this->globalPermissions instanceof \\ArrayAccess) {\n+ // TODO should we also validate that the values are all simple arrays?\n+ foreach ($this->globalPermissions as $key => $value) {\n+ $this->supportedAttributes[] = $key;\n+ }\n+ } else {\n+ throw new \\DomainException(\"No global permissions config found\");\n+ }\n}\nprotected function supports(string $attribute, $subject)\n{\n- // if the attribute isn't one we support, return false\n- if (! in_array($attribute, [self::VIEW_SETTINGS, self::EDIT_SETTINGS], true)) {\n- return false;\n- }\n-\n- return true;\n+ return in_array($attribute, $this->supportedAttributes, true);\n}\nprotected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n{\n- if ($this->security->isGranted('ROLE_ADMIN')) {\n- return true;\n- }\n+// if ($this->security->isGranted('ROLE_SUPER_ADMIN')) {\n+// return true;\n+// }\n$user = $token->getUser();\n@@ -97,12 +100,22 @@ global:\nreturn false;\n}\n- switch ($attribute) {\n- case self::VIEW_SETTINGS:\n- return true;\n- case self::EDIT_SETTINGS:\n+// switch ($attribute) {\n+// case self::PERMISSION_DASHBOARD:\n+// return $this->hasRoleForPermission($user, $attribute);\n+// }\n+\n+ if (!isset($this->globalPermissions[$attribute])) {\n+ throw new \\DomainException(\"Global permission '$attribute' not defined, check your security and permissions configuration.\");\n+ }\n+\n+ $rolesWithPermission = $this->globalPermissions[$attribute];\n+ foreach ($rolesWithPermission as $role) {\n+ if ($this->security->isGranted($role)) {\nreturn true;\n}\n+ }\n+ return false;\nthrow new \\LogicException('This code should not be reached!');\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
GlobalVoter.php now supports any permission defined in the 'global:' part of permissions.yaml
|
95,115 |
14.11.2020 13:39:57
| -3,600 |
7cda8bf7da6cc26caff45450d4905a8e706631ca
|
Updated lots of global permissions.
|
[
{
"change_type": "MODIFY",
"old_path": "assets/scss/layout/_admin.scss",
"new_path": "assets/scss/layout/_admin.scss",
"diff": "@@ -7,6 +7,11 @@ body {\n}\n}\n+.impersonator {\n+ height: 24px;\n+ background-color: purple;\n+}\n+\n// Main Layout Grid\n.admin {\nmargin-top: $admin-toolbar-height;\n"
},
{
"change_type": "MODIFY",
"old_path": "assets/scss/modules/admin/_toolbar.scss",
"new_path": "assets/scss/modules/admin/_toolbar.scss",
"diff": "position: absolute;\ntop: 0;\nleft: 0;\n+ z-index: 1;\n}\n.toolbar-item {\n"
},
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "# and understand the consequences of making uninformed changes to the roles and\n# permissions.\n-\n-# Now we'll define some permissions. Each permission comes with a list of roles\n-# that grant access.\n-\n-# The first set of permissions are the 'global' permissions; these are not tied\n+# These permissions are the 'global' permissions; these are not tied\n# to any content types, but rather apply to global, non-content activity in\n# Bolt's backend. Most of these permissions map directly to backend routes;\n# keep in mind, however, that routes do not always correspond to URL paths 1:1.\n# Also note that the 'editcontent' and 'overview' routes are special-cased\n# inside the code, so they don't appear here.\nglobal:\n- about: [ everyone ] # view the 'About Bolt' page\n- checks: [ admin, developer ]\n- clearcache: [ admin, developer ]\n- contentaction: [ editor, admin, developer ]\n- dashboard: [ everyone ]\n- dbcheck: [ admin, developer ]\n- dbupdate: [ admin, developer ]\n- dbupdate_result: [ admin, developer ]\n- extensions: [ developer ]\n- extensions:config: [ developer ]\n- fileedit: [ admin, developer ]\n- files:config: [ developer ]\n- files:hidden: [ developer ]\n- files:theme: [ developer ]\n- files:uploads: [ admin, developer, chief-editor, editor ]\n- files: [ admin, developer, chief-editor, editor ]\n- prefill: [ developer ]\n- profile: [ everyone ] # edit own profile\n- settings: [ admin, developer, everyone ]\n- translation: [ developer ]\n- useraction: [ admin, developer ] # enable/disable/delete\n+ about: [ IS_AUTHENTICATED_ANONYMOUSLY ] # view the 'About Bolt' page\n+# checks: [ admin, developer ]\n+ clearcache: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n+# contentaction: [ editor, admin, developer ]\n+ dashboard: [ IS_AUTHENTICATED_FULLY ]\n+# dbcheck: [ admin, developer ]\n+# dbupdate: [ admin, developer ]\n+# dbupdate_result: [ admin, developer ]\n+ extensions: [ ROLE_DEVELOPER ]\n+# extensions:config: [ developer ]\n+ fileedit: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n+# files:config: [ developer ]\n+# files:hidden: [ developer ]\n+# files:theme: [ developer ]\n+# files:uploads: [ admin, developer, chief-editor, editor ]\n+# files: [ admin, developer, chief-editor, editor ]\n+# prefill: [ developer ]\n+ profile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\n+# settings: [ admin, developer, everyone ]\n+# translation: [ developer ]\n+# useraction: [ admin, developer ] # enable/disable/delete\nuseredit: [ admin, developer ] # user settings\n- users: [ admin, developer ] # view user overview\n- roles: [ admin, developer ] # view the roles overview\n- maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n- omnisearch: [ everyone ]\n- # Access to the various logs\n- changelog: [ admin, developer, chief-editor ]\n- systemlog: [ admin, developer ]\n- # The following permissions are particularly important: login and postLogin\n- # determine who may see and use the login form. If you set them to anything\n- # but 'anonymous', only users will be able to log in that are logged in\n- # already, which is probably never what you want.\n- login: [ anonymous ]\n- postLogin: [ anonymous ]\n- # Likewise, 'logout' needs to be granted to 'everyone', otherwise people\n- # cannot log out anymore.\n- logout: [ everyone ]\n+# users: [ admin, developer ] # view user overview\n+# roles: [ admin, developer ] # view the roles overview\n+# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n+ omnisearch: [ IS_AUTHENTICATED_ANONYMOUSLY ]\n+# # Access to the various logs\n+# changelog: [ admin, developer, chief-editor ]\n+ systemlog: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n+# NEW ???\n+ bulk_operations: [ ROLE_CHIEF_EDITOR ]\n+ fixtures: [ ROLE_DEVELOPER ]\n+ kitchensink: [ ROLE_DEVELOPER ]\n+\n# For content type related actions, permissions can be set individually for\n# each content type. For this, we define three groups of permission sets.\n"
},
{
"change_type": "MODIFY",
"old_path": "config/packages/security.yaml",
"new_path": "config/packages/security.yaml",
"diff": "security:\nrole_hierarchy:\n- ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]\n- ROLE_ADMIN: [ROLE_EDITOR, ROLE_USER, ROLE_ALLOWED_TO_SWITCH]\n+ ROLE_DEVELOPER: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]\n+ ROLE_ADMIN: [ROLE_CHIEF_EDITOR, ROLE_ALLOWED_TO_SWITCH]\n+ ROLE_CHIEF_EDITOR: [ROLE_EDITOR]\nROLE_EDITOR: [ROLE_USER]\nROLE_USER: []\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/BulkOperationsController.php",
"new_path": "src/Controller/Backend/BulkOperationsController.php",
"diff": "@@ -16,7 +16,7 @@ use Symfony\\Component\\Routing\\Annotation\\Route;\nuse Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('bulk_operations')\")\n*/\nclass BulkOperationsController extends AbstractController implements BackendZoneInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ClearCacheController.php",
"new_path": "src/Controller/Backend/ClearCacheController.php",
"diff": "@@ -14,7 +14,7 @@ use Symfony\\Component\\HttpKernel\\KernelInterface;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('clearcache')\")\n*/\nclass ClearCacheController extends AbstractController implements BackendZoneInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/DashboardController.php",
"new_path": "src/Controller/Backend/DashboardController.php",
"diff": "@@ -11,7 +11,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ *\n*/\nclass DashboardController extends TwigAwareController implements BackendZoneInterface\n{\n@@ -20,6 +20,10 @@ class DashboardController extends TwigAwareController implements BackendZoneInte\n*/\npublic function index(Query $query): Response\n{\n+\n+ $this->denyAccessUnlessGranted('dashboard');\n+\n+ // TODO PERMISSIONS: implement listing that only lists content that the user is allowed to see\n$amount = (int) $this->config->get('general/records_per_page', 10);\n$page = (int) $this->request->get('page', 1);\n$contentTypes = $this->config->get('contenttypes')->where('show_on_dashboard', true)->keys()->implode(',');\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ExtensionsController.php",
"new_path": "src/Controller/Backend/ExtensionsController.php",
"diff": "@@ -14,7 +14,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('extensions')\")\n*/\nclass ExtensionsController extends AbstractController implements BackendZoneInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/FileEditController.php",
"new_path": "src/Controller/Backend/FileEditController.php",
"diff": "@@ -24,7 +24,7 @@ use Webimpress\\SafeWriter\\FileWriter;\nuse Webmozart\\PathUtil\\Path;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('fileedit')\")\n*/\nclass FileEditController extends TwigAwareController implements BackendZoneInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/GeneralController.php",
"new_path": "src/Controller/Backend/GeneralController.php",
"diff": "@@ -14,7 +14,6 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n*/\nclass GeneralController extends TwigAwareController implements BackendZoneInterface\n{\n@@ -31,6 +30,8 @@ class GeneralController extends TwigAwareController implements BackendZoneInterf\n*/\npublic function about(): Response\n{\n+ $this->denyAccessUnlessGranted('about');\n+\n$twigVars = [\n'installType' => Version::installType(),\n'platform' => $this->doctrineVersion->getPlatform(),\n@@ -48,6 +49,8 @@ class GeneralController extends TwigAwareController implements BackendZoneInterf\n*/\npublic function kitchensink(ContentRepository $content, Config $config): Response\n{\n+ $this->denyAccessUnlessGranted('kitchensink');\n+\n$contentTypes = $config->get('contenttypes');\n/** @var Content $records */\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/LogViewerController.php",
"new_path": "src/Controller/Backend/LogViewerController.php",
"diff": "@@ -12,7 +12,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('systemlog')\")\n*/\nclass LogViewerController extends TwigAwareController implements BackendZoneInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/GlobalVoter.php",
"new_path": "src/Security/GlobalVoter.php",
"diff": "@@ -7,63 +7,11 @@ namespace Bolt\\Security;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\User;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\n-use Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\nuse Symfony\\Component\\Security\\Core\\Security;\nclass GlobalVoter extends Voter\n{\n-\n- /*\n-# The first set of permissions are the 'global' permissions; these are not tied\n-# to any content types, but rather apply to global, non-content activity in\n-# Bolt's backend. Most of these permissions map directly to backend routes;\n-# keep in mind, however, that routes do not always correspond to URL paths 1:1.\n-# The default set defined here is appropriate for most sites, so most likely,\n-# you will not have to change it.\n-# Also note that the 'editcontent' and 'overview' routes are special-cased\n-# inside the code, so they don't appear here.\n-global:\n- about: [ everyone ] # view the 'About Bolt' page\n- checks: [ admin, developer ]\n- clearcache: [ admin, developer ]\n- contentaction: [ editor, admin, developer ]\n- dashboard: [ everyone ]\n- dbcheck: [ admin, developer ]\n- dbupdate: [ admin, developer ]\n- dbupdate_result: [ admin, developer ]\n- extensions: [ developer ]\n- extensions:config: [ developer ]\n- fileedit: [ admin, developer ]\n- files:config: [ developer ]\n- files:hidden: [ developer ]\n- files:theme: [ developer ]\n- files:uploads: [ admin, developer, chief-editor, editor ]\n- files: [ admin, developer, chief-editor, editor ]\n- prefill: [ developer ]\n- profile: [ everyone ] # edit own profile\n- settings: [ admin, developer, everyone ]\n- translation: [ developer ]\n- useraction: [ admin, developer ] # enable/disable/delete\n- useredit: [ admin, developer ] # user settings\n- users: [ admin, developer ] # view user overview\n- roles: [ admin, developer ] # view the roles overview\n- maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n- omnisearch: [ everyone ]\n- # Access to the various logs\n- changelog: [ admin, developer, chief-editor ]\n- systemlog: [ admin, developer ]\n- # The following permissions are particularly important: login and postLogin\n- # determine who may see and use the login form. If you set them to anything\n- # but 'anonymous', only users will be able to log in that are logged in\n- # already, which is probably never what you want.\n- login: [ anonymous ]\n- postLogin: [ anonymous ]\n- # Likewise, 'logout' needs to be granted to 'everyone', otherwise people\n- # cannot log out anymore.\n- logout: [ everyone ]\n- */\n-\nprivate $security;\nprivate $globalPermissions;\nprivate $supportedAttributes;\n@@ -100,11 +48,6 @@ global:\nreturn false;\n}\n-// switch ($attribute) {\n-// case self::PERMISSION_DASHBOARD:\n-// return $this->hasRoleForPermission($user, $attribute);\n-// }\n-\nif (!isset($this->globalPermissions[$attribute])) {\nthrow new \\DomainException(\"Global permission '$attribute' not defined, check your security and permissions configuration.\");\n}\n@@ -116,7 +59,5 @@ global:\n}\n}\nreturn false;\n-\n- throw new \\LogicException('This code should not be reached!');\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_base/layout.html.twig",
"new_path": "templates/_base/layout.html.twig",
"diff": "<body>\n<div class=\"admin\">\n-\n{% set admin_menu_json = admin_menu_array()|json_encode %}\n<!-- Admin Toolbar -->\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Updated lots of global permissions.
|
95,115 |
14.11.2020 15:42:05
| -3,600 |
f34e60dfe4e07b0d91ad779d06e6dad6fcf77c29
|
fix typo: impersionation -> impersonation
|
[
{
"change_type": "MODIFY",
"old_path": "assets/scss/modules/admin/_toolbar.scss",
"new_path": "assets/scss/modules/admin/_toolbar.scss",
"diff": "}\n}\n- .toolbar-impersionation {\n+ .toolbar-impersonation {\nposition: absolute;\ntop: 0;\nleft: 0;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
fix typo: impersionation -> impersonation
|
95,115 |
14.11.2020 23:16:07
| -3,600 |
5f0fe0b6fe95cc413a4b740307e1ce13ec84a5b1
|
cscheck fixes
|
[
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/PermissionsParser.php",
"new_path": "src/Configuration/Parser/PermissionsParser.php",
"diff": "@@ -8,9 +8,6 @@ use Tightenco\\Collect\\Support\\Collection;\nclass PermissionsParser extends BaseParser\n{\n- /** @var string */\n- private $path;\n-\npublic function __construct(string $projectDir, string $filename = 'permissions.yaml')\n{\nparent::__construct($projectDir, $filename);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/DashboardController.php",
"new_path": "src/Controller/Backend/DashboardController.php",
"diff": "@@ -6,13 +6,9 @@ namespace Bolt\\Controller\\Backend;\nuse Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Storage\\Query;\n-use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n-/**\n- *\n- */\nclass DashboardController extends TwigAwareController implements BackendZoneInterface\n{\n/**\n@@ -20,7 +16,6 @@ class DashboardController extends TwigAwareController implements BackendZoneInte\n*/\npublic function index(Query $query): Response\n{\n-\n$this->denyAccessUnlessGranted('dashboard');\n// TODO PERMISSIONS: implement listing that only lists content that the user is allowed to see\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/GeneralController.php",
"new_path": "src/Controller/Backend/GeneralController.php",
"diff": "@@ -9,12 +9,9 @@ use Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Entity\\Content;\nuse Bolt\\Repository\\ContentRepository;\nuse Bolt\\Version;\n-use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n-/**\n- */\nclass GeneralController extends TwigAwareController implements BackendZoneInterface\n{\n/** @var \\Bolt\\Doctrine\\Version */\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/GlobalVoter.php",
"new_path": "src/Security/GlobalVoter.php",
"diff": "@@ -22,11 +22,12 @@ class GlobalVoter extends Voter\n$this->globalPermissions = $config->get('permissions/global');\nif (is_array($this->globalPermissions) || $this->globalPermissions instanceof \\ArrayAccess) {\n// TODO should we also validate that the values are all simple arrays?\n- foreach ($this->globalPermissions as $key => $value) {\n- $this->supportedAttributes[] = $key;\n+ $globalPermissionNames = array_keys($this->globalPermissions);\n+ foreach ($globalPermissionNames as $attribute) {\n+ $this->supportedAttributes[] = $attribute;\n}\n} else {\n- throw new \\DomainException(\"No global permissions config found\");\n+ throw new \\DomainException('No global permissions config found');\n}\n}\n@@ -49,7 +50,7 @@ class GlobalVoter extends Voter\n}\nif (! isset($this->globalPermissions[$attribute])) {\n- throw new \\DomainException(\"Global permission '$attribute' not defined, check your security and permissions configuration.\");\n+ throw new \\DomainException(\"Global permission '${attribute}' not defined, check your security and permissions configuration.\");\n}\n$rolesWithPermission = $this->globalPermissions[$attribute];\n@@ -58,6 +59,7 @@ class GlobalVoter extends Voter\nreturn true;\n}\n}\n+\nreturn false;\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
cscheck fixes
|
95,115 |
17.11.2020 20:34:05
| -3,600 |
c490800b1c730c9291ef3b8753dd4fef1e79bdcb
|
fix error - you can assume you'll receive a Collection
|
[
{
"change_type": "MODIFY",
"old_path": "src/Security/GlobalVoter.php",
"new_path": "src/Security/GlobalVoter.php",
"diff": "@@ -9,6 +9,7 @@ use Bolt\\Entity\\User;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\nuse Symfony\\Component\\Security\\Core\\Security;\n+use Tightenco\\Collect\\Support\\Collection;\nclass GlobalVoter extends Voter\n{\n@@ -20,9 +21,9 @@ class GlobalVoter extends Voter\n{\n$this->security = $security;\n$this->globalPermissions = $config->get('permissions/global');\n- if (is_array($this->globalPermissions) || $this->globalPermissions instanceof \\ArrayAccess) {\n+ if ($this->globalPermissions instanceof Collection) {\n// TODO should we also validate that the values are all simple arrays?\n- $globalPermissionNames = array_keys($this->globalPermissions);\n+ $globalPermissionNames = array_keys($this->globalPermissions->all());\nforeach ($globalPermissionNames as $attribute) {\n$this->supportedAttributes[] = $attribute;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
fix error - you can assume you'll receive a Collection
|
95,115 |
23.11.2020 00:53:58
| -3,600 |
83bdf84b1eb956744dc9b9abb50e1f81a4c06e0d
|
add permissions to cache check
|
[
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Config.php",
"new_path": "src/Configuration/Config.php",
"diff": "@@ -131,7 +131,7 @@ class Config\n//'permissions' => $this->parseConfigYaml('permissions.yml'),\n//'extensions' => $this->parseConfigYaml('extensions.yml'),\n- $timestamps = $this->getConfigFilesTimestamps($general, $taxonomy, $contentTypes, $menu, $theme);\n+ $timestamps = $this->getConfigFilesTimestamps($general, $taxonomy, $contentTypes, $menu, $theme, $permissions);\nreturn [\nDeepCollection::deepMake($config),\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
add permissions to cache check
|
95,115 |
23.11.2020 00:54:25
| -3,600 |
53feae31ee2816874a445ebf4342f55d6f7c1d3b
|
new voter for the OWNER attribute on content checks
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Security/ContentOwnerVoter.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Security;\n+\n+use Bolt\\Configuration\\Config;\n+use Bolt\\Entity\\Content;\n+use Bolt\\Entity\\User;\n+use Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\n+use Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\n+use Symfony\\Component\\Security\\Core\\Security;\n+\n+class ContentOwnerVoter extends Voter\n+{\n+ public const OWNER = 'OWNER';\n+\n+ private $security;\n+\n+ public function __construct(Security $security, Config $config)\n+ {\n+ $this->security = $security;\n+ }\n+\n+ protected function supports(string $attribute, $subject)\n+ {\n+ // only vote on `Content`\n+ if (! ($subject instanceof Content)) {\n+ return false;\n+ }\n+\n+ return $attribute === self::OWNER;\n+ }\n+\n+ protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n+ {\n+ $user = $token->getUser();\n+\n+ // Notice the check on a _Bolt_ user, other user classes that might implement UserInterface\n+ // cannot 'own' bolt content\n+ if (! $user instanceof User) {\n+ // the user must be logged in; if not, deny access\n+ return false;\n+ }\n+\n+ /** @var User $boltUser */\n+ $boltUser = $user;\n+\n+ /** @var Content $content */\n+ $content = $subject;\n+\n+ $author = $content->getAuthor();\n+\n+ return $author && ($author->getId() === $boltUser->getId());\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
new voter for the OWNER attribute on content checks
|
95,115 |
23.11.2020 00:54:44
| -3,600 |
6a421d18b34560d75bffa6b80527470489358533
|
permissions.yaml updates, work in progress
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -16,7 +16,7 @@ global:\nabout: [ IS_AUTHENTICATED_ANONYMOUSLY ] # view the 'About Bolt' page\n# checks: [ admin, developer ]\nclearcache: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n-# contentaction: [ editor, admin, developer ]\n+# contentaction: [ ROLE_EDITOR, admin, developer ]\ndashboard: [ IS_AUTHENTICATED_FULLY ]\n# dbcheck: [ admin, developer ]\n# dbupdate: [ admin, developer ]\n@@ -27,8 +27,8 @@ global:\n# files:config: [ developer ]\n# files:hidden: [ developer ]\n# files:theme: [ developer ]\n-# files:uploads: [ admin, developer, chief-editor, editor ]\n-# files: [ admin, developer, chief-editor, editor ]\n+# files:uploads: [ admin, developer, chief-editor, ROLE_EDITOR ]\n+# files: [ admin, developer, chief-editor, ROLE_EDITOR ]\n# prefill: [ developer ]\nprofile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\n# settings: [ admin, developer, everyone ]\n@@ -97,20 +97,29 @@ global:\n# permission can indirectly enable users more permissions\n# in ways that may not be immediately obvious.\n# - view: allows viewing records in the backend\n+\n+\n+\n+# these permissions will be added to _all_ contenttypes, they can not be overridden\ncontenttype-all:\n- edit: [ ROLE_DEVELOPER, admin, chief-editor ]\n- create: [ ROLE_DEVELOPER, admin, chief-editor ]\n- publish: [ ROLE_DEVELOPER, admin, chief-editor ]\n- depublish: [ ROLE_DEVELOPER, admin, chief-editor ]\n- delete: [ ROLE_DEVELOPER, admin ]\n- change-ownership: [ ROLE_DEVELOPER, admin ]\n- show-in-menu: [ IS_AUTHENTICATED_FULLY ]\n+ edit: [ ROLE_ADMIN ]\n+ create: [ ROLE_ADMIN ]\n+ publish: [ ROLE_ADMIN ]\n+ depublish: [ ROLE_ADMIN ]\n+ delete: [ ROLE_ADMIN ]\n+ change-ownership: [ ROLE_ADMIN ]\n+ view: [ ROLE_ADMIN ] # = show in menu, show listings, open 'edit' view without actually being able to edit, any of the other permissions always imply 'view'\n+# these permissions are used as a default for contenttypes\n+# you can override these settings per contenttype by adding it to the `contenttypes:` array\ncontenttype-default:\n- edit: [ editor ]\n- create: [ editor ]\n- change-ownership: [ owner ]\n- view: [ anonymous ]\n+ edit: [ ROLE_CHIEF_EDITOR ]\n+ create: [ ROLE_CHIEF_EDITOR ]\n+ change-ownership: [ CONTENT_OWNER ] # <-- how to handle chance-ownership permission without 'edit'?\n+ view: [ ROLE_CHIEF_EDITOR ]\n+# view: [ IS_AUTHENTICATED_FULLY ]\n+# show-in-menu: [ IS_AUTHENTICATED_FULLY ] # <-- not a useful permission after all\n+\ncontenttypes:\n@@ -125,12 +134,15 @@ contenttypes:\n# # amended.\n#\n# # Only the Admin and Chief Editor are allowed to edit records\n-# edit: [ admin, chief-editor ]\n-# create: [ admin, chief-editor ]\n-# publish: [ admin, chief-editor ]\n-# depublish: [ admin, chief-editor ]\n-# delete: [ admin, chief-editor ]\n-# # Roles that can see the area in the admin section\n-# view: [ developer, admin, chief-editor ]\n-# # Do not expose this content type on the front-end unless user is\n-# logged into the backend\n+# edit: [ ROLE_CHIEF_EDITOR ]\n+# create: [ ROLE_CHIEF_EDITOR ]\n+# publish: [ ROLE_CHIEF_EDITOR ]\n+# depublish: [ ROLE_CHIEF_EDITOR ]\n+# delete: [ ROLE_CHIEF_EDITOR ]\n+# show-in-menu: [ ROLE_CHIEF_EDITOR ]\n+ pages:\n+ edit: [ ROLE_EDITOR ]\n+ create: [ ROLE_EDITOR ]\n+ change-ownership: [ CONTENT_OWNER ]\n+ view: [ IS_AUTHENTICATED_FULLY ]\n+# show-in-menu: [ IS_AUTHENTICATED_FULLY ] #<-- not useful after all\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
permissions.yaml updates, work in progress
|
95,115 |
23.11.2020 00:55:22
| -3,600 |
4d4f9f66f8f52dfbe48b7967253c881fb690c4d6
|
GlobalVoter.php use widest check possible for User.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Security/GlobalVoter.php",
"new_path": "src/Security/GlobalVoter.php",
"diff": "@@ -5,10 +5,10 @@ declare(strict_types=1);\nnamespace Bolt\\Security;\nuse Bolt\\Configuration\\Config;\n-use Bolt\\Entity\\User;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\nuse Symfony\\Component\\Security\\Core\\Security;\n+use Symfony\\Component\\Security\\Core\\User\\UserInterface;\nuse Tightenco\\Collect\\Support\\Collection;\nclass GlobalVoter extends Voter\n@@ -45,7 +45,7 @@ class GlobalVoter extends Voter\n$user = $token->getUser();\n- if (! $user instanceof User) {\n+ if (! $user instanceof UserInterface) {\n// the user must be logged in; if not, deny access\nreturn false;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
GlobalVoter.php use widest check possible for User.
|
95,115 |
23.11.2020 00:56:19
| -3,600 |
fae7dab811d1f94ebd00e66a6fcaa767500a4cea
|
ContentVoter.php first stab at actually implementing the rules with all, default, and specific contenttype settings.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Security/ContentVoter.php",
"new_path": "src/Security/ContentVoter.php",
"diff": "@@ -5,11 +5,12 @@ declare(strict_types=1);\nnamespace Bolt\\Security;\nuse Bolt\\Configuration\\Config;\n+use Bolt\\Configuration\\Content\\ContentType;\nuse Bolt\\Entity\\Content;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\nuse Symfony\\Component\\Security\\Core\\Security;\n-use Symfony\\Component\\Security\\Core\\User\\User;\n+use Symfony\\Component\\Security\\Core\\User\\UserInterface;\nuse Tightenco\\Collect\\Support\\Collection;\nclass ContentVoter extends Voter\n@@ -28,90 +29,126 @@ class ContentVoter extends Voter\n# permission can indirectly enable users more permissions\n# in ways that may not be immediately obvious.\n*/\n- public const CONTENT_EDIT = 'content_edit';\n- public const CONTENT_CREATE = 'content_create';\n- public const CONTENT_PUBLISH = 'content_publish';\n- public const CONTENT_DEPUBLISH = 'content_depublish';\n- public const CONTENT_DELETE = 'content_delete';\n- public const CONTENT_CHANGE_OWNERSHIP = 'content_change-ownership';\n+ public const CONTENT_EDIT = 'edit';\n+ public const CONTENT_CREATE = 'create';\n+ public const CONTENT_PUBLISH = 'publish';\n+ public const CONTENT_DEPUBLISH = 'depublish';\n+ public const CONTENT_DELETE = 'delete';\n+ public const CONTENT_CHANGE_OWNERSHIP = 'change-ownership';\n+ public const CONTENT_VIEW = 'view';\nprivate $security;\nprivate $supportedAttributes;\n+ /** @var Collection|null */\n+ private $contenttypePermissionsAll;\n+ /** @var Collection|null */\n+ private $contenttypePermissionsDefault;\n+ /** @var Collection|null */\n+ private $contenttypePermissions;\n+\npublic function __construct(Security $security, Config $config)\n{\n$this->security = $security;\n- $config->get('permissions/contenttype-all');\n- $config->get('permissions/contenttype-default');\n- $config->get('permissions/contenttypes');\n+ $this->contenttypePermissionsAll = $config->get('permissions/contenttype-all', collect([]));\n+ $this->contenttypePermissionsDefault = $config->get('permissions/contenttype-default', collect([]));\n+ $this->contenttypePermissions = $config->get('permissions/contenttypes', null);\n- if ($this->globalPermissions instanceof Collection) {\n- // TODO should we also validate that the values are all simple arrays?\n- $globalPermissionNames = array_keys($this->globalPermissions->all());\n- foreach ($globalPermissionNames as $attribute) {\n- $this->supportedAttributes[] = $attribute;\n+ if (! ($this->contenttypePermissionsAll instanceof Collection)) {\n+ throw new \\DomainException('No permissions config found');\n}\n- } else {\n- throw new \\DomainException('No global permissions config found');\n+ if (! ($this->contenttypePermissionsDefault instanceof Collection)) {\n+ throw new \\DomainException('No permissions config found');\n+ }\n+ if (! ($this->contenttypePermissions == null || $this->contenttypePermissions instanceof Collection)) {\n+ throw new \\DomainException('No permissions config found');\n}\n}\nprotected function supports(string $attribute, $subject)\n{\n- // if the attribute isn't one we support, return false\n- if (! in_array($attribute, [self::CONTENT_EDIT, self::CONTENT_CREATE, self::CONTENT_PUBLISH,\n- self::CONTENT_DEPUBLISH, self::CONTENT_DELETE, self::CONTENT_CHANGE_OWNERSHIP,\n- self::CONTENT_VIEW, ], true)) {\n+ // only vote on `Content` and `ContentType` objects\n+ if (! ($subject instanceof Content || $subject instanceof ContentType)) {\nreturn false;\n}\n- return in_array($attribute, $this->supportedAttributes, true);\n- // only vote on `Content` objects\n- if (! $subject instanceof Content) {\n- return false;\n- }\n-\n- return true;\n+ // if the attribute isn't one we support, return false\n+ return in_array($attribute, [self::CONTENT_EDIT, self::CONTENT_CREATE, self::CONTENT_PUBLISH,\n+ self::CONTENT_DEPUBLISH, self::CONTENT_DELETE, self::CONTENT_CHANGE_OWNERSHIP,\n+ self::CONTENT_VIEW], true);\n}\nprotected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n{\n- if ($this->security->isGranted('ROLE_ADMIN')) {\n- return true;\n- }\n-\n$user = $token->getUser();\n- if (! $user instanceof User) {\n+ if (! $user instanceof UserInterface) {\n// the user must be logged in; if not, deny access\nreturn false;\n}\n- // you know $subject is a Post object, thanks to `supports()`\n+ // first check if the users has an 'all' permission set for this content(type)\n+ $allRoles = $this->contenttypePermissionsAll->get($attribute);\n+ if ($allRoles && $allRoles instanceof Collection) {\n+ // check if user is granted any of the specified attributes/roles\n+ foreach ($allRoles as $role) {\n+ if ($this->security->isGranted($role, $subject)) {\n+ return true;\n+ }\n+ }\n+ }\n+\n+ $contentTypeName = null;\n+ if ($subject instanceof Content) {\n/** @var Content $content */\n$content = $subject;\n-\n- switch ($attribute) {\n- case self::CONTENT_EDIT:\n- return $this->canEdit($content, $user);\n+ $contentTypeName = $content->getContentType();\n+ } else if ($subject instanceof ContentType) {\n+ /** @var ContentType $contentType */\n+ $contentType = $subject;\n+ $contentTypeName = $contentType->getSlug();\n+ } else {\n+ return false;\n}\n- throw new \\LogicException('This code should not be reached!');\n+ // try to find a contenttype specific setting first\n+ if ($this->contenttypePermissions) {\n+ $contenTypePermissions = $this->contenttypePermissions->get($contentTypeName);\n+ if ($contenTypePermissions) {\n+ $roles = $contenTypePermissions->get($attribute);\n+ if ($roles) {\n+ // check if user is granted any of the specified attributes/roles\n+ return $this->isGrantedAny($roles, $subject);\n+ }\n+ }\n}\n- private function canView(Content $content, User $user)\n- {\n- // if they can edit, they can view\n- if ($this->canEdit($content, $user)) {\n- return true;\n+ // if there was no specific rule for this contenttype + attribute, fall back to the default\n+ $contentTypeDefaultPermissions = $this->contenttypePermissionsDefault;\n+ if ($contentTypeDefaultPermissions) {\n+ $roles = $contentTypeDefaultPermissions->get($attribute);\n+\n+ if ($roles) {\n+ // check if user is granted any of the specified attributes/roles\n+ return $this->isGrantedAny($roles, $subject);\n+ }\n}\n+ // apparently there was no match -> deny!\nreturn false;\n+\n+// // Or do we always want to have a 'complete' setup, and throw an error here?\n+// throw new \\LogicException('This code should not be reached!');\n}\n- private function canEdit(Content $content, User $user)\n+ private function isGrantedAny($attributes, $subject = null)\n{\n- return $user === $content->getAuthor();\n+ foreach ($attributes as $attribute) {\n+ if ($this->security->isGranted($attribute, $subject)) {\n+ return true;\n+ }\n+ }\n+ return false;\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
ContentVoter.php first stab at actually implementing the rules with all, default, and specific contenttype settings.
|
95,115 |
23.11.2020 00:57:14
| -3,600 |
f494caee87c76dc9586b429b830ae6a84a42b6bf
|
Menu only show content types in menu where user has 'view' permission.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -7,12 +7,14 @@ namespace Bolt\\Menu;\nuse Bolt\\Configuration\\Config;\nuse Bolt\\Configuration\\Content\\ContentType;\nuse Bolt\\Repository\\ContentRepository;\n+use Bolt\\Security\\ContentVoter;\nuse Bolt\\Twig\\ContentExtension;\nuse Bolt\\Version;\nuse Knp\\Menu\\FactoryInterface;\nuse Knp\\Menu\\ItemInterface;\nuse Knp\\Menu\\MenuItem;\nuse Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\n+use Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface;\nuse Symfony\\Contracts\\Translation\\TranslatorInterface;\nfinal class BackendMenuBuilder implements BackendMenuBuilderInterface\n@@ -40,6 +42,9 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n/** @var ExtensionBackendMenuInterface[] */\nprivate $extensionMenus;\n+ /** @var AuthorizationCheckerInterface */\n+ private $authorizationChecker;\n+\npublic function __construct(\nFactoryInterface $menuFactory,\niterable $extensionMenus = [],\n@@ -47,7 +52,8 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\nContentRepository $contentRepository,\nUrlGeneratorInterface $urlGenerator,\nTranslatorInterface $translator,\n- ContentExtension $contentExtension\n+ ContentExtension $contentExtension,\n+ AuthorizationCheckerInterface $authorizationChecker\n) {\n$this->menuFactory = $menuFactory;\n$this->config = $config;\n@@ -56,6 +62,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n$this->translator = $translator;\n$this->contentExtension = $contentExtension;\n$this->extensionMenus = $extensionMenus;\n+ $this->authorizationChecker = $authorizationChecker;\n}\nprivate function createAdminMenu(): ItemInterface\n@@ -312,6 +319,10 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n$contentTypes = $this->config->get('contenttypes')->whereStrict('show_in_menu', true);\nforeach ($contentTypes as $contentType) {\n+ // add only if the user can 'view'\n+ if (! $this->authorizationChecker->isGranted(ContentVoter::CONTENT_VIEW, $contentType)) {\n+ continue;\n+ }\n$menu->addChild($contentType->getSlug(), [\n'uri' => $this->urlGenerator->generate('bolt_content_overview', ['contentType' => $contentType->getSlug()]),\n'extras' => [\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Menu only show content types in menu where user has 'view' permission.
|
95,115 |
23.11.2020 00:58:22
| -3,600 |
3cc51751acb5f45cd654ae84155ac82958aa90f1
|
added specific isGranted checks instead of general ROLE_ADMIN
|
[
{
"change_type": "MODIFY",
"old_path": "src/Twig/ContentExtension.php",
"new_path": "src/Twig/ContentExtension.php",
"diff": "@@ -18,6 +18,7 @@ use Bolt\\Enum\\Statuses;\nuse Bolt\\Log\\LoggerTrait;\nuse Bolt\\Repository\\ContentRepository;\nuse Bolt\\Repository\\TaxonomyRepository;\n+use Bolt\\Security\\ContentVoter;\nuse Bolt\\Storage\\Query;\nuse Bolt\\Utils\\ContentHelper;\nuse Bolt\\Utils\\Excerpt;\n@@ -410,7 +411,7 @@ class ContentExtension extends AbstractExtension\npublic function getDeleteLink(?Content $content, bool $absolute = false): ?string\n{\n- if (! $content instanceof Content || $content->getId() === null || ! $this->security->getUser() || ! $this->security->isGranted('ROLE_ADMIN')) {\n+ if (! $content instanceof Content || $content->getId() === null || ! $this->security->getUser() || ! $this->security->isGranted(ContentVoter::CONTENT_DELETE, $content)) {\nreturn null;\n}\n@@ -424,16 +425,17 @@ class ContentExtension extends AbstractExtension\npublic function getDuplicateLink(?Content $content, bool $absolute = false): ?string\n{\n- if (! $content instanceof Content || $content->getId() === null || ! $this->security->getUser() || ! $this->security->isGranted('ROLE_ADMIN')) {\n+ if (! $content instanceof Content || $content->getId() === null || ! $this->security->getUser() || ! $this->security->isGranted(ContentVoter::CONTENT_CREATE, $content)) {\nreturn null;\n}\nreturn $this->generateLink('bolt_content_duplicate', ['id' => $content->getId()], $absolute);\n}\n+ // TODO decide on voter - what _is_ a statuslink? Right now checking for 'view' permission\npublic function getStatusLink(?Content $content, bool $absolute = false): ?string\n{\n- if (! $content instanceof Content || $content->getId() === null || ! $this->security->getUser() || ! $this->security->isGranted('ROLE_ADMIN')) {\n+ if (! $content instanceof Content || $content->getId() === null || ! $this->security->getUser() || ! $this->security->isGranted(ContentVoter::CONTENT_VIEW, $content)) {\nreturn null;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
added specific isGranted checks instead of general ROLE_ADMIN
|
95,115 |
25.11.2020 10:18:55
| -3,600 |
f0c861bcd89b48d6e7602d8b428a805d6b3fa48f
|
added TODO PERMISSIONS to find this later.
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -60,7 +60,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @Route(\"/user-edit/add\", methods={\"GET\",\"POST\"}, name=\"bolt_user_add\")\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('ROLE_ADMIN')\") // TODO PERMISSIONS update permissions\n*/\npublic function add(Request $request): Response\n{\n@@ -186,7 +186,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @Route(\"/user-status/{id}\", methods={\"POST\", \"GET\"}, name=\"bolt_user_update_status\", requirements={\"id\": \"\\d+\"})\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('ROLE_ADMIN')\") // TODO PERMISSIONS update permissions\n*/\npublic function status(?User $user): Response\n{\n@@ -207,7 +207,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @Route(\"/user-delete/{id}\", methods={\"POST\", \"GET\"}, name=\"bolt_user_delete\", requirements={\"id\": \"\\d+\"})\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('ROLE_ADMIN')\") // TODO PERMISSIONS update permissions\n*/\npublic function delete(?User $user): Response\n{\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
added TODO PERMISSIONS to find this later.
|
95,115 |
25.11.2020 22:39:54
| -3,600 |
932e30a80d29011e8301b4449d9bc75d3da0c87a
|
create and implement detailed permissions for file editing
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -23,12 +23,13 @@ global:\n# dbupdate_result: [ admin, developer ]\nextensions: [ ROLE_DEVELOPER ]\n# extensions:config: [ developer ]\n- fileedit: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n-# files:config: [ developer ]\n-# files:hidden: [ developer ]\n-# files:theme: [ developer ]\n-# files:uploads: [ admin, developer, chief-editor, ROLE_EDITOR ]\n-# files: [ admin, developer, chief-editor, ROLE_EDITOR ]\n+\n+ # these control /bolt/file-edit and /bolt/filemanager -> combined create/read/update/delete permission\n+ # the part after the files: is the 'location' where the files are part of\n+ managefiles:config: [ ROLE_DEVELOPER ] # all configuration yml files /bolt/filemanager/config and /bolt/file-edit/config?file=/bolt/menu.yaml\n+ managefiles:files: [ ROLE_DEVELOPER ]\n+ managefiles:themes: [ ROLE_DEVELOPER ]\n+\n# prefill: [ developer ]\nprofile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\n# settings: [ admin, developer, everyone ]\n@@ -44,7 +45,7 @@ global:\nsystemlog: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n# NEW ???\nbulk_operations: [ ROLE_CHIEF_EDITOR ]\n- fixtures: [ ROLE_DEVELOPER ]\n+ fixtures: [ ROLE_DEVELOPER ] # <-- controller route exists, but fixtures support hasn't been implemented yet\nkitchensink: [ ROLE_DEVELOPER ]\n@@ -96,7 +97,7 @@ global:\n# grant additional permissions on a record, so this\n# permission can indirectly enable users more permissions\n# in ways that may not be immediately obvious.\n-# - view: allows viewing records in the backend\n+# - view: allows viewing records in the backend (listings, content/fields)\n@@ -144,5 +145,6 @@ contenttypes:\nedit: [ ROLE_EDITOR ]\ncreate: [ ROLE_EDITOR ]\nchange-ownership: [ CONTENT_OWNER ]\n- view: [ IS_AUTHENTICATED_FULLY ]\n+ view: [ ROLE_USER ]\n+# view: [ IS_AUTHENTICATED_FULLY ]\n# show-in-menu: [ IS_AUTHENTICATED_FULLY ] #<-- not useful after all\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/FileEditController.php",
"new_path": "src/Controller/Backend/FileEditController.php",
"diff": "@@ -8,7 +8,6 @@ use Bolt\\Controller\\CsrfTrait;\nuse Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Repository\\MediaRepository;\nuse Doctrine\\ORM\\EntityManagerInterface;\n-use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\nuse Symfony\\Component\\Filesystem\\Filesystem;\nuse Symfony\\Component\\HttpFoundation\\JsonResponse;\nuse Symfony\\Component\\HttpFoundation\\RedirectResponse;\n@@ -23,9 +22,6 @@ use Webimpress\\SafeWriter\\Exception\\ExceptionInterface;\nuse Webimpress\\SafeWriter\\FileWriter;\nuse Webmozart\\PathUtil\\Path;\n-/**\n- * @Security(\"is_granted('fileedit')\")\n- */\nclass FileEditController extends TwigAwareController implements BackendZoneInterface\n{\nuse CsrfTrait;\n@@ -52,6 +48,8 @@ class FileEditController extends TwigAwareController implements BackendZoneInter\n*/\npublic function edit(string $location): Response\n{\n+ $this->denyAccessUnlessGranted('managefiles:' . $location);\n+\n$file = $this->getFromRequest('file');\nif (mb_strpos($file, '/') !== 0) {\n$file = '/' . $file;\n@@ -80,6 +78,9 @@ class FileEditController extends TwigAwareController implements BackendZoneInter\n$file = $this->getFromRequest('file');\n$locationName = $this->getFromRequest('location');\n+\n+ $this->denyAccessUnlessGranted('managefiles:' . $locationName);\n+\n$contents = $this->getFromRequestRaw('editfile');\n$extension = Path::getExtension($file);\n@@ -128,6 +129,9 @@ class FileEditController extends TwigAwareController implements BackendZoneInter\n}\n$locationName = $this->getFromRequest('location', '');\n+\n+ $this->denyAccessUnlessGranted('managefiles:' . $locationName);\n+\n$path = $this->getFromRequest('path', '');\n$media = $this->mediaRepository->findOneByFullFilename($path, $locationName);\n@@ -173,6 +177,9 @@ class FileEditController extends TwigAwareController implements BackendZoneInter\n}\n$locationName = $this->getFromRequest('location', '');\n+\n+ $this->denyAccessUnlessGranted('managefiles:' . $locationName);\n+\n$path = $this->getFromRequest('path', '');\n$originalFilepath = Path::canonicalize($locationName . '/' . $path);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/FilemanagerController.php",
"new_path": "src/Controller/Backend/FilemanagerController.php",
"diff": "@@ -24,9 +24,6 @@ use Symfony\\Component\\Security\\Core\\Exception\\InvalidCsrfTokenException;\nuse Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface;\nuse Webmozart\\PathUtil\\Path;\n-/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n- */\nclass FilemanagerController extends TwigAwareController implements BackendZoneInterface\n{\nuse CsrfTrait;\n@@ -59,6 +56,8 @@ class FilemanagerController extends TwigAwareController implements BackendZoneIn\n*/\npublic function filemanager(string $location): Response\n{\n+ $this->denyAccessUnlessGranted('managefiles:' . $location);\n+\n$path = $this->getFromRequest('path', '');\nif (str::endsWith($path, '/') === false) {\n$path .= '/';\n@@ -110,6 +109,9 @@ class FilemanagerController extends TwigAwareController implements BackendZoneIn\n$path = $this->getFromRequest('path');\n$location = $this->getFromRequest('location');\n+\n+ $this->denyAccessUnlessGranted('managefiles:' . $location);\n+\n$location = $this->fileLocations->get($location);\n$folder = Path::canonicalize($location->getBasepath() . '/' . $path);\n@@ -148,6 +150,9 @@ class FilemanagerController extends TwigAwareController implements BackendZoneIn\n$path = $this->getFromRequest('path') . $this->getFromRequest('folderName');\n$location = $this->getFromRequest('location');\n+\n+ $this->denyAccessUnlessGranted('managefiles:' . $location);\n+\n$location = $this->fileLocations->get($location);\n$folder = Path::canonicalize($location->getBasepath() . '/' . $path);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
create and implement detailed permissions for file editing
|
95,115 |
26.11.2020 00:15:33
| -3,600 |
d8d9c711bdfe88c2dee64b9d5debb0879dccbb72
|
add developer role ('above' admin at the moment)
|
[
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/UserFixtures.php",
"new_path": "src/DataFixtures/UserFixtures.php",
"diff": "@@ -124,6 +124,13 @@ class UserFixtures extends BaseFixture implements FixtureGroupInterface\n'email' => 'john_user@example.org',\n'roles' => ['ROLE_USER'],\n],\n+ [\n+ 'displayname' => 'Developer',\n+ 'username' => 'developer',\n+ 'password' => $this->append ? Str::generatePassword(10) : 'developer%1',\n+ 'email' => 'developer@example.org',\n+ 'roles' => ['ROLE_DEVELOPER'],\n+ ],\n];\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
add developer role ('above' admin at the moment)
|
95,115 |
26.11.2020 00:15:56
| -3,600 |
959b523cc3b6d49705c309a0aa5eed9ae5d97694
|
only allow developer to switch user
|
[
{
"change_type": "MODIFY",
"old_path": "config/packages/security.yaml",
"new_path": "config/packages/security.yaml",
"diff": "@@ -24,7 +24,7 @@ security:\npattern: ^/\nanonymous: true\nuser_checker: Bolt\\Security\\UserChecker\n- switch_user: true\n+ switch_user: { role: CAN_SWITCH_USER }\nguard:\nauthenticators:\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Security/SwitchUserVoter.php",
"diff": "+<?php\n+\n+\n+namespace Bolt\\Security;\n+\n+use Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\n+use Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\n+use Symfony\\Component\\Security\\Core\\Security;\n+use Symfony\\Component\\Security\\Core\\User\\UserInterface;\n+\n+class SwitchUserVoter extends Voter\n+{\n+ private $security;\n+\n+ public function __construct(Security $security)\n+ {\n+ $this->security = $security;\n+ }\n+\n+ protected function supports($attribute, $subject)\n+ {\n+ return $attribute === 'CAN_SWITCH_USER'\n+ && $subject instanceof UserInterface;\n+ }\n+\n+ protected function voteOnAttribute($attribute, $subject, TokenInterface $token)\n+ {\n+ $user = $token->getUser();\n+ // if the user is anonymous or if the subject is not a user, do not grant access\n+ if (!$user instanceof UserInterface || !$subject instanceof UserInterface) {\n+ return false;\n+ }\n+\n+ if ($this->security->isGranted('ROLE_DEVELOPER')) {\n+ return true;\n+ }\n+\n+ /*\n+ * or use some custom data from your User object\n+ if ($user->isAllowedToSwitch()) {\n+ return true;\n+ }\n+ */\n+\n+ return false;\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
only allow developer to switch user
|
95,115 |
26.11.2020 00:16:46
| -3,600 |
40d6ad7ec68db6e640f93fc5808f82b93dc5142c
|
comment to remember to update permission
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -111,6 +111,8 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @Route(\"/user-edit/{id}\", methods={\"GET\",\"POST\"}, name=\"bolt_user_edit\", requirements={\"id\": \"\\d+\"})\n* @Route(\"/profile-edit\", methods={\"GET\",\"POST\"}, name=\"bolt_profile_edit\")\n+ *\n+ * // TODO PERMISSIONS update permissions\n*/\npublic function edit(?User $user, Request $request): Response\n{\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
comment to remember to update permission
|
95,115 |
26.11.2020 00:17:00
| -3,600 |
23a640b5e5444a11fc2793bced0e11a8c0c3b686
|
permissions.yaml work in progress
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -18,16 +18,14 @@ global:\nclearcache: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n# contentaction: [ ROLE_EDITOR, admin, developer ]\ndashboard: [ IS_AUTHENTICATED_FULLY ]\n-# dbcheck: [ admin, developer ]\n-# dbupdate: [ admin, developer ]\n-# dbupdate_result: [ admin, developer ]\n+\nextensions: [ ROLE_DEVELOPER ]\n# extensions:config: [ developer ]\n# these control /bolt/file-edit and /bolt/filemanager -> combined create/read/update/delete permission\n# the part after the files: is the 'location' where the files are part of\nmanagefiles:config: [ ROLE_DEVELOPER ] # all configuration yml files /bolt/filemanager/config and /bolt/file-edit/config?file=/bolt/menu.yaml\n- managefiles:files: [ ROLE_DEVELOPER ]\n+ managefiles:files: [ ROLE_ADMIN ]\nmanagefiles:themes: [ ROLE_DEVELOPER ]\n# prefill: [ developer ]\n@@ -43,7 +41,7 @@ global:\n# # Access to the various logs\n# changelog: [ admin, developer, chief-editor ]\nsystemlog: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n-# NEW ???\n+# NEW\nbulk_operations: [ ROLE_CHIEF_EDITOR ]\nfixtures: [ ROLE_DEVELOPER ] # <-- controller route exists, but fixtures support hasn't been implemented yet\nkitchensink: [ ROLE_DEVELOPER ]\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
permissions.yaml work in progress
|
95,115 |
27.11.2020 22:37:12
| -3,600 |
a15e40ecf20708d82b73053a04c3ddf6ac4c297b
|
workable UserEditController.php, lots of work in progress
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "# and understand the consequences of making uninformed changes to the roles and\n# permissions.\n+# roles that are presented in the list when editing a user\n+# these will be filtered based on the user's own level to make sure you don't assign\n+# roles 'above' yourself.\n+# TODO implement\n+# note: ROLE_USER is assigned to Bolt Entity Users if no roles have been set\n+assignable_roles: [ROLE_DEVELOPER, ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR, ROLE_USER]\n+# some roles are not in the role hierarchy and not assigned to 'normal' back end users\n+# if they should be assignable you need to add them here\n+assignable_roles_unchecked: [ROLE_USER_FRONTEND_GROUP1, ROLE_USER_FRONTEND_GROUP2]\n+\n+\n# These permissions are the 'global' permissions; these are not tied\n# to any content types, but rather apply to global, non-content activity in\n# Bolt's backend. Most of these permissions map directly to backend routes;\n# inside the code, so they don't appear here.\nglobal:\nabout: [ IS_AUTHENTICATED_ANONYMOUSLY ] # view the 'About Bolt' page\n-# checks: [ admin, developer ]\nclearcache: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n-# contentaction: [ ROLE_EDITOR, admin, developer ]\ndashboard: [ IS_AUTHENTICATED_FULLY ]\n-\nextensions: [ ROLE_DEVELOPER ]\n-# extensions:config: [ developer ]\n-\n# these control /bolt/file-edit and /bolt/filemanager -> combined create/read/update/delete permission\n# the part after the files: is the 'location' where the files are part of\nmanagefiles:config: [ ROLE_DEVELOPER ] # all configuration yml files /bolt/filemanager/config and /bolt/file-edit/config?file=/bolt/menu.yaml\nmanagefiles:files: [ ROLE_ADMIN ]\nmanagefiles:themes: [ ROLE_DEVELOPER ]\n-\n# prefill: [ developer ]\nprofile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\n# settings: [ admin, developer, everyone ]\n# translation: [ developer ]\n-# useraction: [ admin, developer ] # enable/disable/delete\n- useredit: [ admin, developer ] # user settings\n-# users: [ admin, developer ] # view user overview\n-# roles: [ admin, developer ] # view the roles overview\n+ user:list: [ ROLE_ADMIN ] # overview listing of users and a list of active sessions\n+ user:add: [ ROLE_ADMIN ] # add user - allows editing user _before_ saving, after saving 'useredit' is needed. -> cannot give roles above 'self'\n+ user:status: [ ROLE_ADMIN ] # user enable/disable -> cannot enable/disable users with roles above 'self'\n+ user:delete: [ ROLE_ADMIN ] # user delete -> cannot delete users with roles above 'self'\n+ user:edit: [ ROLE_ADMIN ] # user edit all fields, including status -> cannot give roles above 'self'\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\nomnisearch: [ IS_AUTHENTICATED_ANONYMOUSLY ]\n# # Access to the various logs\n@@ -140,7 +146,7 @@ contenttypes:\n# delete: [ ROLE_CHIEF_EDITOR ]\n# show-in-menu: [ ROLE_CHIEF_EDITOR ]\npages:\n- edit: [ ROLE_EDITOR ]\n+ edit: [ ROLE_EDITOR, CONTENT_OWNER ]\ncreate: [ ROLE_EDITOR ]\nchange-ownership: [ CONTENT_OWNER ]\nview: [ ROLE_USER ]\n"
},
{
"change_type": "MODIFY",
"old_path": "config/packages/security.yaml",
"new_path": "config/packages/security.yaml",
"diff": "security:\nrole_hierarchy:\n- ROLE_DEVELOPER: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]\n- ROLE_ADMIN: [ROLE_CHIEF_EDITOR, ROLE_ALLOWED_TO_SWITCH]\n+ ROLE_DEVELOPER: [ROLE_ADMIN]\n+ ROLE_ADMIN: [ROLE_CHIEF_EDITOR]\nROLE_CHIEF_EDITOR: [ROLE_EDITOR]\nROLE_EDITOR: [ROLE_USER]\n+ # ROLE_USER is assigned to Bolt Entity Users if no roles have been set\nROLE_USER: []\nencoders:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/PermissionsParser.php",
"new_path": "src/Configuration/Parser/PermissionsParser.php",
"diff": "@@ -4,6 +4,7 @@ declare(strict_types=1);\nnamespace Bolt\\Configuration\\Parser;\n+use Bolt\\Common\\Arr;\nuse Tightenco\\Collect\\Support\\Collection;\nclass PermissionsParser extends BaseParser\n@@ -18,8 +19,19 @@ class PermissionsParser extends BaseParser\n*/\npublic function parse(): Collection\n{\n- $permissionConfig = $this->parseConfigYaml($this->getInitialFilename());\n+ $defaultConfig = $this->getDefaultConfig();\n+ $yamlConfig = $this->parseConfigYaml($this->getInitialFilename());\n+ $permissionConfig = Arr::replaceRecursive($defaultConfig, $yamlConfig);\nreturn new Collection($permissionConfig);\n}\n+\n+ protected function getDefaultConfig(): array\n+ {\n+ // TODO PERMISSIONS add more defaults\n+ return [\n+ 'assignable_roles' => ['ROLE_DEVELOPER', 'ROLE_ADMIN', 'ROLE_CHIEF_EDITOR', 'ROLE_EDITOR', 'ROLE_USER'],\n+ 'assignable_roles_unchecked' => []\n+ ];\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserController.php",
"new_path": "src/Controller/Backend/UserController.php",
"diff": "@@ -14,7 +14,9 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * Display the list of users, along with buttons to change them.\n+ *\n+ * @Security(\"is_granted('user:list')\")\n*/\nclass UserController extends TwigAwareController implements BackendZoneInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -5,6 +5,7 @@ declare(strict_types=1);\nnamespace Bolt\\Controller\\Backend;\nuse Bolt\\Common\\Str;\n+use Bolt\\Configuration\\Config;\nuse Bolt\\Controller\\CsrfTrait;\nuse Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Entity\\User;\n@@ -42,12 +43,16 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\nprotected $defaultLocale;\n+ private $assignableRoles;\n+ private $assignableRolesUnchecked;\n+\npublic function __construct(\nUrlGeneratorInterface $urlGenerator,\nEntityManagerInterface $em,\nUserPasswordEncoderInterface $passwordEncoder,\nCsrfTokenManagerInterface $csrfTokenManager,\nEventDispatcherInterface $dispatcher,\n+ Config $config,\nstring $defaultLocale\n) {\n$this->urlGenerator = $urlGenerator;\n@@ -56,11 +61,13 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n$this->csrfTokenManager = $csrfTokenManager;\n$this->dispatcher = $dispatcher;\n$this->defaultLocale = $defaultLocale;\n+ $this->assignableRoles = $config->get('permissions/assignable_roles')->all();\n+ $this->assignableRolesUnchecked = $config->get('permissions/assignable_roles_unchecked')->all();\n}\n/**\n* @Route(\"/user-edit/add\", methods={\"GET\",\"POST\"}, name=\"bolt_user_add\")\n- * @Security(\"is_granted('ROLE_ADMIN')\") // TODO PERMISSIONS update permissions\n+ * @Security(\"is_granted('user:add')\") -- first check, more detailed checks in method\n*/\npublic function add(Request $request): Response\n{\n@@ -69,8 +76,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n$event = new UserEvent($user);\n$this->dispatcher->dispatch($event, UserEvent::ON_ADD);\n-\n- $roles = array_merge($this->getParameter('security.role_hierarchy.roles'), $event->getRoleOptions()->toArray());\n+ $roles = $this->_getPossibleRoles($event);\n// These are the variables we have to pass into our FormType so we can build the fields correctly\n$form_data = [\n@@ -112,7 +118,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n* @Route(\"/user-edit/{id}\", methods={\"GET\",\"POST\"}, name=\"bolt_user_edit\", requirements={\"id\": \"\\d+\"})\n* @Route(\"/profile-edit\", methods={\"GET\",\"POST\"}, name=\"bolt_profile_edit\")\n*\n- * // TODO PERMISSIONS update permissions\n+ * @Security(\"is_granted('user:edit')\") -- first check, more detailed checks in method\n*/\npublic function edit(?User $user, Request $request): Response\n{\n@@ -125,10 +131,13 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n$is_profile_edit = true;\n}\n+ // don't allow editing a user with higher roles then yourself\n+ $this->_denyUnlessRolesAssignable($user->getRoles());\n+\n$event = new UserEvent($user);\n$this->dispatcher->dispatch($event, UserEvent::ON_EDIT);\n- $roles = array_merge($this->getParameter('security.role_hierarchy.roles'), $event->getRoleOptions()->toArray());\n+ $roles = $this->_getPossibleRoles($event);\n// We don't require the user to set the password again on the \"user edit\" form\n// If it is otherwise set use the given password normally\n@@ -188,12 +197,14 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @Route(\"/user-status/{id}\", methods={\"POST\", \"GET\"}, name=\"bolt_user_update_status\", requirements={\"id\": \"\\d+\"})\n- * @Security(\"is_granted('ROLE_ADMIN')\") // TODO PERMISSIONS update permissions\n+ * @Security(\"is_granted('user:status')\") -- first check, more detailed checks in method\n*/\n- public function status(?User $user): Response\n+ public function status(User $user): Response\n{\n$this->validateCsrf('useredit');\n+ $this->_denyUnlessRolesAssignable($user->getRoles());\n+\n$newStatus = $this->request->get('status', UserStatus::DISABLED);\n$user->setStatus($newStatus);\n@@ -209,12 +220,14 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @Route(\"/user-delete/{id}\", methods={\"POST\", \"GET\"}, name=\"bolt_user_delete\", requirements={\"id\": \"\\d+\"})\n- * @Security(\"is_granted('ROLE_ADMIN')\") // TODO PERMISSIONS update permissions\n+ * @Security(\"is_granted('user:delete')\") -- first check, more detailed checks in method\n*/\n- public function delete(?User $user): Response\n+ public function delete(User $user): Response\n{\n$this->validateCsrf('useredit');\n+ $this->_denyUnlessRolesAssignable($user->getRoles());\n+\n$this->em->remove($user);\n$contentArray = $this->getDoctrine()->getManager()->getRepository(\\Bolt\\Entity\\Content::class)->findBy(['author' => $user]);\nforeach ($contentArray as $content) {\n@@ -237,8 +250,9 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n}\n/**\n- * This function is called by add and edit function if given form was submitted and validated correctly\n- * Here the User Object will be persisted to the DB\n+ * This function is called by add and edit function if given form was submitted and validated correctly.\n+ * Here the User Object will be persisted to the DB. A security exception will be raised if the roles\n+ * for the user being saved are not allowed for the current logged user.\n*/\nprivate function _handleValidFormSubmit(FormInterface $form): void\n{\n@@ -246,6 +260,8 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/** @var User $user */\n$user = $form->getData();\n+ $this->_denyUnlessRolesAssignable($user->getRoles());\n+\n// Once validated, encode the password\nif ($user->getPlainPassword()) {\n$user->setPassword($this->passwordEncoder->encodePassword($user, $user->getPlainPassword()));\n@@ -264,4 +280,48 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n$this->addFlash('success', 'user.updated_profile');\n}\n+\n+ /**\n+ * @param UserEvent $event\n+ * @return array\n+ */\n+ private function _getPossibleRoles(UserEvent $event): array\n+ {\n+ // TODO - Maybe the roles defined in role_hierarchy are not necessarily the roles we want to allow to be 'set'\n+ // here. It is not _required_ for roles to be specified in the role_hierarchy, as it is just a utility to\n+ // configure a hierarchy and make life easier.\n+ // Change this to get the roles from the permissions.yaml\n+//\n+// // only allow user to assign system roles they have themselves, use ARRAY_FILTER_USE_KEY as the role names are the keys (values are a list of roles they inherit)\n+// $filteredSystemRoles = array_filter($this->getParameter('security.role_hierarchy.roles'), function ($role) {\n+// return $this->isGranted($role);\n+// }, ARRAY_FILTER_USE_KEY);\n+// // allow all roles added by extensions to be assigned (At the moment this seems the best solution to handle these)\n+// $extensionSuppliedRoles = $event->getRoleOptions()->toArray();\n+// $roles = array_merge($filteredSystemRoles, $extensionSuppliedRoles);\n+ $roleHierarchy = $this->getParameter('security.role_hierarchy.roles');\n+ $result = [];\n+ foreach ($this->assignableRoles as $assignableRole) {\n+ if (in_array($assignableRole, $this->assignableRolesUnchecked, true) || $this->isGranted($assignableRole)) {\n+ if (isset($roleHierarchy[$assignableRole])) {\n+ $result[$assignableRole] = $roleHierarchy[$assignableRole];\n+ } else {\n+ $result[$assignableRole] = [];\n+ }\n+ }\n+ }\n+ return $result;\n+ }\n+\n+ private function _denyUnlessRolesAssignable($roles) {\n+ // check if there is no attempt to assign roles that are not granted to the current logged in user\n+ foreach ($roles as $role) {\n+ if (in_array($role, $this->assignableRolesUnchecked, true)) {\n+ // skip checking roles specified as unchecked\n+ continue;\n+ }\n+ $this->denyAccessUnlessGranted($role);\n+ }\n+ }\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/ContentOwnerVoter.php",
"new_path": "src/Security/ContentOwnerVoter.php",
"diff": "@@ -4,39 +4,26 @@ declare(strict_types=1);\nnamespace Bolt\\Security;\n-use Bolt\\Configuration\\Config;\nuse Bolt\\Entity\\Content;\nuse Bolt\\Entity\\User;\nuse Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\n-use Symfony\\Component\\Security\\Core\\Security;\nclass ContentOwnerVoter extends Voter\n{\n- public const OWNER = 'OWNER';\n-\n- private $security;\n-\n- public function __construct(Security $security, Config $config)\n- {\n- $this->security = $security;\n- }\n+ public const OWNER = 'CONTENT_OWNER';\nprotected function supports(string $attribute, $subject)\n{\n// only vote on `Content`\n- if (! ($subject instanceof Content)) {\n- return false;\n- }\n-\n- return $attribute === self::OWNER;\n+ return $attribute === self::OWNER && $subject instanceof Content;\n}\nprotected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n{\n$user = $token->getUser();\n- // Notice the check on a _Bolt_ user, other user classes that might implement UserInterface\n+ // Notice the check on a _Bolt_ user entity, other user classes that might implement UserInterface\n// cannot 'own' bolt content\nif (! $user instanceof User) {\n// the user must be logged in; if not, deny access\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/SwitchUserVoter.php",
"new_path": "src/Security/SwitchUserVoter.php",
"diff": "@@ -8,6 +8,18 @@ use Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\nuse Symfony\\Component\\Security\\Core\\Security;\nuse Symfony\\Component\\Security\\Core\\User\\UserInterface;\n+/**\n+ * Class SwitchUserVoter votes on the 'switch user' permission - the ability to impersonate another user. This is\n+ * extremely powerful and can be abused. Therefore it is not configurable in bolt's permissions.yaml.\n+ * This Voter is enabled by the following piece of symfony security configuration:\n+ *\n+ * switch_user: { role: CAN_SWITCH_USER }\n+ *\n+ * in a firewall definition.\n+ * If it is configured like above only users with ROLE_DEVELOPER can impersonate.\n+ *\n+ * @package Bolt\\Security\n+ */\nclass SwitchUserVoter extends Voter\n{\nprivate $security;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
workable UserEditController.php, lots of work in progress
|
95,115 |
28.11.2020 23:22:35
| -3,600 |
432375739437a19c91b47136892ff564de7510ca
|
getting somewhere, started implementing permissions in ContentEditController.php
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -49,8 +49,9 @@ global:\nsystemlog: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n# NEW\nbulk_operations: [ ROLE_CHIEF_EDITOR ]\n- fixtures: [ ROLE_DEVELOPER ] # <-- controller route exists, but fixtures support hasn't been implemented yet\nkitchensink: [ ROLE_DEVELOPER ]\n+ upload: [ ROLE_EDITOR ] # upload media/files\n+ extensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\n# For content type related actions, permissions can be set individually for\n@@ -93,9 +94,7 @@ global:\n#\n# - edit: allows updating existing records\n# - create: allows creating new records\n-# - publish: allows changing the status of a record to \"published\", as well as\n-# scheduling a record for future publishing\n-# - depublish: allows changing the status of a record from \"published\"\n+# - change-status: allows changing the published status of a record\n# - delete: allows (hard) deletion of records\n# - change-ownership: allows changing a record's owner. Note that ownership may\n# grant additional permissions on a record, so this\n@@ -109,8 +108,7 @@ global:\ncontenttype-all:\nedit: [ ROLE_ADMIN ]\ncreate: [ ROLE_ADMIN ]\n- publish: [ ROLE_ADMIN ]\n- depublish: [ ROLE_ADMIN ]\n+ change-status: [ ROLE_ADMIN ]\ndelete: [ ROLE_ADMIN ]\nchange-ownership: [ ROLE_ADMIN ]\nview: [ ROLE_ADMIN ] # = show in menu, show listings, open 'edit' view without actually being able to edit, any of the other permissions always imply 'view'\n@@ -118,7 +116,7 @@ contenttype-all:\n# these permissions are used as a default for contenttypes\n# you can override these settings per contenttype by adding it to the `contenttypes:` array\ncontenttype-default:\n- edit: [ ROLE_CHIEF_EDITOR ]\n+ edit: [ ROLE_CHIEF_EDITOR, CONTENT_OWNER ]\ncreate: [ ROLE_CHIEF_EDITOR ]\nchange-ownership: [ CONTENT_OWNER ] # <-- how to handle chance-ownership permission without 'edit'?\nview: [ ROLE_CHIEF_EDITOR ]\n@@ -141,8 +139,7 @@ contenttypes:\n# # Only the Admin and Chief Editor are allowed to edit records\n# edit: [ ROLE_CHIEF_EDITOR ]\n# create: [ ROLE_CHIEF_EDITOR ]\n-# publish: [ ROLE_CHIEF_EDITOR ]\n-# depublish: [ ROLE_CHIEF_EDITOR ]\n+# change-status: [ ROLE_CHIEF_EDITOR ]\n# delete: [ ROLE_CHIEF_EDITOR ]\n# show-in-menu: [ ROLE_CHIEF_EDITOR ]\npages:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/Async/UploadController.php",
"new_path": "src/Controller/Backend/Async/UploadController.php",
"diff": "@@ -30,7 +30,7 @@ use Throwable;\nuse Webmozart\\PathUtil\\Path;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('upload')\")\n*/\nclass UploadController extends AbstractController implements AsyncZoneInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ContentEditController.php",
"new_path": "src/Controller/Backend/ContentEditController.php",
"diff": "@@ -22,6 +22,7 @@ use Bolt\\Repository\\FieldRepository;\nuse Bolt\\Repository\\MediaRepository;\nuse Bolt\\Repository\\RelationRepository;\nuse Bolt\\Repository\\TaxonomyRepository;\n+use Bolt\\Security\\ContentVoter;\nuse Bolt\\Utils\\TranslationsManager;\nuse Bolt\\Validator\\ContentValidatorInterface;\nuse Carbon\\Carbon;\n@@ -106,6 +107,9 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n$content->setAuthor($user);\n$content->setContentType($contentType);\n+ // content now has a contentType -> permission check possible\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_CREATE, $content);\n+\n$this->contentFillListener->fillContent($content);\nif ($this->request->getMethod() === 'POST') {\n@@ -120,6 +124,8 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n*/\npublic function edit(Content $content): Response\n{\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_EDIT, $content);\n+\n$event = new ContentEvent($content);\n$this->dispatcher->dispatch($event, ContentEvent::ON_EDIT);\n@@ -135,6 +141,15 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n$content = $this->contentFromPost($content);\n+ // TODO PERMISSIONS -- we also have to check for status (and future: owner) changes\n+ // hmm, how to handle changes of status for a new item? Is that a thing? --> maybe prevent changing from the default?\n+ /*\n+ status \"[\\\"published\\\"]\"\n+ publishedAt \"2020-10-23T02:20:41.000Z\"\n+ depublishedAt \"\"\n+ */\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_EDIT, $content);\n+\n// check if validator should be enabled (default for bolt 4.x is not enabled)\n$enableContentValidator = $this->config->get('general/validator_options/enable', false);\nif ($enableContentValidator && $contentValidator) {\n@@ -175,6 +190,8 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n$this->validateCsrf('editrecord');\n$content = $this->contentFromPost($content);\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_VIEW, $content);\n+\n$recordSlug = $content->getDefinition()->get('singular_slug');\n$event = new ContentEvent($content);\n@@ -195,6 +212,8 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n*/\npublic function duplicate(Content $content): Response\n{\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_CREATE, $content);\n+\n/** @var User $user */\n$user = $this->getUser();\n@@ -223,6 +242,8 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n*/\npublic function duplicateSave(?Content $content = null): Response\n{\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_CREATE, $content);\n+\nreturn $this->new($content->getContentType());\n}\n@@ -233,6 +254,8 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n{\n$this->validateCsrf('status');\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_CHANGE_STATUS, $content);\n+\n$content->setStatus($this->getFromRequest('status'));\n$event = new ContentEvent($content);\n@@ -259,6 +282,8 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n{\n$this->validateCsrf('delete');\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_DELETE, $content);\n+\n$event = new ContentEvent($content);\n$this->dispatcher->dispatch($event, ContentEvent::PRE_DELETE);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ContentLocalizationController.php",
"new_path": "src/Controller/Backend/ContentLocalizationController.php",
"diff": "@@ -6,11 +6,15 @@ namespace Bolt\\Controller\\Backend;\nuse Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Entity\\Content;\n+use Bolt\\Security\\ContentVoter;\nuse Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n+ * Permissions for this controller follow ContentEditController - you can see the localization status if you have\n+ * 'view' permission on this item.\n+ *\n* @Security(\"is_granted('ROLE_ADMIN')\")\n*/\nclass ContentLocalizationController extends TwigAwareController implements BackendZoneInterface\n@@ -20,6 +24,7 @@ class ContentLocalizationController extends TwigAwareController implements Backe\n*/\npublic function locales(Content $content): Response\n{\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_VIEW, $content);\n$content->getFields();\nreturn $this->render('@bolt/content/view_locales.html.twig', [\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/MenuPageController.php",
"new_path": "src/Controller/Backend/MenuPageController.php",
"diff": "@@ -10,7 +10,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * TODO PERMISSIONS removed check here - check if checks in twig are set. (probably not in twig itself but in the admin_menu_array() call)\n*/\nclass MenuPageController extends TwigAwareController implements BackendZoneInterface\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -17,6 +17,13 @@ use Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\nuse Symfony\\Component\\Security\\Core\\Authorization\\AuthorizationCheckerInterface;\nuse Symfony\\Contracts\\Translation\\TranslatorInterface;\n+/**\n+ * Class BackendMenuBuilder\n+ *\n+ * TODO PERMISSIONS -- add checks for menu items (don't show / disable when not available)\n+ *\n+ * @package Bolt\\Menu\n+ */\nfinal class BackendMenuBuilder implements BackendMenuBuilderInterface\n{\npublic const MAX_LATEST_RECORDS = 5;\n@@ -72,6 +79,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n/** @var MenuItem $menu */\n$menu = $this->menuFactory->createItem('root');\n+ if ($this->authorizationChecker->isGranted('dashboard')) {\n$menu->addChild('Dashboard', [\n'uri' => $this->urlGenerator->generate('bolt_dashboard'),\n'extras' => [\n@@ -79,6 +87,8 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-tachometer-alt',\n],\n]);\n+ }\n+\n$menu->addChild('Content', [\n'extras' => [\n@@ -92,7 +102,10 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n$this->addContentOthers($menu);\n+ // TODO PERMISSIONS -- should we check for any type of permission? Maybe a single global one makes sense.\n+ if ($this->authorizationChecker->isGranted('extensionmenus')) {\n$this->addExtensionMenus($menu);\n+ }\n$menu->addChild('Settings', [\n'extras' => [\n@@ -103,7 +116,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n// Configuration submenu\n-\n+ // TODO PERMISSIONS\n$menu->addChild('Configuration', [\n'uri' => $this->urlGenerator->generate('bolt_menupage', [\n'slug' => 'configuration',\n@@ -188,7 +201,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n// Maintenance submenu\n-\n+ // TODO PERMISSIONS\n$menu->addChild('Maintenance', [\n'uri' => $this->urlGenerator->generate('bolt_menupage', [\n'slug' => 'maintenance',\n@@ -263,7 +276,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n// Hide this menu item, unless we're on a \"Git clone\" install.\n- if (Version::installType() === 'Git clone') {\n+ if (Version::installType() === 'Git clone' && $this->authorizationChecker->isGranted('kitchensink')) {\n$menu->getChild('Maintenance')->addChild('The Kitchensink', [\n'uri' => $this->urlGenerator->generate('bolt_kitchensink'),\n'extras' => [\n@@ -282,7 +295,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n// File Management submenu\n-\n+ // TODO PERMISSIONS\n$menu->addChild('File Management', [\n'uri' => $this->urlGenerator->generate('bolt_menupage', [\n'slug' => 'filemanagement',\n@@ -348,6 +361,11 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n$contentTypes = $this->config->get('contenttypes')->where('show_in_menu', '!==', true);\nforeach ($contentTypes as $contentType) {\n+\n+ if (! $this->authorizationChecker->isGranted(ContentVoter::CONTENT_VIEW, $contentType)) {\n+ continue;\n+ }\n+\n$label = $contentType->get('show_in_menu') ?: $t->trans('caption.other_content');\nif (! $menu->getChild($label)) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/ContentVoter.php",
"new_path": "src/Security/ContentVoter.php",
"diff": "@@ -31,8 +31,7 @@ class ContentVoter extends Voter\n*/\npublic const CONTENT_EDIT = 'edit';\npublic const CONTENT_CREATE = 'create';\n- public const CONTENT_PUBLISH = 'publish';\n- public const CONTENT_DEPUBLISH = 'depublish';\n+ public const CONTENT_CHANGE_STATUS = 'change-status';\npublic const CONTENT_DELETE = 'delete';\npublic const CONTENT_CHANGE_OWNERSHIP = 'change-ownership';\npublic const CONTENT_VIEW = 'view';\n@@ -74,9 +73,8 @@ class ContentVoter extends Voter\n}\n// if the attribute isn't one we support, return false\n- return in_array($attribute, [self::CONTENT_EDIT, self::CONTENT_CREATE, self::CONTENT_PUBLISH,\n- self::CONTENT_DEPUBLISH, self::CONTENT_DELETE, self::CONTENT_CHANGE_OWNERSHIP,\n- self::CONTENT_VIEW], true);\n+ return in_array($attribute, [self::CONTENT_EDIT, self::CONTENT_CREATE, self::CONTENT_CHANGE_STATUS,\n+ self::CONTENT_DELETE, self::CONTENT_CHANGE_OWNERSHIP, self::CONTENT_VIEW], true);\n}\nprotected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
getting somewhere, started implementing permissions in ContentEditController.php
|
95,115 |
09.01.2021 12:11:55
| -3,600 |
e02f548e17e3c82d51d713cb8a0c0c863def7fe1
|
add additional roles for 'henkie' to support testing the user edit screen
|
[
{
"change_type": "MODIFY",
"old_path": "src/DataFixtures/UserFixtures.php",
"new_path": "src/DataFixtures/UserFixtures.php",
"diff": "@@ -101,7 +101,7 @@ class UserFixtures extends BaseFixture implements FixtureGroupInterface\n'username' => 'henkie',\n'password' => $this->append ? Str::generatePassword(10) : 'henkie%1',\n'email' => 'henkie@example.org',\n- 'roles' => ['ROLE_EDITOR'],\n+ 'roles' => ['ROLE_EDITOR', 'ROLE_EXTRA_1', 'ROLE_EXTRA_2', 'ROLE_USER_FRONTEND_GROUP1'],\n],\n[\n'displayname' => 'Jane Doe',\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
add additional roles for 'henkie' to support testing the user edit screen
|
95,115 |
09.01.2021 12:13:25
| -3,600 |
c090d1059ca6d04f15749d059fd8cee5deb826a6
|
added assign_unchecked_roles permission and rename 'contenttype-all' permission setting to 'contenttype-base'
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "# roles that are presented in the list when editing a user\n# these will be filtered based on the user's own level to make sure you don't assign\n-# roles 'above' yourself.\n-# TODO implement\n+# roles 'above' yourself. Any role you have yourself you can assign to others.\n+# (This is assuming roles are defined in the symfony security config and ordered in a\n+# hierarchy in config/packages/security.yaml)\n+\n# note: ROLE_USER is assigned to Bolt Entity Users if no roles have been set\n-assignable_roles: [ROLE_DEVELOPER, ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR, ROLE_USER]\n-# some roles are not in the role hierarchy and not assigned to 'normal' back end users\n-# if they should be assignable you need to add them here\n+# it is not included in this list as it should not be added/removed\n+assignable_roles: [ROLE_DEVELOPER, ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR]\n+# some roles are not in the role hierarchy and/or not assigned to 'normal' back end users\n+# the default is to leave these roles 'as is'\n+# if they should be assignable you need to add them here, these roles can be assigned by\n+# users with the global 'assign_unchecked_roles' permission (see below)\n+# for other users the behavior will be to leave them 'as is'\nassignable_roles_unchecked: [ROLE_USER_FRONTEND_GROUP1, ROLE_USER_FRONTEND_GROUP2]\n-\n# These permissions are the 'global' permissions; these are not tied\n# to any content types, but rather apply to global, non-content activity in\n# Bolt's backend. Most of these permissions map directly to backend routes;\n@@ -52,11 +57,12 @@ global:\nkitchensink: [ ROLE_DEVELOPER ]\nupload: [ ROLE_EDITOR ] # upload media/files\nextensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\n+ assign_unchecked_roles: [ ROLE_ADMIN ] # see above at assignable_roles_unchecked\n# For content type related actions, permissions can be set individually for\n# each content type. For this, we define three groups of permission sets.\n-# The 'contenttype-all' permission sets *overrides*; any roles specified here\n+# The 'contenttype-base' permission sets *overrides*; any roles specified here\n# will grant a permission for all content types, regardless of the rest of this\n# section.\n# The 'contenttype-default' contains rules that are used when the desired\n@@ -71,7 +77,7 @@ global:\n# short-circuits and always grants anything unconditionally.\n#\n# Otherwise, it checks whether any of the current user's roles match any of the\n-# roles in contenttype-all/{permission}. If so, the search is over, and the\n+# roles in contenttype-base/{permission}. If so, the search is over, and the\n# permission can be granted.\n#\n# The next step is to find contenttypes/{contenttype}/{permission}. If it is\n@@ -104,8 +110,8 @@ global:\n-# these permissions will be added to _all_ contenttypes, they can not be overridden\n-contenttype-all:\n+# these permissions will be set for all contenttypes, config below can add additional roles to these, but they can not be overridden\n+contenttype-base:\nedit: [ ROLE_ADMIN ]\ncreate: [ ROLE_ADMIN ]\nchange-status: [ ROLE_ADMIN ]\n@@ -113,7 +119,7 @@ contenttype-all:\nchange-ownership: [ ROLE_ADMIN ]\nview: [ ROLE_ADMIN ] # = show in menu, show listings, open 'edit' view without actually being able to edit, any of the other permissions always imply 'view'\n-# these permissions are used as a default for contenttypes\n+# these permissions are used as a default for contenttypes, they are added to the base permissions\n# you can override these settings per contenttype by adding it to the `contenttypes:` array\ncontenttype-default:\nedit: [ ROLE_CHIEF_EDITOR, CONTENT_OWNER ]\n@@ -132,8 +138,8 @@ contenttypes:\n# # Keys in this dictionary map to keys in the contenttypes.yml specification.\n# showcases:\n# # Rules defined here *override* rules defined in contenttype-default,\n-# # but *add* to rules in contenttype-all. This means that permissions\n-# # granted through contenttype-all cannot be revoked here, merely\n+# # but *add* to rules in contenttype-base. This means that permissions\n+# # granted through contenttype-base cannot be revoked here, merely\n# # amended.\n#\n# # Only the Admin and Chief Editor are allowed to edit records\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/ContentVoter.php",
"new_path": "src/Security/ContentVoter.php",
"diff": "@@ -50,7 +50,7 @@ class ContentVoter extends Voter\n{\n$this->security = $security;\n- $this->contenttypePermissionsAll = $config->get('permissions/contenttype-all', collect([]));\n+ $this->contenttypePermissionsAll = $config->get('permissions/contenttype-base', collect([]));\n$this->contenttypePermissionsDefault = $config->get('permissions/contenttype-default', collect([]));\n$this->contenttypePermissions = $config->get('permissions/contenttypes', null);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
added assign_unchecked_roles permission and rename 'contenttype-all' permission setting to 'contenttype-base'
|
95,115 |
09.01.2021 14:15:51
| -3,600 |
4344566effeacf3af0176551a5badb9a3751ee08
|
added TODO to mark security role update that is still to do
|
[
{
"change_type": "MODIFY",
"old_path": "src/Form/UserType.php",
"new_path": "src/Form/UserType.php",
"diff": "@@ -108,6 +108,7 @@ class UserType extends AbstractType\n* - this form is used to add a new user\n* - if the given user object (=logged in user in profile edit page) has ROLE_ADMIN\n*/\n+ // TODO PERMISSIONS -> fix this\nif ($options['is_profile_edit'] === false || in_array('ROLE_ADMIN', $options['data']->getRoles(), true)) {\n$builder\n->add('roles', ChoiceType::class, [\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
added TODO to mark security role update that is still to do
|
95,115 |
09.01.2021 14:18:09
| -3,600 |
bcfe40f48f48f2e0881564f18becde88523d7355
|
update (broken) UserEditController.php before continuing on simpler stuff
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "# note: ROLE_USER is assigned to Bolt Entity Users if no roles have been set\n# it is not included in this list as it should not be added/removed\n-assignable_roles: [ROLE_DEVELOPER, ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR]\n+# the assumption is that these roles are also defined in the symfony security role hierarchy\n+assignable_roles: [ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR]\n# some roles are not in the role hierarchy and/or not assigned to 'normal' back end users\n# the default is to leave these roles 'as is'\n# if they should be assignable you need to add them here, these roles can be assigned by\n# users with the global 'assign_unchecked_roles' permission (see below)\n-# for other users the behavior will be to leave them 'as is'\n-assignable_roles_unchecked: [ROLE_USER_FRONTEND_GROUP1, ROLE_USER_FRONTEND_GROUP2]\n+# for other users the behavior will be to leave them 'as is' and not show them when editing users\n+assignable_roles_unchecked: [ROLE_USER_FRONTEND_GROUP1, ROLE_USER_FRONTEND_GROUP2, ROLE_EXTRA_1, ROLE_EXTRA_14]\n# These permissions are the 'global' permissions; these are not tied\n# to any content types, but rather apply to global, non-content activity in\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -22,6 +22,7 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\nuse Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\nuse Symfony\\Component\\Security\\Core\\Encoder\\UserPasswordEncoderInterface;\n+use Symfony\\Component\\Security\\Core\\Role\\RoleHierarchyInterface;\nuse Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface;\nuse Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface;\n@@ -41,6 +42,9 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/** @var EventDispatcherInterface */\nprivate $dispatcher;\n+ /** @var RoleHierarchyInterface */\n+ private $roleHierarchy;\n+\nprotected $defaultLocale;\nprivate $assignableRoles;\n@@ -52,6 +56,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\nUserPasswordEncoderInterface $passwordEncoder,\nCsrfTokenManagerInterface $csrfTokenManager,\nEventDispatcherInterface $dispatcher,\n+ RoleHierarchyInterface $roleHierarchy,\nConfig $config,\nstring $defaultLocale\n) {\n@@ -60,6 +65,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n$this->passwordEncoder = $passwordEncoder;\n$this->csrfTokenManager = $csrfTokenManager;\n$this->dispatcher = $dispatcher;\n+ $this->roleHierarchy = $roleHierarchy;\n$this->defaultLocale = $defaultLocale;\n$this->assignableRoles = $config->get('permissions/assignable_roles')->all();\n$this->assignableRolesUnchecked = $config->get('permissions/assignable_roles_unchecked')->all();\n@@ -71,12 +77,13 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n*/\npublic function add(Request $request): Response\n{\n+ // TODO PERMISSIONS this is broken at the moment -- the handling of the roles in the form is weird, and some complex decisions have to be made on the rules\n$user = UserRepository::factory();\n$submitted_data = $request->request->get('user');\n$event = new UserEvent($user);\n$this->dispatcher->dispatch($event, UserEvent::ON_ADD);\n- $roles = $this->_getPossibleRoles($event);\n+ $roles = $this->_getPossibleRoles();\n// These are the variables we have to pass into our FormType so we can build the fields correctly\n$form_data = [\n@@ -122,6 +129,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n*/\npublic function edit(?User $user, Request $request): Response\n{\n+ // TODO PERMISSIONS this is broken at the moment -- the handling of the roles in the form is weird, and some complex decisions have to be made on the rules\n$submitted_data = $request->request->get('user');\n$is_profile_edit = false;\n@@ -132,12 +140,13 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n}\n// don't allow editing a user with higher roles then yourself\n- $this->_denyUnlessRolesAssignable($user->getRoles());\n+ // TODO PERMISSIONS this is broken at the moment\n+// $this->_denyUnlessRolesAssignable($user->getRoles());\n$event = new UserEvent($user);\n$this->dispatcher->dispatch($event, UserEvent::ON_EDIT);\n- $roles = $this->_getPossibleRoles($event);\n+ $roles = $this->_getPossibleRoles();\n// We don't require the user to set the password again on the \"user edit\" form\n// If it is otherwise set use the given password normally\n@@ -226,6 +235,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n{\n$this->validateCsrf('useredit');\n+ // TODO only allow to delete users 'below' yourself?\n$this->_denyUnlessRolesAssignable($user->getRoles());\n$this->em->remove($user);\n@@ -282,34 +292,22 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n}\n/**\n- * @param UserEvent $event\n* @return array\n*/\n- private function _getPossibleRoles(UserEvent $event): array\n+ private function _getPossibleRoles(): array\n{\n- // TODO - Maybe the roles defined in role_hierarchy are not necessarily the roles we want to allow to be 'set'\n- // here. It is not _required_ for roles to be specified in the role_hierarchy, as it is just a utility to\n- // configure a hierarchy and make life easier.\n- // Change this to get the roles from the permissions.yaml\n-//\n-// // only allow user to assign system roles they have themselves, use ARRAY_FILTER_USE_KEY as the role names are the keys (values are a list of roles they inherit)\n-// $filteredSystemRoles = array_filter($this->getParameter('security.role_hierarchy.roles'), function ($role) {\n-// return $this->isGranted($role);\n-// }, ARRAY_FILTER_USE_KEY);\n-// // allow all roles added by extensions to be assigned (At the moment this seems the best solution to handle these)\n-// $extensionSuppliedRoles = $event->getRoleOptions()->toArray();\n-// $roles = array_merge($filteredSystemRoles, $extensionSuppliedRoles);\n$roleHierarchy = $this->getParameter('security.role_hierarchy.roles');\n$result = [];\n- foreach ($this->assignableRoles as $assignableRole) {\n- if (in_array($assignableRole, $this->assignableRolesUnchecked, true) || $this->isGranted($assignableRole)) {\n+ $assignableRoles = $this->_getAssignableRoles();\n+\n+ // only show the roles you can give access to\n+ foreach ($assignableRoles as $assignableRole) {\nif (isset($roleHierarchy[$assignableRole])) {\n$result[$assignableRole] = $roleHierarchy[$assignableRole];\n} else {\n$result[$assignableRole] = [];\n}\n}\n- }\nreturn $result;\n}\n@@ -324,4 +322,19 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n}\n}\n+ /**\n+ * @return array\n+ */\n+ private function _getAssignableRoles(): array\n+ {\n+ $assignableRoles = array_filter($this->assignableRoles, function ($role) {\n+ return $this->isGranted($role);\n+ });\n+ $userCanAssignUncheckedRoles = $this->isGranted('assign_unchecked_roles');\n+ if ($userCanAssignUncheckedRoles) {\n+ $assignableRoles = array_merge($assignableRoles, $this->assignableRolesUnchecked);\n+ }\n+ return $assignableRoles;\n+ }\n+\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
update (broken) UserEditController.php before continuing on simpler stuff
|
95,115 |
09.01.2021 23:13:37
| -3,600 |
68016da09af6f65a442a4a87a0ec05d549fbd6bd
|
allow setting 'readonly' flag on fields from twig instead of depending on setting from field (used if field is editable but you don't have permission to do so)
|
[
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/_base.html.twig",
"new_path": "templates/_partials/fields/_base.html.twig",
"diff": "{% set required = (field.definition.required|default) ? true : false %}\n{% endif %}\n-{# Set readonly #}\n+{# Set readonly based on field definition if not set already #}\n+{% if readonly is not defined %}\n{% set readonly = (field.definition.readonly|default) ? true : false %}\n+{% endif %}\n{# Set error validation message #}\n{% set errormessage = field.definition.get('error')|default(false) %}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
allow setting 'readonly' flag on fields from twig instead of depending on setting from field (used if field is editable but you don't have permission to do so)
|
95,115 |
09.01.2021 23:15:02
| -3,600 |
81d76b35c6d28776489496445d74a1be36216793
|
hide new/delete/edit buttons if you don't have the right permissions, set readonly on status fields if you don't have permission to change them.
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/sidebar/Components/Menu/_SubMenu.vue",
"new_path": "assets/js/app/sidebar/Components/Menu/_SubMenu.vue",
"diff": "<template>\n<ul class=\"link--menu\">\n- <li v-if=\"item.link_new !== null\" class=\"link--actions\">\n- <a :href=\"item.link_new\" data-patience=\"virtue\">\n+ <li class=\"link--actions\">\n+ <a v-if=\"item.link_new !== null\" :href=\"item.link_new\" data-patience=\"virtue\">\n<i class=\"fas fa-fw fa-magic mr-2\"></i><span>{{ labels['action.new'] }}</span>\n</a>\n<a :href=\"item.link_listing\" data-patience=\"virtue\">\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/content/_buttons.html.twig",
"new_path": "templates/content/_buttons.html.twig",
"diff": "{% import '@bolt/_macro/_macro.html.twig' as macro %}\n<div class=\"record-actions {% if hide_on_mobile|default(false) %}d-lg-none d-xl-block{% endif %}\">\n+ {% if is_granted('edit', record) %}\n{{ macro.button('action.save', 'fa-save', 'success mb-0', {'type': 'submit', 'form': 'editcontent', 'data-patience': 'virtue', 'name': 'save'}) }}\n+ {% endif %}\n{% if record.id %}\n{% if record|feature == 'homepage' or not record.definition.get('viewless') %}\n{% if record.status == \"published\" and record|link(true) %}\n<a href=\"{{ record|link(true, currentlocale) }}\" class=\"btn btn-tertiary btn-sm\" target=\"_blank\">{{ macro.icon('fa-sign-out-alt') }} {{ __('action.view_saved') }}</a>\n{% endif %}\n+ {% if record.extras.deleteLink is defined %}\n<a href=\"{{ record.extras.deleteLink }}\" class='action-remove-collection-item btn btn-sm btn-hidden-danger' data-confirmation=\"{{ 'action.confirm_delete'|trans }}\">\n{{ macro.icon('trash') }}{{ 'action.delete'|trans }}\n</a>\n+ {% endif %}\n</div>\n{% endif %}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/content/_fields_aside.html.twig",
"new_path": "templates/content/_fields_aside.html.twig",
"diff": "<div class=\"form-fieldsgroup form-fieldsgroup__editable-fields\">\n+ {% set disableStatusChanges = not is_granted('change-status', record) %}\n{% include '@bolt/_partials/fields/select.html.twig' with {\n'label' : 'field.status'|trans,\n'name' : 'status',\n'value' : [record.status],\n'options' : record|status_options,\n'form' : 'editcontent',\n- 'required' : true\n+ 'required' : true,\n+ 'readonly' : disableStatusChanges\n} %}\n{% include '@bolt/_partials/fields/date.html.twig' with {\n'name' : 'publishedAt',\n'value' : record.publishedAt,\n'mode' : 'datetime',\n- 'form' : 'editcontent'\n+ 'form' : 'editcontent',\n+ 'readonly' : disableStatusChanges\n} %}\n{% include '@bolt/_partials/fields/date.html.twig' with {\n'name' : 'depublishedAt',\n'value' : record.depublishedAt,\n'mode' : 'datetime',\n- 'form' : 'editcontent'\n+ 'form' : 'editcontent',\n+ 'readonly' : disableStatusChanges\n} %}\n{% include '@bolt/_partials/fields/text.html.twig' with {\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
hide new/delete/edit buttons if you don't have the right permissions, set readonly on status fields if you don't have permission to change them.
|
95,115 |
09.01.2021 23:16:00
| -3,600 |
4a78c4da58b812a8c234b172b7e5a8c7b709a5a2
|
check for edit permissions instead of ROLE_ADMIN
|
[
{
"change_type": "MODIFY",
"old_path": "src/Twig/ContentExtension.php",
"new_path": "src/Twig/ContentExtension.php",
"diff": "@@ -402,7 +402,7 @@ class ContentExtension extends AbstractExtension\npublic function getEditLink(?Content $content): ?string\n{\n- if (! $content instanceof Content || $content->getId() === null || ! $this->security->getUser() || ! $this->security->isGranted('ROLE_ADMIN')) {\n+ if (! $content instanceof Content || $content->getId() === null || ! $this->security->getUser() || ! $this->security->isGranted(ContentVoter::CONTENT_EDIT, $content)) {\nreturn null;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
check for edit permissions instead of ROLE_ADMIN
|
95,115 |
09.01.2021 23:17:47
| -3,600 |
423e1c20c9d6619fe4a47d2847c5ea09bec3590b
|
add new derived permission 'menu_listing' and special case for 'view' that is also given for edit/delete/change_* permissions
|
[
{
"change_type": "MODIFY",
"old_path": "src/Security/ContentVoter.php",
"new_path": "src/Security/ContentVoter.php",
"diff": "@@ -35,14 +35,17 @@ class ContentVoter extends Voter\npublic const CONTENT_DELETE = 'delete';\npublic const CONTENT_CHANGE_OWNERSHIP = 'change-ownership';\npublic const CONTENT_VIEW = 'view';\n+ # used to determine of user can view an entry or see the listing/menu for it\n+ # this permission is not to be specified in the config, it is only used internally\n+ public const CONTENT_MENU_LISTING = 'menu_listing';\nprivate $security;\nprivate $supportedAttributes;\n/** @var Collection|null */\n- private $contenttypePermissionsAll;\n+ private $contenttypeBasePermissions;\n/** @var Collection|null */\n- private $contenttypePermissionsDefault;\n+ private $contenttypeDefaultPermissions;\n/** @var Collection|null */\nprivate $contenttypePermissions;\n@@ -50,18 +53,18 @@ class ContentVoter extends Voter\n{\n$this->security = $security;\n- $this->contenttypePermissionsAll = $config->get('permissions/contenttype-base', collect([]));\n- $this->contenttypePermissionsDefault = $config->get('permissions/contenttype-default', collect([]));\n+ $this->contenttypeBasePermissions = $config->get('permissions/contenttype-base', collect([]));\n+ $this->contenttypeDefaultPermissions = $config->get('permissions/contenttype-default', collect([]));\n$this->contenttypePermissions = $config->get('permissions/contenttypes', null);\n- if (! ($this->contenttypePermissionsAll instanceof Collection)) {\n- throw new \\DomainException('No permissions config found');\n+ if (! ($this->contenttypeBasePermissions instanceof Collection)) {\n+ throw new \\DomainException('No suitable contenttype-base permissions config found');\n}\n- if (! ($this->contenttypePermissionsDefault instanceof Collection)) {\n- throw new \\DomainException('No permissions config found');\n+ if (! ($this->contenttypeDefaultPermissions instanceof Collection)) {\n+ throw new \\DomainException('No suitable contenttype-default permissions config found');\n}\nif (! ($this->contenttypePermissions == null || $this->contenttypePermissions instanceof Collection)) {\n- throw new \\DomainException('No permissions config found');\n+ throw new \\DomainException('No suitable contenttypes permissions config found');\n}\n}\n@@ -74,7 +77,7 @@ class ContentVoter extends Voter\n// if the attribute isn't one we support, return false\nreturn in_array($attribute, [self::CONTENT_EDIT, self::CONTENT_CREATE, self::CONTENT_CHANGE_STATUS,\n- self::CONTENT_DELETE, self::CONTENT_CHANGE_OWNERSHIP, self::CONTENT_VIEW], true);\n+ self::CONTENT_DELETE, self::CONTENT_CHANGE_OWNERSHIP, self::CONTENT_VIEW, self::CONTENT_MENU_LISTING], true);\n}\nprotected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n@@ -86,8 +89,27 @@ class ContentVoter extends Voter\nreturn false;\n}\n- // first check if the users has an 'all' permission set for this content(type)\n- $allRoles = $this->contenttypePermissionsAll->get($attribute);\n+ // special case for CONTENT_MENU_LISTING\n+ if ($attribute === self::CONTENT_MENU_LISTING) {\n+\n+ return $this->voteOnAttribute(self::CONTENT_CREATE, $subject, $token)\n+ || $this->voteOnAttribute(self::CONTENT_DELETE, $subject, $token)\n+ || $this->voteOnAttribute(self::CONTENT_EDIT, $subject, $token)\n+ || $this->voteOnAttribute(self::CONTENT_CHANGE_STATUS, $subject, $token)\n+ || $this->voteOnAttribute(self::CONTENT_CHANGE_OWNERSHIP, $subject, $token)\n+ || $this->voteOnAttribute(self::CONTENT_VIEW, $subject, $token)\n+ ;\n+ }\n+\n+ // special case for CONTENT_VIEW -> we'll also grant this to users that have any of these edit/delete permissions\n+ // if the user has none of these, continue the function below to check for the 'real' CONTENT_VIEW permission\n+ if ($attribute === self::CONTENT_VIEW && $this->isGrantedAny([self::CONTENT_EDIT, self::CONTENT_CHANGE_STATUS,\n+ self::CONTENT_DELETE, self::CONTENT_CHANGE_OWNERSHIP], $subject)) {\n+ return true;\n+ }\n+\n+ // first check if the user has a 'base' permission set for this content(type)\n+ $allRoles = $this->contenttypeBasePermissions->get($attribute);\nif ($allRoles && $allRoles instanceof Collection) {\n// check if user is granted any of the specified attributes/roles\nforeach ($allRoles as $role) {\n@@ -123,7 +145,7 @@ class ContentVoter extends Voter\n}\n// if there was no specific rule for this contenttype + attribute, fall back to the default\n- $contentTypeDefaultPermissions = $this->contenttypePermissionsDefault;\n+ $contentTypeDefaultPermissions = $this->contenttypeDefaultPermissions;\nif ($contentTypeDefaultPermissions) {\n$roles = $contentTypeDefaultPermissions->get($attribute);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
add new derived permission 'menu_listing' and special case for 'view' that is also given for edit/delete/change_* permissions
|
95,115 |
09.01.2021 23:19:56
| -3,600 |
64bace17c7d5d0fe3aa1865f7cb09ef0b72bb55f
|
implement new permission system for ListingController.php
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ListingController.php",
"new_path": "src/Controller/Backend/ListingController.php",
"diff": "@@ -7,13 +7,12 @@ namespace Bolt\\Controller\\Backend;\nuse Bolt\\Configuration\\Content\\ContentType;\nuse Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Entity\\Content;\n+use Bolt\\Security\\ContentVoter;\nuse Bolt\\Storage\\Query;\n-use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n*/\nclass ListingController extends TwigAwareController implements BackendZoneInterface\n{\n@@ -24,6 +23,8 @@ class ListingController extends TwigAwareController implements BackendZoneInterf\n{\n$contentTypeObject = ContentType::factory($contentType, $this->config->get('contenttypes'));\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_MENU_LISTING, $contentTypeObject);\n+\n$page = (int) $this->getFromRequest('page', '1');\n$pager = $this->createPager($query, $contentType, $contentTypeObject->get('records_per_page'), $contentTypeObject->get('order'));\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
implement new permission system for ListingController.php
|
95,115 |
09.01.2021 23:21:23
| -3,600 |
9e784de521bc4df7bc184eff066ed42a201ff6e1
|
check for 'new' permission and don't add link_new url if permission not given -> this will prevent a 'new' item from appearing in the sidebar submenu for a content type
|
[
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -332,8 +332,8 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n$contentTypes = $this->config->get('contenttypes')->whereStrict('show_in_menu', true);\nforeach ($contentTypes as $contentType) {\n- // add only if the user can 'view'\n- if (! $this->authorizationChecker->isGranted(ContentVoter::CONTENT_VIEW, $contentType)) {\n+ // add only if the user can or needs to access this contenttype (for view, edit, ...)\n+ if (! $this->authorizationChecker->isGranted(ContentVoter::CONTENT_MENU_LISTING, $contentType)) {\ncontinue;\n}\n$menu->addChild($contentType->getSlug(), [\n@@ -344,7 +344,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'slug' => $contentType->getSlug(),\n'singular_slug' => $contentType['singular_slug'],\n'icon' => $contentType['icon_many'],\n- 'link_new' => $this->urlGenerator->generate('bolt_content_new', ['contentType' => $contentType->getSlug()]),\n+ 'link_new' => $this->authorizationChecker->isGranted(ContentVoter::CONTENT_CREATE, $contentType) ? $this->urlGenerator->generate('bolt_content_new', ['contentType' => $contentType->getSlug()]) : null,\n'link_listing' => $contentType->getSlug(),\n'singleton' => $contentType['singleton'],\n'active' => $contentType->getSlug() === 'pages' ? true : false,\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
check for 'new' permission and don't add link_new url if permission not given -> this will prevent a 'new' item from appearing in the sidebar submenu for a content type
|
95,115 |
09.01.2021 23:24:02
| -3,600 |
ad46714481fa49523b9ad6c822be446cfe3dd2b5
|
big change to ContentEditController.php to update it to the new permission system, config updates (mostly documentation)
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -74,10 +74,7 @@ global:\n# To understand how this works, it may be best to follow the permission checker\n# through its decision-making process.\n#\n-# First, it checks whether the current user is in the \"root\" role; if so, it\n-# short-circuits and always grants anything unconditionally.\n-#\n-# Otherwise, it checks whether any of the current user's roles match any of the\n+# First it checks whether any of the current user's roles match any of the\n# roles in contenttype-base/{permission}. If so, the search is over, and the\n# permission can be granted.\n#\n@@ -108,8 +105,9 @@ global:\n# permission can indirectly enable users more permissions\n# in ways that may not be immediately obvious.\n# - view: allows viewing records in the backend (listings, content/fields)\n-\n-\n+#\n+# Note that all permissions imply 'view' permission, so you don't have to give 'view' along with 'edit'\n+# Note change-ownership is available as a setting but is not implemented in the bolt admin at the moment\n# these permissions will be set for all contenttypes, config below can add additional roles to these, but they can not be overridden\ncontenttype-base:\n@@ -128,7 +126,6 @@ contenttype-default:\nchange-ownership: [ CONTENT_OWNER ] # <-- how to handle chance-ownership permission without 'edit'?\nview: [ ROLE_CHIEF_EDITOR ]\n# view: [ IS_AUTHENTICATED_FULLY ]\n-# show-in-menu: [ IS_AUTHENTICATED_FULLY ] # <-- not a useful permission after all\ncontenttypes:\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ContentEditController.php",
"new_path": "src/Controller/Backend/ContentEditController.php",
"diff": "@@ -37,8 +37,22 @@ use Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface;\nuse Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface;\nuse Tightenco\\Collect\\Support\\Collection;\n+// utility method not of real use outside this controller\n+function datesDiffer(?\\DateTime $dateTime1, ?\\DateTime $dateTime2): bool\n+{\n+ if ($dateTime1 !== null) {\n+ if ($dateTime2 !== null) {\n+ return $dateTime1->getTimestamp() !== $dateTime2->getTimestamp();\n+ }\n+ // $dateTime2 null while $dateTime1 is not\n+ return true;\n+ }\n+ // $dateTime1 is null, so if $dateTime2 is NOT null they differ\n+ return $dateTime2 !== null;\n+}\n+\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * CRUD + status, duplicate, preview, for content - note that listing is handled by ListingController.php\n*/\nclass ContentEditController extends TwigAwareController implements BackendZoneInterface\n{\n@@ -124,7 +138,8 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n*/\npublic function edit(Content $content): Response\n{\n- $this->denyAccessUnlessGranted(ContentVoter::CONTENT_EDIT, $content);\n+// $this->denyAccessUnlessGranted(ContentVoter::CONTENT_EDIT, $content);\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_VIEW, $content);\n$event = new ContentEvent($content);\n$this->dispatcher->dispatch($event, ContentEvent::ON_EDIT);\n@@ -135,21 +150,45 @@ class ContentEditController extends TwigAwareController implements BackendZoneIn\n/**\n* @Route(\"/edit/{id}\", name=\"bolt_content_edit_post\", methods={\"POST\"}, requirements={\"id\": \"\\d+\"})\n*/\n- public function save(?Content $content = null, ?ContentValidatorInterface $contentValidator = null): Response\n+ public function save(?Content $originalContent = null, ?ContentValidatorInterface $contentValidator = null): Response\n{\n$this->validateCsrf('editrecord');\n- $content = $this->contentFromPost($content);\n+ // pre-check on original content, store properties for later comparison\n+ if ($originalContent !== null) {\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_EDIT, $originalContent);\n+ $originalStatus = $originalContent->getStatus();\n+ $originalPublishedAt = $originalContent->getPublishedAt();\n+ $originalDepublishedAt = $originalContent->getDepublishedAt();\n+ $originalAuthor = $originalContent->getAuthor();\n+ } else {\n+ $originalStatus = null;\n+ $originalPublishedAt = null;\n+ $originalDepublishedAt = null;\n+ $originalAuthor = null;\n+ }\n- // TODO PERMISSIONS -- we also have to check for status (and future: owner) changes\n- // hmm, how to handle changes of status for a new item? Is that a thing? --> maybe prevent changing from the default?\n- /*\n- status \"[\\\"published\\\"]\"\n- publishedAt \"2020-10-23T02:20:41.000Z\"\n- depublishedAt \"\"\n- */\n+ $content = $this->contentFromPost($originalContent);\n+\n+ // check again on new/updated content, this is needed in case the save action is used to create a new item\n$this->denyAccessUnlessGranted(ContentVoter::CONTENT_EDIT, $content);\n+ // check for status (and owner, but that hasn't been implemented in the forms yet) changes\n+ if ($originalContent !== null) {\n+ // deny if we detect any of these status fields being changed\n+ if (\n+ $originalStatus !== $content->getStatus() ||\n+ datesDiffer($originalPublishedAt, $content->getPublishedAt()) ||\n+ datesDiffer($originalDepublishedAt, $content->getDepublishedAt())\n+ ) {\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_CHANGE_STATUS, $content);\n+ }\n+ // deny if owner changes\n+ if ($originalAuthor !== $content->getAuthor()) {\n+ $this->denyAccessUnlessGranted(ContentVoter::CONTENT_CHANGE_OWNERSHIP, $content);\n+ }\n+ }\n+\n// check if validator should be enabled (default for bolt 4.x is not enabled)\n$enableContentValidator = $this->config->get('general/validator_options/enable', false);\nif ($enableContentValidator && $contentValidator) {\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
big change to ContentEditController.php to update it to the new permission system, config updates (mostly documentation)
|
95,115 |
09.01.2021 23:26:16
| -3,600 |
744e958ef102c670d2817cbf53b7bf2098be785f
|
updates to permissions.yaml for testing
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -113,7 +113,7 @@ global:\ncontenttype-base:\nedit: [ ROLE_ADMIN ]\ncreate: [ ROLE_ADMIN ]\n- change-status: [ ROLE_ADMIN ]\n+ change-status: [ ROLE_ADMIN ] # <-- TODO PERMISSIONS how to handle change-status permission without 'edit'? For now it will just not work!\ndelete: [ ROLE_ADMIN ]\nchange-ownership: [ ROLE_ADMIN ]\nview: [ ROLE_ADMIN ] # = show in menu, show listings, open 'edit' view without actually being able to edit, any of the other permissions always imply 'view'\n@@ -145,11 +145,18 @@ contenttypes:\n# create: [ ROLE_CHIEF_EDITOR ]\n# change-status: [ ROLE_CHIEF_EDITOR ]\n# delete: [ ROLE_CHIEF_EDITOR ]\n-# show-in-menu: [ ROLE_CHIEF_EDITOR ]\npages:\nedit: [ ROLE_EDITOR, CONTENT_OWNER ]\ncreate: [ ROLE_EDITOR ]\nchange-ownership: [ CONTENT_OWNER ]\nview: [ ROLE_USER ]\n-# view: [ IS_AUTHENTICATED_FULLY ]\n-# show-in-menu: [ IS_AUTHENTICATED_FULLY ] #<-- not useful after all\n+ entries:\n+# edit: [ ROLE_EDITOR ]\n+# edit: [ ROLE_EDITOR, CONTENT_OWNER ]\n+# create: [ ROLE_EDITOR ]\n+# change-ownership: [ CONTENT_OWNER ]\n+ view: [ ROLE_EDITOR ]\n+ homepage: # singleton\n+ view: [ ROLE_EDITOR ]\n+# edit: [ ROLE_EDITOR ]\n+# create: [ ROLE_EDITOR ]\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
updates to permissions.yaml for testing
|
95,115 |
10.01.2021 19:48:06
| -3,600 |
59a0912b0211e647ebb0ad810eb9ffb0f9675584
|
simplified user role assignment permissions to a workable system
updated visibility of action buttons on listing screen
fixed voter for switch user permission
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "# and understand the consequences of making uninformed changes to the roles and\n# permissions.\n-# roles that are presented in the list when editing a user\n-# these will be filtered based on the user's own level to make sure you don't assign\n-# roles 'above' yourself. Any role you have yourself you can assign to others.\n-# (This is assuming roles are defined in the symfony security config and ordered in a\n-# hierarchy in config/packages/security.yaml)\n-\n-# note: ROLE_USER is assigned to Bolt Entity Users if no roles have been set\n-# it is not included in this list as it should not be added/removed\n-# the assumption is that these roles are also defined in the symfony security role hierarchy\n-assignable_roles: [ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR]\n-# some roles are not in the role hierarchy and/or not assigned to 'normal' back end users\n-# the default is to leave these roles 'as is'\n-# if they should be assignable you need to add them here, these roles can be assigned by\n-# users with the global 'assign_unchecked_roles' permission (see below)\n-# for other users the behavior will be to leave them 'as is' and not show them when editing users\n-assignable_roles_unchecked: [ROLE_USER_FRONTEND_GROUP1, ROLE_USER_FRONTEND_GROUP2, ROLE_EXTRA_1, ROLE_EXTRA_14]\n+# List of roles that are presented in the list of options when editing a user.\n+# Roles that are not in this list are left 'as is' when editing users.\n+# Note: ROLE_USER is assigned to Bolt Entity Users if no roles have been set\n+# it should not be included in this list as it should not be added/removed.\n+assignable_roles: [ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR, ROLE_EXTRA_1, ROLE_USER_FRONTEND_GROUP2]\n# These permissions are the 'global' permissions; these are not tied\n# to any content types, but rather apply to global, non-content activity in\n@@ -43,11 +32,11 @@ global:\nprofile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\n# settings: [ admin, developer, everyone ]\n# translation: [ developer ]\n- user:list: [ ROLE_ADMIN ] # overview listing of users and a list of active sessions\n- user:add: [ ROLE_ADMIN ] # add user - allows editing user _before_ saving, after saving 'useredit' is needed. -> cannot give roles above 'self'\n- user:status: [ ROLE_ADMIN ] # user enable/disable -> cannot enable/disable users with roles above 'self'\n- user:delete: [ ROLE_ADMIN ] # user delete -> cannot delete users with roles above 'self'\n- user:edit: [ ROLE_ADMIN ] # user edit all fields, including status -> cannot give roles above 'self'\n+ user:list: [ ROLE_ADMIN, ROLE_EDITOR ] # overview listing of users and a list of active sessions\n+ user:add: [ ROLE_ADMIN ] # add user - allows editing user _before_ saving, can set status on create, after saving 'useredit' is needed.\n+ user:status: [ ROLE_ADMIN ] # user enable/disable\n+ user:delete: [ ROLE_ADMIN ] # user delete\n+ user:edit: [ ROLE_ADMIN ] # user edit all fields, includes user:status permissions\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\nomnisearch: [ IS_AUTHENTICATED_ANONYMOUSLY ]\n# # Access to the various logs\n@@ -58,8 +47,6 @@ global:\nkitchensink: [ ROLE_DEVELOPER ]\nupload: [ ROLE_EDITOR ] # upload media/files\nextensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\n- assign_unchecked_roles: [ ROLE_ADMIN ] # see above at assignable_roles_unchecked\n-\n# For content type related actions, permissions can be set individually for\n# each content type. For this, we define three groups of permission sets.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Parser/PermissionsParser.php",
"new_path": "src/Configuration/Parser/PermissionsParser.php",
"diff": "@@ -30,8 +30,7 @@ class PermissionsParser extends BaseParser\n{\n// TODO PERMISSIONS add more defaults\nreturn [\n- 'assignable_roles' => ['ROLE_DEVELOPER', 'ROLE_ADMIN', 'ROLE_CHIEF_EDITOR', 'ROLE_EDITOR', 'ROLE_USER'],\n- 'assignable_roles_unchecked' => []\n+ 'assignable_roles' => ['ROLE_ADMIN', 'ROLE_CHIEF_EDITOR', 'ROLE_EDITOR'],\n];\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -22,7 +22,6 @@ use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\nuse Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface;\nuse Symfony\\Component\\Security\\Core\\Encoder\\UserPasswordEncoderInterface;\n-use Symfony\\Component\\Security\\Core\\Role\\RoleHierarchyInterface;\nuse Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface;\nuse Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface;\n@@ -42,13 +41,9 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/** @var EventDispatcherInterface */\nprivate $dispatcher;\n- /** @var RoleHierarchyInterface */\n- private $roleHierarchy;\n-\nprotected $defaultLocale;\nprivate $assignableRoles;\n- private $assignableRolesUnchecked;\npublic function __construct(\nUrlGeneratorInterface $urlGenerator,\n@@ -56,7 +51,6 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\nUserPasswordEncoderInterface $passwordEncoder,\nCsrfTokenManagerInterface $csrfTokenManager,\nEventDispatcherInterface $dispatcher,\n- RoleHierarchyInterface $roleHierarchy,\nConfig $config,\nstring $defaultLocale\n) {\n@@ -65,25 +59,22 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n$this->passwordEncoder = $passwordEncoder;\n$this->csrfTokenManager = $csrfTokenManager;\n$this->dispatcher = $dispatcher;\n- $this->roleHierarchy = $roleHierarchy;\n$this->defaultLocale = $defaultLocale;\n$this->assignableRoles = $config->get('permissions/assignable_roles')->all();\n- $this->assignableRolesUnchecked = $config->get('permissions/assignable_roles_unchecked')->all();\n}\n/**\n* @Route(\"/user-edit/add\", methods={\"GET\",\"POST\"}, name=\"bolt_user_add\")\n- * @Security(\"is_granted('user:add')\") -- first check, more detailed checks in method\n+ * @Security(\"is_granted('user:add')\")\n*/\npublic function add(Request $request): Response\n{\n- // TODO PERMISSIONS this is broken at the moment -- the handling of the roles in the form is weird, and some complex decisions have to be made on the rules\n$user = UserRepository::factory();\n$submitted_data = $request->request->get('user');\n$event = new UserEvent($user);\n$this->dispatcher->dispatch($event, UserEvent::ON_ADD);\n- $roles = $this->_getPossibleRoles();\n+ $roles = $this->_getPossibleRolesForForm();\n// These are the variables we have to pass into our FormType so we can build the fields correctly\n$form_data = [\n@@ -129,7 +120,6 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n*/\npublic function edit(?User $user, Request $request): Response\n{\n- // TODO PERMISSIONS this is broken at the moment -- the handling of the roles in the form is weird, and some complex decisions have to be made on the rules\n$submitted_data = $request->request->get('user');\n$is_profile_edit = false;\n@@ -139,14 +129,10 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n$is_profile_edit = true;\n}\n- // don't allow editing a user with higher roles then yourself\n- // TODO PERMISSIONS this is broken at the moment\n-// $this->_denyUnlessRolesAssignable($user->getRoles());\n-\n$event = new UserEvent($user);\n$this->dispatcher->dispatch($event, UserEvent::ON_EDIT);\n- $roles = $this->_getPossibleRoles();\n+ $roles = $this->_getPossibleRolesForForm();\n// We don't require the user to set the password again on the \"user edit\" form\n// If it is otherwise set use the given password normally\n@@ -229,15 +215,12 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @Route(\"/user-delete/{id}\", methods={\"POST\", \"GET\"}, name=\"bolt_user_delete\", requirements={\"id\": \"\\d+\"})\n- * @Security(\"is_granted('user:delete')\") -- first check, more detailed checks in method\n+ * @Security(\"is_granted('user:delete')\")\n*/\npublic function delete(User $user): Response\n{\n$this->validateCsrf('useredit');\n- // TODO only allow to delete users 'below' yourself?\n- $this->_denyUnlessRolesAssignable($user->getRoles());\n-\n$this->em->remove($user);\n$contentArray = $this->getDoctrine()->getManager()->getRepository(\\Bolt\\Entity\\Content::class)->findBy(['author' => $user]);\nforeach ($contentArray as $content) {\n@@ -294,47 +277,15 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @return array\n*/\n- private function _getPossibleRoles(): array\n+ private function _getPossibleRolesForForm(): array\n{\n- $roleHierarchy = $this->getParameter('security.role_hierarchy.roles');\n$result = [];\n- $assignableRoles = $this->_getAssignableRoles();\n+ $assignableRoles = $this->assignableRoles;\n- // only show the roles you can give access to\n+ // convert into array for form\nforeach ($assignableRoles as $assignableRole) {\n- if (isset($roleHierarchy[$assignableRole])) {\n- $result[$assignableRole] = $roleHierarchy[$assignableRole];\n- } else {\n- $result[$assignableRole] = [];\n- }\n+ $result[$assignableRole] = $assignableRole;\n}\nreturn $result;\n}\n-\n- private function _denyUnlessRolesAssignable($roles) {\n- // check if there is no attempt to assign roles that are not granted to the current logged in user\n- foreach ($roles as $role) {\n- if (in_array($role, $this->assignableRolesUnchecked, true)) {\n- // skip checking roles specified as unchecked\n- continue;\n- }\n- $this->denyAccessUnlessGranted($role);\n- }\n- }\n-\n- /**\n- * @return array\n- */\n- private function _getAssignableRoles(): array\n- {\n- $assignableRoles = array_filter($this->assignableRoles, function ($role) {\n- return $this->isGranted($role);\n- });\n- $userCanAssignUncheckedRoles = $this->isGranted('assign_unchecked_roles');\n- if ($userCanAssignUncheckedRoles) {\n- $assignableRoles = array_merge($assignableRoles, $this->assignableRolesUnchecked);\n- }\n- return $assignableRoles;\n- }\n-\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Form/UserType.php",
"new_path": "src/Form/UserType.php",
"diff": "@@ -45,12 +45,12 @@ class UserType extends AbstractType\n// Create custom role options array\n$roleOptions = [];\n$custom_roles = $options['roles'];\n- foreach ($custom_roles as $roleName => $roleHierarchy) {\n+ foreach ($custom_roles as $roleName => $roleValue) {\n// For some reason these select arrays are built like\n// array-key => Label\n// array-value => Key which is used to save in the DB (and used for validation)\n- $label = mb_strtolower(implode(', ', $roleHierarchy));\n- $roleOptions[$label] = $roleName;\n+ // (at the moment $roleName and $roleValue are almost always the same, but this could change in the future)\n+ $roleOptions[$roleName] = $roleValue;\n}\n// Create custom location options array\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/SwitchUserVoter.php",
"new_path": "src/Security/SwitchUserVoter.php",
"diff": "@@ -31,15 +31,14 @@ class SwitchUserVoter extends Voter\nprotected function supports($attribute, $subject)\n{\n- return $attribute === 'CAN_SWITCH_USER'\n- && $subject instanceof UserInterface;\n+ return $attribute === 'CAN_SWITCH_USER' && $subject === null;\n}\nprotected function voteOnAttribute($attribute, $subject, TokenInterface $token)\n{\n$user = $token->getUser();\n- // if the user is anonymous or if the subject is not a user, do not grant access\n- if (!$user instanceof UserInterface || !$subject instanceof UserInterface) {\n+ // if the user is anonymous or if the subject is set, do not grant access\n+ if (!$user instanceof UserInterface || $subject !== null) {\nreturn false;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/users/listing.html.twig",
"new_path": "templates/users/listing.html.twig",
"diff": "{% endif %}\n<td>{% if iteratedUser.lastIp %}<code>{{ iteratedUser.lastIp }}</code>{% else %}-{% endif %}</td>\n<td>\n+ {% if is_granted('user:edit') %}\n{{ macro.buttonlink('action.edit', path('bolt_user_edit', {'id': iteratedUser.id}), 'edit', 'secondary sm') }}\n+ {% endif %}\n{% if user.id != iteratedUser.id %}\n+ {% if is_granted('user:status') %}\n{% if iteratedUser.status !== 'disabled' %}\n{{ macro.buttonlink('action.disable', path('bolt_user_update_status', {'id': iteratedUser.id, '_csrf_token': csrf_token('useredit'), 'status': 'disabled'}), 'ban', 'secondary sm') }}\n{% endif %}\n{% if iteratedUser.status !== 'enabled' %}\n{{ macro.buttonlink('action.enable', path('bolt_user_update_status', {'id': iteratedUser.id, '_csrf_token': csrf_token('useredit'), 'status': 'enabled'}), 'thumbs-up', 'secondary sm') }}\n{% endif %}\n+ {% endif %}\n+ {% if is_granted('CAN_SWITCH_USER') %}\n{{ macro.buttonlink('action.impersonate', path('bolt_dashboard', {'_switch_user': iteratedUser.username}), 'user-shield', 'secondary sm') }}\n+ {% endif %}\n+ {% if is_granted('user:delete') %}\n{{ macro.buttonlink('action.delete', path('bolt_user_delete', {'id': iteratedUser.id, '_csrf_token': csrf_token('useredit')}), 'trash', 'danger sm', {'data-confirmation': 'action.confirm_delete'|trans }) }}\n{% endif %}\n+ {% endif %}\n</td>\n</tr>\n{% endfor %}\n</table>\n<p class=\"buttons\">\n+ {% if is_granted('user:add') %}\n{{ macro.buttonlink('action.add_user', path('bolt_user_add'), 'user-plus', 'secondary') }}\n+ {% endif %}\n</p>\n<h3>Current sessions</h3>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
- simplified user role assignment permissions to a workable system
- updated visibility of action buttons on listing screen
- fixed voter for switch user permission
|
95,115 |
10.01.2021 20:30:05
| -3,600 |
5145f9184c532bde7a04177ddd0af0de497713de
|
fix UserEditController.php missing methods
permission checks + visibility in menu 90% done for non-content permissions
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -28,24 +28,21 @@ global:\nmanagefiles:config: [ ROLE_DEVELOPER ] # all configuration yml files /bolt/filemanager/config and /bolt/file-edit/config?file=/bolt/menu.yaml\nmanagefiles:files: [ ROLE_ADMIN ]\nmanagefiles:themes: [ ROLE_DEVELOPER ]\n-# prefill: [ developer ]\n- profile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\n-# settings: [ admin, developer, everyone ]\n-# translation: [ developer ]\n- user:list: [ ROLE_ADMIN, ROLE_EDITOR ] # overview listing of users and a list of active sessions\n+ profile: [ IS_AUTHENTICATED_FULLY ] # edit own profile TODO PERMISSIONS\n+ translation: [ ROLE_ADMIN ] # TODO PERMISSIONS how to enforce this?\n+ user:list: [ ROLE_ADMIN ] # overview listing of users and a list of active sessions\nuser:add: [ ROLE_ADMIN ] # add user - allows editing user _before_ saving, can set status on create, after saving 'useredit' is needed.\nuser:status: [ ROLE_ADMIN ] # user enable/disable\nuser:delete: [ ROLE_ADMIN ] # user delete\nuser:edit: [ ROLE_ADMIN ] # user edit all fields, includes user:status permissions\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n- omnisearch: [ IS_AUTHENTICATED_ANONYMOUSLY ]\n-# # Access to the various logs\n-# changelog: [ admin, developer, chief-editor ]\n+# omnisearch: [ IS_AUTHENTICATED_ANONYMOUSLY ]\nsystemlog: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n# NEW\n+ api: [ ROLE_CHIEF_EDITOR ] # TODO PERMISSIONS how to enforce this?\nbulk_operations: [ ROLE_CHIEF_EDITOR ]\nkitchensink: [ ROLE_DEVELOPER ]\n- upload: [ ROLE_EDITOR ] # upload media/files\n+ upload: [ ROLE_EDITOR ] # TODO PERMISSIONS upload media/files ? Or should this be handled by managefiles:files\nextensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\n# For content type related actions, permissions can be set individually for\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -114,7 +114,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/**\n* @Route(\"/user-edit/{id}\", methods={\"GET\",\"POST\"}, name=\"bolt_user_edit\", requirements={\"id\": \"\\d+\"})\n- * @Route(\"/profile-edit\", methods={\"GET\",\"POST\"}, name=\"bolt_profile_edit\")\n+ * @Route(\"/profile-edit\", methods={\"GET\",\"POST\"}, name=\"bolt_profile_edit\") TODO PERMISSIONS move to separate function so we can correctly check permissions\n*\n* @Security(\"is_granted('user:edit')\") -- first check, more detailed checks in method\n*/\n@@ -198,8 +198,6 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n{\n$this->validateCsrf('useredit');\n- $this->_denyUnlessRolesAssignable($user->getRoles());\n-\n$newStatus = $this->request->get('status', UserStatus::DISABLED);\n$user->setStatus($newStatus);\n@@ -253,8 +251,6 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n/** @var User $user */\n$user = $form->getData();\n- $this->_denyUnlessRolesAssignable($user->getRoles());\n-\n// Once validated, encode the password\nif ($user->getPlainPassword()) {\n$user->setPassword($this->passwordEncoder->encodePassword($user, $user->getPlainPassword()));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -128,6 +128,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n],\n]);\n+ if ($this->authorizationChecker->isGranted('user:list')) {\n$menu->getChild('Configuration')->addChild('Users & Permissions', [\n'uri' => $this->urlGenerator->generate('bolt_users'),\n'extras' => [\n@@ -135,7 +136,9 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-users',\n],\n]);\n+ }\n+ if ($this->authorizationChecker->isGranted('managefiles:config')) {\n$menu->getChild('Configuration')->addChild('Main configuration', [\n'uri' => $this->urlGenerator->generate('bolt_file_edit', [\n'location' => 'config',\n@@ -199,6 +202,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-cogs',\n],\n]);\n+ }\n// Maintenance submenu\n// TODO PERMISSIONS\n@@ -213,6 +217,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n],\n]);\n+ if ($this->authorizationChecker->isGranted('extensions')) {\n$menu->getChild('Maintenance')->addChild('Extensions', [\n'uri' => $this->urlGenerator->generate('bolt_extensions'),\n'extras' => [\n@@ -220,7 +225,9 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-plug',\n],\n]);\n+ }\n+ if ($this->authorizationChecker->isGranted('systemlog')) {\n$menu->getChild('Maintenance')->addChild('Log viewer', [\n'uri' => $this->urlGenerator->generate('bolt_logviewer'),\n'extras' => [\n@@ -228,6 +235,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-clipboard',\n],\n]);\n+ }\n$menu->getChild('Maintenance')->addChild('Bolt API', [\n'uri' => $this->urlGenerator->generate('api_entrypoint'),\n@@ -248,6 +256,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n// ],\n// ]);\n+ if ($this->authorizationChecker->isGranted('clearcache')) {\n$menu->getChild('Maintenance')->addChild('Clear the cache', [\n'uri' => $this->urlGenerator->generate('bolt_clear_cache'),\n'extras' => [\n@@ -255,6 +264,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-eraser',\n],\n]);\n+ }\n/*\n* @todo Make Installation checks work from the backend\n@@ -286,6 +296,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n}\n+ if ($this->authorizationChecker->isGranted('about')) {\n$menu->getChild('Maintenance')->addChild('About Bolt', [\n'uri' => $this->urlGenerator->generate('bolt_about'),\n'extras' => [\n@@ -293,6 +304,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-award',\n],\n]);\n+ }\n// File Management submenu\n// TODO PERMISSIONS\n@@ -307,6 +319,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n],\n]);\n+ if ($this->authorizationChecker->isGranted('managefiles:files')) {\n$menu->getChild('File Management')->addChild('Uploaded files', [\n'uri' => $this->urlGenerator->generate('bolt_filemanager', ['location' => 'files']),\n'extras' => [\n@@ -314,7 +327,9 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-archive',\n],\n]);\n+ }\n+ if ($this->authorizationChecker->isGranted('managefiles:themes')) {\n$menu->getChild('File Management')->addChild('View/edit Templates', [\n'uri' => $this->urlGenerator->generate('bolt_filemanager', ['location' => 'themes']),\n'extras' => [\n@@ -322,6 +337,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-scroll',\n],\n]);\n+ }\nreturn $menu;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/GlobalVoter.php",
"new_path": "src/Security/GlobalVoter.php",
"diff": "@@ -39,9 +39,6 @@ class GlobalVoter extends Voter\nprotected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n{\n-// if ($this->security->isGranted('ROLE_SUPER_ADMIN')) {\n-// return true;\n-// }\n$user = $token->getUser();\n@@ -50,6 +47,13 @@ class GlobalVoter extends Voter\nreturn false;\n}\n+ if ($attribute === 'user:status') {\n+ // users with 'user:edit' also have 'user:status' permission\n+ if ($this->voteOnAttribute('user:edit', $subject, $token)) {\n+ return true;\n+ }\n+ }\n+\nif (! isset($this->globalPermissions[$attribute])) {\nthrow new \\DomainException(\"Global permission '${attribute}' not defined, check your security and permissions configuration.\");\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
- fix UserEditController.php missing methods
- permission checks + visibility in menu 90% done for non-content permissions
|
95,115 |
10.01.2021 22:57:24
| -3,600 |
889d6306c76b6f21a83ee4008e6ddb3c206c513d
|
change settings so ROLE_ADMIN keeps the same permissions - this should fix the tests
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -20,14 +20,14 @@ assignable_roles: [ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR, ROLE_EXTRA_1, ROL\n# inside the code, so they don't appear here.\nglobal:\nabout: [ IS_AUTHENTICATED_ANONYMOUSLY ] # view the 'About Bolt' page\n- clearcache: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n+ clearcache: [ ROLE_ADMIN ]\ndashboard: [ IS_AUTHENTICATED_FULLY ]\n- extensions: [ ROLE_DEVELOPER ]\n+ extensions: [ ROLE_ADMIN ]\n# these control /bolt/file-edit and /bolt/filemanager -> combined create/read/update/delete permission\n# the part after the files: is the 'location' where the files are part of\n- managefiles:config: [ ROLE_DEVELOPER ] # all configuration yml files /bolt/filemanager/config and /bolt/file-edit/config?file=/bolt/menu.yaml\n+ managefiles:config: [ ROLE_ADMIN ] # all configuration yml files /bolt/filemanager/config and /bolt/file-edit/config?file=/bolt/menu.yaml\nmanagefiles:files: [ ROLE_ADMIN ]\n- managefiles:themes: [ ROLE_DEVELOPER ]\n+ managefiles:themes: [ ROLE_ADMIN ]\nprofile: [ IS_AUTHENTICATED_FULLY ] # edit own profile TODO PERMISSIONS\ntranslation: [ ROLE_ADMIN ] # TODO PERMISSIONS how to enforce this?\nuser:list: [ ROLE_ADMIN ] # overview listing of users and a list of active sessions\n@@ -37,11 +37,11 @@ global:\nuser:edit: [ ROLE_ADMIN ] # user edit all fields, includes user:status permissions\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n# omnisearch: [ IS_AUTHENTICATED_ANONYMOUSLY ]\n- systemlog: [ ROLE_ADMIN, ROLE_DEVELOPER ]\n+ systemlog: [ ROLE_ADMIN ]\n# NEW\napi: [ ROLE_CHIEF_EDITOR ] # TODO PERMISSIONS how to enforce this?\nbulk_operations: [ ROLE_CHIEF_EDITOR ]\n- kitchensink: [ ROLE_DEVELOPER ]\n+ kitchensink: [ ROLE_ADMIN ]\nupload: [ ROLE_EDITOR ] # TODO PERMISSIONS upload media/files ? Or should this be handled by managefiles:files\nextensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
change settings so ROLE_ADMIN keeps the same permissions - this should fix the tests
|
95,148 |
11.01.2021 13:51:06
| -3,600 |
04ddee03ca72ff3315d604a552b7f2658960e76a
|
test if currentLocale exist
|
[
{
"change_type": "MODIFY",
"old_path": "templates/bundles/TranslationBundle/WebUI/base.html.twig",
"new_path": "templates/bundles/TranslationBundle/WebUI/base.html.twig",
"diff": "{% block javascripts %}\n{{ parent() }}\n+ {% if currentLocale is defined %}\n<script type=\"text/javascript\">\nvar editUrl = \"{{ path('translation_edit', {configName: configName, locale:currentLocale,domain:currentDomain}) }}\";\n</script>\n+ {% endif %}\n<script type=\"text/javascript\" src=\"{{ asset(\"bundles/translation/js/webui.js\") }}\"></script>\n{% endblock %}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
test if currentLocale exist
|
95,144 |
13.01.2021 12:19:55
| -3,600 |
890816aead165aa55c758e2bab79c7559d9263b2
|
Prepare release 4.2.0-beta.5
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/version.js",
"new_path": "assets/js/version.js",
"diff": "// generated by genversion\n-export const version = '4.1.99.4';\n+export const version = '4.1.99.5';\n"
},
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.99.4\",\n+ \"version\": \"4.1.99.5\",\n\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.99.4\",\n+ \"version\": \"4.1.99.5\",\n\"homepage\": \"https://boltcms.io\",\n\"author\": \"Bob den Otter <bob@twokings.nl> (https://boltcms.io)\",\n\"license\": \"MIT\",\n\"@babel/preset-env\": \"^7.12.11\",\n\"@fortawesome/fontawesome-free\": \"^5.15.1\",\n\"@symfony/webpack-encore\": \"^0.31.1\",\n- \"@vue/test-utils\": \"^1.1.1\",\n+ \"@vue/test-utils\": \"^1.1.2\",\n\"ajv-keywords\": \"^3.5.2\",\n\"autoprefixer\": \"^9.8.6\",\n\"babel-core\": \"^7.0.0-bridge.0\",\n\"stylelint\": \"^13.8.0\",\n\"stylelint-config-standard\": \"^19.0.0\",\n\"vue-jest\": \"^3.0.7\",\n- \"vue-loader\": \"^15.9.5\",\n+ \"vue-loader\": \"^15.9.6\",\n\"vue-router\": \"^3.4.9\",\n\"vue-template-compiler\": \"^2.6.12\",\n\"webpackbar\": \"^4.0.0\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Prepare release 4.2.0-beta.5
|
95,115 |
20.01.2021 22:07:49
| -3,600 |
05b0da7640573478051b82de8a93e9c84b6bc6ec
|
Made switch user voter a bit to restrictive
|
[
{
"change_type": "MODIFY",
"old_path": "src/Security/SwitchUserVoter.php",
"new_path": "src/Security/SwitchUserVoter.php",
"diff": "@@ -30,14 +30,14 @@ class SwitchUserVoter extends Voter\nprotected function supports($attribute, $subject)\n{\n- return $attribute === 'CAN_SWITCH_USER' && $subject === null;\n+ return $attribute === 'CAN_SWITCH_USER';\n}\nprotected function voteOnAttribute($attribute, $subject, TokenInterface $token)\n{\n$user = $token->getUser();\n- // if the user is anonymous or if the subject is set, do not grant access\n- if (! $user instanceof UserInterface || $subject !== null) {\n+ // if the user is anonymous, do not grant access (or should we check $subject?)\n+ if (! $user instanceof UserInterface) {\nreturn false;\n}\n@@ -45,13 +45,6 @@ class SwitchUserVoter extends Voter\nreturn true;\n}\n- /*\n- * or use some custom data from your User object\n- if ($user->isAllowedToSwitch()) {\n- return true;\n- }\n- */\n-\nreturn false;\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Made switch user voter a bit to restrictive
|
95,115 |
20.01.2021 22:08:19
| -3,600 |
0f79c8a52a0b3782ed4160f63e3cc7a24d65bdcb
|
separate editing 'own profile' from editing another user
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -113,81 +113,25 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n}\n/**\n- * @Route(\"/user-edit/{id}\", methods={\"GET\",\"POST\"}, name=\"bolt_user_edit\", requirements={\"id\": \"\\d+\"})\n* @Route(\"/profile-edit\", methods={\"GET\",\"POST\"}, name=\"bolt_profile_edit\") TODO PERMISSIONS move to separate function so we can correctly check permissions\n*\n- * @Security(\"is_granted('user:edit')\") -- first check, more detailed checks in method\n+ * @Security(\"is_granted('editprofile')\")\n*/\n- public function edit(?User $user, Request $request): Response\n+ public function editProfile(Request $request): Response\n{\n$submitted_data = $request->request->get('user');\n- $is_profile_edit = false;\n-\n- // $user is null on /profile-edit but not on /user-edit/<ID>\n- if ($user === null) {\n- $user = $this->getUser();\n- $is_profile_edit = true;\n- }\n-\n- $event = new UserEvent($user);\n- $this->dispatcher->dispatch($event, UserEvent::ON_EDIT);\n-\n- $roles = $this->_getPossibleRolesForForm();\n-\n- // We don't require the user to set the password again on the \"user edit\" form\n- // If it is otherwise set use the given password normally\n- $require_password = false;\n- if (! empty($submitted_data['plainPassword'])) {\n- $require_password = true;\n- }\n-\n- // These are the variables we have to pass into our FormType so we can build the fields correctly\n- $form_data = [\n- 'suggested_password' => Str::generatePassword(),\n- 'roles' => $roles,\n- 'require_username' => false,\n- 'require_password' => $require_password,\n- 'default_locale' => $this->defaultLocale,\n- 'is_profile_edit' => $is_profile_edit,\n- ];\n- $form = $this->createForm(UserType::class, $user, $form_data);\n-\n- // ON SUBMIT\n- if (! empty($submitted_data)) {\n- // Since the username is disabled on edit form we need to set it here so Symfony Forms doesn't throw an error\n- $submitted_data['username'] = $user->getUsername();\n-\n- $submitted_data['locale'] = json_decode($submitted_data['locale'])[0];\n-\n- // Status is not available for profile edit on non admin users\n- if (! empty($submitted_data['status'])) {\n- $submitted_data['status'] = json_decode($submitted_data['status'])[0];\n- }\n-\n- // Roles is not available for profile edit on non admin users\n- if (! empty($submitted_data['roles'])) {\n- // We need to transform to JSON.stringify value for the field \"roles\" into\n- // an array so symfony forms validation works\n- $submitted_data['roles'] = json_decode($submitted_data['roles']);\n+ return $this->handleEdit(true, $this->getUser(), $submitted_data);\n}\n- // Transform media array to keep only filepath\n- $submitted_data['avatar'] = $submitted_data['avatar']['filename'];\n-\n- $form->submit($submitted_data);\n- }\n- if ($form->isSubmitted() && $form->isValid()) {\n- $this->_handleValidFormSubmit($form);\n- if ($is_profile_edit) {\n- return $this->redirectToRoute('bolt_profile_edit');\n- }\n-\n- return $this->redirectToRoute('bolt_users');\n- }\n-\n- return $this->render('@bolt/users/edit.html.twig', [\n- 'userForm' => $form->createView(),\n- ]);\n+ /**\n+ * @Route(\"/user-edit/{id}\", methods={\"GET\",\"POST\"}, name=\"bolt_user_edit\", requirements={\"id\": \"\\d+\"})\n+ *\n+ * @Security(\"is_granted('user:edit')\")\n+ */\n+ public function edit(User $user, Request $request): Response\n+ {\n+ $submitted_data = $request->request->get('user');\n+ return $this->handleEdit(false, $user, $submitted_data);\n}\n/**\n@@ -282,4 +226,70 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\nreturn $result;\n}\n+\n+ /**\n+ * @param bool $is_profile_edit\n+ * @param \\Symfony\\Component\\Security\\Core\\User\\UserInterface|null $user\n+ * @param $submitted_data\n+ * @return RedirectResponse|Response\n+ */\n+ private function handleEdit(bool $is_profile_edit, ?\\Symfony\\Component\\Security\\Core\\User\\UserInterface $user, $submitted_data)\n+ {\n+ $redirectRouteAfterSubmit = $is_profile_edit ? 'bolt_profile_edit' : 'bolt_users';\n+ $event = new UserEvent($user);\n+ $this->dispatcher->dispatch($event, UserEvent::ON_EDIT);\n+\n+ $roles = $this->_getPossibleRolesForForm();\n+\n+ // We don't require the user to set the password again on the \"user edit\" form\n+ // If it is otherwise set use the given password normally\n+ $require_password = false;\n+ if (!empty($submitted_data['plainPassword'])) {\n+ $require_password = true;\n+ }\n+\n+ // These are the variables we have to pass into our FormType so we can build the fields correctly\n+ $form_data = [\n+ 'suggested_password' => Str::generatePassword(),\n+ 'roles' => $roles,\n+ 'require_username' => false,\n+ 'require_password' => $require_password,\n+ 'default_locale' => $this->defaultLocale,\n+ 'is_profile_edit' => $is_profile_edit,\n+ ];\n+ $form = $this->createForm(UserType::class, $user, $form_data);\n+\n+ // ON SUBMIT\n+ if (!empty($submitted_data)) {\n+ // Since the username is disabled on edit form we need to set it here so Symfony Forms doesn't throw an error\n+ $submitted_data['username'] = $user->getUsername();\n+\n+ $submitted_data['locale'] = json_decode($submitted_data['locale'])[0];\n+\n+ // Status is not available for profile edit on non admin users\n+ if (!empty($submitted_data['status'])) {\n+ $submitted_data['status'] = json_decode($submitted_data['status'])[0];\n+ }\n+\n+ // Roles is not available for profile edit on non admin users\n+ if (!empty($submitted_data['roles'])) {\n+ // We need to transform to JSON.stringify value for the field \"roles\" into\n+ // an array so symfony forms validation works\n+ $submitted_data['roles'] = json_decode($submitted_data['roles']);\n+ }\n+\n+ // Transform media array to keep only filepath\n+ $submitted_data['avatar'] = $submitted_data['avatar']['filename'];\n+\n+ $form->submit($submitted_data);\n+ }\n+ if ($form->isSubmitted() && $form->isValid()) {\n+ $this->_handleValidFormSubmit($form);\n+ return $this->redirectToRoute($redirectRouteAfterSubmit);\n+ }\n+\n+ return $this->render('@bolt/users/edit.html.twig', [\n+ 'userForm' => $form->createView(),\n+ ]);\n+ }\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
separate editing 'own profile' from editing another user
|
95,115 |
20.01.2021 22:09:38
| -3,600 |
e0be2fd0da7bf61395b450d6e4d59bedae7bf4b8
|
various updates to permissions.yaml
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -28,7 +28,7 @@ global:\nmanagefiles:config: [ ROLE_ADMIN ] # all configuration yml files /bolt/filemanager/config and /bolt/file-edit/config?file=/bolt/menu.yaml\nmanagefiles:files: [ ROLE_ADMIN ]\nmanagefiles:themes: [ ROLE_ADMIN ]\n- profile: [ IS_AUTHENTICATED_FULLY ] # edit own profile TODO PERMISSIONS\n+ editprofile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\ntranslation: [ ROLE_ADMIN ] # TODO PERMISSIONS how to enforce this?\nuser:list: [ ROLE_ADMIN ] # overview listing of users and a list of active sessions\nuser:add: [ ROLE_ADMIN ] # add user - allows editing user _before_ saving, can set status on create, after saving 'useredit' is needed.\n@@ -36,7 +36,6 @@ global:\nuser:delete: [ ROLE_ADMIN ] # user delete\nuser:edit: [ ROLE_ADMIN ] # user edit all fields, includes user:status permissions\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n-# omnisearch: [ IS_AUTHENTICATED_ANONYMOUSLY ]\nsystemlog: [ ROLE_ADMIN ]\n# NEW\napi: [ ROLE_CHIEF_EDITOR ] # TODO PERMISSIONS how to enforce this?\n@@ -107,9 +106,8 @@ contenttype-base:\ncontenttype-default:\nedit: [ ROLE_CHIEF_EDITOR, CONTENT_OWNER ]\ncreate: [ ROLE_CHIEF_EDITOR ]\n- change-ownership: [ CONTENT_OWNER ] # <-- how to handle chance-ownership permission without 'edit'?\n+ change-ownership: [ CONTENT_OWNER ] # <-- NOT IMPLEMENTED YET (and: how to handle chance-ownership permission without 'edit'?)\nview: [ ROLE_CHIEF_EDITOR ]\n-# view: [ IS_AUTHENTICATED_FULLY ]\ncontenttypes:\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
various updates to permissions.yaml
|
95,115 |
20.01.2021 22:40:26
| -3,600 |
1eac51137b9cd9866ac86df08df18bc774df2e20
|
clean up BackendMenuBuilder.php: remove TODO items that have been done and clean up empty nested menus
|
[
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -21,7 +21,6 @@ use Symfony\\Contracts\\Translation\\TranslatorInterface;\n/**\n* Class BackendMenuBuilder\n*\n- * TODO PERMISSIONS -- add checks for menu items (don't show / disable when not available)\n*/\nfinal class BackendMenuBuilder implements BackendMenuBuilderInterface\n{\n@@ -100,7 +99,6 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n$this->addContentOthers($menu);\n- // TODO PERMISSIONS -- should we check for any type of permission? Maybe a single global one makes sense.\nif ($this->authorizationChecker->isGranted('extensionmenus')) {\n$this->addExtensionMenus($menu);\n}\n@@ -114,7 +112,6 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n// Configuration submenu\n- // TODO PERMISSIONS\n$menu->addChild('Configuration', [\n'uri' => $this->urlGenerator->generate('bolt_menupage', [\n'slug' => 'configuration',\n@@ -203,7 +200,6 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n}\n// Maintenance submenu\n- // TODO PERMISSIONS\n$menu->addChild('Maintenance', [\n'uri' => $this->urlGenerator->generate('bolt_menupage', [\n'slug' => 'maintenance',\n@@ -235,6 +231,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n}\n+ // TODO PERMISSIONS we can hide this item, but that will not make the api unavailable\n$menu->getChild('Maintenance')->addChild('Bolt API', [\n'uri' => $this->urlGenerator->generate('api_entrypoint'),\n'extras' => [\n@@ -275,6 +272,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n// ],\n// ]);\n+ // TODO PERMISSIONS we can hide this item, but that will not make the translation system unavailable\n$menu->getChild('Maintenance')->addChild('Translations', [\n'uri' => $this->urlGenerator->generate('translation_index'),\n'extras' => [\n@@ -283,7 +281,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n],\n]);\n- // Hide this menu item, unless we're on a \"Git clone\" install.\n+ // Hide this menu item, unless we're on a \"Git clone\" install and user has 'kitchensink' permissions\nif (Version::installType() === 'Git clone' && $this->authorizationChecker->isGranted('kitchensink')) {\n$menu->getChild('Maintenance')->addChild('The Kitchensink', [\n'uri' => $this->urlGenerator->generate('bolt_kitchensink'),\n@@ -305,7 +303,6 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n}\n// File Management submenu\n- // TODO PERMISSIONS\n$menu->addChild('File Management', [\n'uri' => $this->urlGenerator->generate('bolt_menupage', [\n'slug' => 'filemanagement',\n@@ -337,6 +334,15 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n}\n+ //\n+ // These 'container' menus can be empty due to permissions - remove them if this is the case\n+ //\n+ foreach (['Configuration', 'Maintenance', 'File Management'] as $menuName) {\n+ if ($menu->getChild($menuName) !== null && count($menu->getChild($menuName)->getChildren()) === 0) {\n+ $menu->removeChild($menuName);\n+ }\n+ }\n+\nreturn $menu;\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
clean up BackendMenuBuilder.php: remove TODO items that have been done and clean up empty nested menus
|
95,115 |
20.01.2021 22:40:44
| -3,600 |
3b522cadbae5a0276187d2e47c87dd899c894a09
|
clean up: remove TODO items that have been done
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/MenuPageController.php",
"new_path": "src/Controller/Backend/MenuPageController.php",
"diff": "@@ -8,9 +8,6 @@ use Bolt\\Controller\\TwigAwareController;\nuse Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n-/**\n- * TODO PERMISSIONS removed check here - check if checks in twig are set. (probably not in twig itself but in the admin_menu_array() call)\n- */\nclass MenuPageController extends TwigAwareController implements BackendZoneInterface\n{\n/**\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -113,7 +113,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n}\n/**\n- * @Route(\"/profile-edit\", methods={\"GET\",\"POST\"}, name=\"bolt_profile_edit\") TODO PERMISSIONS move to separate function so we can correctly check permissions\n+ * @Route(\"/profile-edit\", methods={\"GET\",\"POST\"}, name=\"bolt_profile_edit\")\n*\n* @Security(\"is_granted('editprofile')\")\n*/\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
clean up: remove TODO items that have been done
|
95,115 |
22.01.2021 23:05:29
| -3,600 |
b70b8e6a020f94c41f2d1960a33f80cc903faa69
|
english translation keys added
|
[
{
"change_type": "MODIFY",
"old_path": "translations/messages.en.xlf",
"new_path": "translations/messages.en.xlf",
"diff": "<target>Share secure preview link</target>\n</segment>\n</unit>\n+ <unit id=\"zYeSeNJ\" name=\"action.stop_impersonating\">\n+ <segment>\n+ <source>action.stop_impersonating</source>\n+ <target>stop impersonating</target>\n+ </segment>\n+ </unit>\n+ <unit id=\"W7z__Yi\" name=\"action.impersonate\">\n+ <segment>\n+ <source>action.impersonate</source>\n+ <target>impersonate</target>\n+ </segment>\n+ </unit>\n</file>\n</xliff>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
english translation keys added
|
95,115 |
22.01.2021 23:09:14
| -3,600 |
8f223516313d42ce599647de3764be21c501b076
|
updated permissions setup for user edit form (UserType.php)
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -31,8 +31,8 @@ global:\neditprofile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\ntranslation: [ ROLE_ADMIN ] # TODO PERMISSIONS how to enforce this?\nuser:list: [ ROLE_ADMIN ] # overview listing of users and a list of active sessions\n- user:add: [ ROLE_ADMIN ] # add user - allows editing user _before_ saving, can set status on create, after saving 'useredit' is needed.\n- user:status: [ ROLE_ADMIN ] # user enable/disable\n+ user:add: [ ROLE_ADMIN ] # add user - allows editing user _before_ saving, can set roles, status on create, after saving 'useredit' is needed.\n+ user:status: [ ROLE_ADMIN ] # user enable/disable - only used for changing status outside of add/edit context\nuser:delete: [ ROLE_ADMIN ] # user delete\nuser:edit: [ ROLE_ADMIN ] # user edit all fields, includes user:status permissions\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/UserEditController.php",
"new_path": "src/Controller/Backend/UserEditController.php",
"diff": "@@ -83,6 +83,7 @@ class UserEditController extends TwigAwareController implements BackendZoneInter\n'require_username' => true,\n'require_password' => true,\n'default_locale' => $this->defaultLocale,\n+ 'is_profile_edit' => false,\n];\n$form = $this->createForm(UserType::class, $user, $form_data);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Form/UserType.php",
"new_path": "src/Form/UserType.php",
"diff": "@@ -17,6 +17,7 @@ use Symfony\\Component\\Form\\Extension\\Core\\Type\\TextType;\nuse Symfony\\Component\\Form\\FormBuilderInterface;\nuse Symfony\\Component\\Form\\FormInterface;\nuse Symfony\\Component\\OptionsResolver\\OptionsResolver;\n+use Symfony\\Component\\Security\\Core\\Security;\nuse Twig\\Environment;\nclass UserType extends AbstractType\n@@ -30,7 +31,9 @@ class UserType extends AbstractType\n/** @var DeepCollection */\nprivate $avatarConfig;\n- public function __construct(LocaleHelper $localeHelper, Environment $twig, Config $config)\n+ private $security;\n+\n+ public function __construct(LocaleHelper $localeHelper, Environment $twig, Config $config, Security $security)\n{\n$this->localeHelper = $localeHelper;\n$this->twig = $twig;\n@@ -38,6 +41,8 @@ class UserType extends AbstractType\n/** @var DeepCollection $config */\n$config = $config->get('general');\n$this->avatarConfig = $config->get('user_avatar');\n+\n+ $this->security = $security;\n}\npublic function buildForm(FormBuilderInterface $builder, array $options): void\n@@ -104,12 +109,14 @@ class UserType extends AbstractType\n;\n/*\n- * Allow Roles and Status to be set if either\n- * - this form is used to add a new user\n- * - if the given user object (=logged in user in profile edit page) has ROLE_ADMIN\n+ * Add Roles and Status if the form is used to add a new user or edit an existing one\n+ * AND the current user has add OR edit rights.\n+ * (check if either editing or adding is allowed is done in the controller)\n+ *\n+ * Note that the profile edit screen never should show these options.\n*/\n- // TODO PERMISSIONS -> fix this\n- if ($options['is_profile_edit'] === false || in_array('ROLE_ADMIN', $options['data']->getRoles(), true)) {\n+ if ($options['is_profile_edit'] === false &&\n+ ($this->security->isGranted('user:add') || $this->security->isGranted('user:delete'))) {\n$builder\n->add('roles', ChoiceType::class, [\n'choices' => $roleOptions,\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
updated permissions setup for user edit form (UserType.php)
|
95,115 |
22.01.2021 23:25:43
| -3,600 |
a0a0f54aa0939e7f561bebff00185ccf1a76e086
|
fixed permissions for api in bolt admin (decided not to try and actually limit access to /bolt/api or /api)
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -37,8 +37,7 @@ global:\nuser:edit: [ ROLE_ADMIN ] # user edit all fields, includes user:status permissions\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\nsystemlog: [ ROLE_ADMIN ]\n-# NEW\n- api: [ ROLE_CHIEF_EDITOR ] # TODO PERMISSIONS how to enforce this?\n+ api_menu: [ ROLE_ADMIN ] # WARNING: this only shows/hides api in the bolt admin menu, it doesn't protect /bolt/api or /api routes\nbulk_operations: [ ROLE_CHIEF_EDITOR ]\nkitchensink: [ ROLE_ADMIN ]\nupload: [ ROLE_EDITOR ] # TODO PERMISSIONS upload media/files ? Or should this be handled by managefiles:files\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -230,7 +230,8 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n}\n- // TODO PERMISSIONS we can hide this item, but that will not make the api unavailable\n+ // Note 'api_menu' permission will show/hide this item, it will not change access to the api calls themselves\n+ if ($this->authorizationChecker->isGranted('api_menu')) {\n$menu->getChild('Maintenance')->addChild('Bolt API', [\n'uri' => $this->urlGenerator->generate('api_entrypoint'),\n'extras' => [\n@@ -238,6 +239,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-code',\n],\n]);\n+ }\n/*\n* @todo Make fixtures work from the backend\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
fixed permissions for api in bolt admin (decided not to try and actually limit access to /bolt/api or /api)
|
95,115 |
23.01.2021 01:01:43
| -3,600 |
a2ab826ad85206921e2e40c298995c0f655c4283
|
managed to come up with a reasonable way to limit access to translate and api packages that don't have their controllers in the Bolt sources.
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -29,7 +29,7 @@ global:\nmanagefiles:files: [ ROLE_ADMIN ]\nmanagefiles:themes: [ ROLE_ADMIN ]\neditprofile: [ IS_AUTHENTICATED_FULLY ] # edit own profile\n- translation: [ ROLE_ADMIN ] # TODO PERMISSIONS how to enforce this?\n+ translation: [ ROLE_ADMIN ]\nuser:list: [ ROLE_ADMIN ] # overview listing of users and a list of active sessions\nuser:add: [ ROLE_ADMIN ] # add user - allows editing user _before_ saving, can set roles, status on create, after saving 'useredit' is needed.\nuser:status: [ ROLE_ADMIN ] # user enable/disable - only used for changing status outside of add/edit context\n@@ -37,7 +37,7 @@ global:\nuser:edit: [ ROLE_ADMIN ] # user edit all fields, includes user:status permissions\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\nsystemlog: [ ROLE_ADMIN ]\n- api_menu: [ ROLE_ADMIN ] # WARNING: this only shows/hides api in the bolt admin menu, it doesn't protect /bolt/api or /api routes\n+ api_admin: [ ROLE_ADMIN ] # WARNING: this only shows/hides api in the bolt admin, it doesn't protect the /api route(s)\nbulk_operations: [ ROLE_CHIEF_EDITOR ]\nkitchensink: [ ROLE_ADMIN ]\nupload: [ ROLE_EDITOR ] # TODO PERMISSIONS upload media/files ? Or should this be handled by managefiles:files\n@@ -95,7 +95,7 @@ global:\ncontenttype-base:\nedit: [ ROLE_ADMIN ]\ncreate: [ ROLE_ADMIN ]\n- change-status: [ ROLE_ADMIN ] # <-- TODO PERMISSIONS how to handle change-status permission without 'edit'? For now it will just not work!\n+ change-status: [ ROLE_ADMIN ] # Note: You can have 'change-status' permission without 'edit' but you cannot use that at the moment as there is no screen that only handles status changes\ndelete: [ ROLE_ADMIN ]\nchange-ownership: [ ROLE_ADMIN ]\nview: [ ROLE_ADMIN ] # = show in menu, show listings, open 'edit' view without actually being able to edit, any of the other permissions always imply 'view'\n"
},
{
"change_type": "MODIFY",
"old_path": "config/packages/security.yaml",
"new_path": "config/packages/security.yaml",
"diff": "@@ -48,5 +48,9 @@ security:\n- { path: '^%bolt.backend_url%/reset-password', roles: IS_AUTHENTICATED_ANONYMOUSLY }\n# backend_url: require users to actually be logged in (not remember-me) - detailed permissions are\n# handled by Voters\n+ - { path: '^%bolt.backend_url%/api', roles: ADMIN_API_ACCESS } # handled by voter\n+ - { path: '^/(%app_locales%)%bolt.backend_url%/api', roles: ADMIN_API_ACCESS } # handled by voter\n+ - { path: '^%bolt.backend_url%/_trans', roles: ADMIN_TRANSLATE_ACCESS } # handled by voter\n+ - { path: '^/(%app_locales%)%bolt.backend_url%/_trans', roles: ADMIN_TRANSLATE_ACCESS } # handled by voter\n- { path: '^%bolt.backend_url%', roles: IS_AUTHENTICATED_FULLY }\n- { path: '^/(%app_locales%)%bolt.backend_url%', roles: IS_AUTHENTICATED_FULLY }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Menu/BackendMenuBuilder.php",
"new_path": "src/Menu/BackendMenuBuilder.php",
"diff": "@@ -230,8 +230,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n]);\n}\n- // Note 'api_menu' permission will show/hide this item, it will not change access to the api calls themselves\n- if ($this->authorizationChecker->isGranted('api_menu')) {\n+ if ($this->authorizationChecker->isGranted('api_admin')) {\n$menu->getChild('Maintenance')->addChild('Bolt API', [\n'uri' => $this->urlGenerator->generate('api_entrypoint'),\n'extras' => [\n@@ -273,7 +272,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n// ],\n// ]);\n- // TODO PERMISSIONS we can hide this item, but that will not make the translation system unavailable\n+ if ($this->authorizationChecker->isGranted('translation')) {\n$menu->getChild('Maintenance')->addChild('Translations', [\n'uri' => $this->urlGenerator->generate('translation_index'),\n'extras' => [\n@@ -281,6 +280,7 @@ final class BackendMenuBuilder implements BackendMenuBuilderInterface\n'icon' => 'fa-language',\n],\n]);\n+ }\n// Hide this menu item, unless we're on a \"Git clone\" install and user has 'kitchensink' permissions\nif (Version::installType() === 'Git clone' && $this->authorizationChecker->isGranted('kitchensink')) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Security/AdminApiVoter.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Security;\n+\n+use Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\n+use Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\n+use Symfony\\Component\\Security\\Core\\Security;\n+\n+class AdminApiVoter extends Voter\n+{\n+ public const ADMIN_API_ACCESS = 'ADMIN_API_ACCESS';\n+\n+ private $security;\n+\n+ public function __construct(Security $security)\n+ {\n+ $this->security = $security;\n+ }\n+\n+ protected function supports(string $attribute, $subject)\n+ {\n+ return $attribute === self::ADMIN_API_ACCESS;\n+ }\n+\n+ protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n+ {\n+ return $this->security->isGranted('api_admin');\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Security/AdminTranslateVoter.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Security;\n+\n+use Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface;\n+use Symfony\\Component\\Security\\Core\\Authorization\\Voter\\Voter;\n+use Symfony\\Component\\Security\\Core\\Security;\n+\n+class AdminTranslateVoter extends Voter\n+{\n+ public const ADMIN_TRANSLATE_ACCESS = 'ADMIN_TRANSLATE_ACCESS';\n+\n+ private $security;\n+\n+ public function __construct(Security $security)\n+ {\n+ $this->security = $security;\n+ }\n+\n+ protected function supports(string $attribute, $subject)\n+ {\n+ return $attribute === self::ADMIN_TRANSLATE_ACCESS;\n+ }\n+\n+ protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)\n+ {\n+ return $this->security->isGranted('translation');\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
managed to come up with a reasonable way to limit access to translate and api packages that don't have their controllers in the Bolt sources.
|
95,144 |
23.01.2021 12:04:27
| -3,600 |
fa69955770c198c91960c54eb6adbac1baf0bd1b
|
Pin API-platform to `2.5.*` for now
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"ext-json\": \"*\",\n\"ext-mbstring\": \"*\",\n\"ext-pdo\": \"*\",\n- \"api-platform/core\": \"^2.5\",\n+ \"api-platform/core\": \"2.5.*\",\n\"babdev/pagerfanta-bundle\": \"^2.5\",\n\"beberlei/doctrineextensions\": \"^1.2\",\n\"bolt/common\": \"^2.1.10\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Pin API-platform to `2.5.*` for now
|
95,144 |
24.01.2021 16:03:24
| -3,600 |
fa817a64ba74d0f33d6ad6e415c2653f99558633
|
Prepare relase 4.2.0-beta.6
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/version.js",
"new_path": "assets/js/version.js",
"diff": "// generated by genversion\n-export const version = '4.1.99.5';\n+export const version = '4.1.99.6';\n"
},
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.99.5\",\n+ \"version\": \"4.1.99.6\",\n\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.99.5\",\n+ \"version\": \"4.1.99.6\",\n\"homepage\": \"https://boltcms.io\",\n\"author\": \"Bob den Otter <bob@twokings.nl> (https://boltcms.io)\",\n\"license\": \"MIT\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Prepare relase 4.2.0-beta.6
|
95,115 |
24.01.2021 16:42:25
| -3,600 |
f07e87f4c21288e452f39dd22a3e51bdd1326ed6
|
Update config in permissions.yaml so they will be (more or less) backwards compatible. Use only ROLE_ADMIN and ROLE_EDITOR in config to keep things simple.
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "# Roles that are not in this list are left 'as is' when editing users.\n# Note: ROLE_USER is assigned to Bolt Entity Users if no roles have been set\n# it should not be included in this list as it should not be added/removed.\n-assignable_roles: [ROLE_ADMIN, ROLE_CHIEF_EDITOR, ROLE_EDITOR, ROLE_EXTRA_1, ROLE_USER_FRONTEND_GROUP2]\n+assignable_roles: [ROLE_ADMIN, ROLE_EDITOR]\n# These permissions are the 'global' permissions; these are not tied\n# to any content types, but rather apply to global, non-content activity in\n@@ -38,7 +38,7 @@ global:\n# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\nsystemlog: [ ROLE_ADMIN ]\napi_admin: [ ROLE_ADMIN ] # WARNING: this only shows/hides api in the bolt admin, it doesn't protect the /api route(s)\n- bulk_operations: [ ROLE_CHIEF_EDITOR ]\n+ bulk_operations: [ ROLE_ADMIN ]\nkitchensink: [ ROLE_ADMIN ]\nupload: [ ROLE_EDITOR ] # TODO PERMISSIONS upload media/files ? Or should this be handled by managefiles:files\nextensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\n@@ -103,10 +103,10 @@ contenttype-base:\n# these permissions are used as a default for contenttypes, they are added to the base permissions\n# you can override these settings per contenttype by adding it to the `contenttypes:` array\ncontenttype-default:\n- edit: [ ROLE_CHIEF_EDITOR, CONTENT_OWNER ]\n- create: [ ROLE_CHIEF_EDITOR ]\n+ edit: [ ROLE_EDITOR, CONTENT_OWNER ]\n+ create: [ ROLE_EDITOR ]\nchange-ownership: [ CONTENT_OWNER ] # <-- NOT IMPLEMENTED YET (and: how to handle chance-ownership permission without 'edit'?)\n- view: [ ROLE_CHIEF_EDITOR ]\n+ view: [ ROLE_EDITOR ]\ncontenttypes:\n@@ -126,18 +126,18 @@ contenttypes:\n# create: [ ROLE_CHIEF_EDITOR ]\n# change-status: [ ROLE_CHIEF_EDITOR ]\n# delete: [ ROLE_CHIEF_EDITOR ]\n- pages:\n- edit: [ ROLE_EDITOR, CONTENT_OWNER ]\n- create: [ ROLE_EDITOR ]\n- change-ownership: [ CONTENT_OWNER ]\n- view: [ ROLE_USER ]\n- entries:\n+# pages:\n+# edit: [ ROLE_EDITOR, CONTENT_OWNER ]\n+# create: [ ROLE_EDITOR ]\n+# change-ownership: [ CONTENT_OWNER ]\n+# view: [ ROLE_USER ]\n+# entries:\n# edit: [ ROLE_EDITOR ]\n# edit: [ ROLE_EDITOR, CONTENT_OWNER ]\n# create: [ ROLE_EDITOR ]\n# change-ownership: [ CONTENT_OWNER ]\n- view: [ ROLE_EDITOR ]\n- homepage: # singleton\n- view: [ ROLE_EDITOR ]\n+# view: [ ROLE_EDITOR ]\n+# homepage: # singleton\n+# view: [ ROLE_EDITOR ]\n# edit: [ ROLE_EDITOR ]\n# create: [ ROLE_EDITOR ]\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update config in permissions.yaml so they will be (more or less) backwards compatible. Use only ROLE_ADMIN and ROLE_EDITOR in config to keep things simple.
|
95,144 |
29.01.2021 15:47:22
| -3,600 |
11fc702cf1defb9a40b2c8af5777a9440c8fd758
|
New Skeleton theming
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "public/theme/skeleton/css/simple.css",
"diff": "+/* Set the global variables for everything. Change these to use your own fonts/colours. */\n+:root {\n+\n+ /* Set sans-serif & mono fonts */\n+ --sans-font: -apple-system, BlinkMacSystemFont, \"Avenir Next\", Avenir, \"Nimbus Sans L\", Roboto, Noto, \"Segoe UI\", Arial, Helvetica, \"Helvetica Neue\", sans-serif;\n+ --mono-font: Consolas, Menlo, Monaco, \"Andale Mono\", \"Ubuntu Mono\", monospace;\n+\n+ /* Body font size. By default, effectively 18.4px, based on 16px as 'root em' */\n+ --base-fontsize: 1.15rem;\n+\n+ /* Major third scale progression - see https://type-scale.com/ */\n+ --header-scale: 1.25;\n+\n+ /* Line height is set to the \"Golden ratio\" for optimal legibility */\n+ --line-height: 1.618;\n+\n+ /* Default (light) theme */\n+ --bg: #FFF;\n+ --accent-bg: #F5F7FF;\n+ --text: #212121;\n+ --text-light: #585858;\n+ --border: #D8DAE1;\n+ --accent: #0D47A1;\n+ --accent-light: #90CAF9;\n+ --code: #D81B60;\n+ --preformatted: #444;\n+ --marked: #FFDD33;\n+}\n+\n+/* Dark theme */\n+@media (prefers-color-scheme: dark) {\n+ :root {\n+ --bg: #212121;\n+ --accent-bg: #2B2B2B;\n+ --text: #DCDCDC;\n+ --text-light: #ABABAB;\n+ --border: #666;\n+ --accent: #FFB300;\n+ --accent-light: #FFECB3;\n+ --code: #F06292;\n+ --preformatted: #CCC;\n+ }\n+\n+ img, video {\n+ opacity: .6;\n+ }\n+}\n+\n+html {\n+ /* Set the font globally */\n+ font-family: var(--sans-font);\n+ font-size: 16px;\n+}\n+\n+/* Make the body a nice central block */\n+body {\n+ color: var(--text);\n+ background: var(--bg);\n+ font-size: var(--base-fontsize);\n+ line-height: var(--line-height);\n+ margin: 0;\n+}\n+\n+/* Make the main element a nice central block */\n+main {\n+ margin: 1rem auto 0;\n+ max-width: 45rem;\n+ padding: 0 .5rem;\n+}\n+\n+aside {\n+ margin: 1rem auto 0;\n+ max-width: 45rem;\n+ padding: 0 .5rem;\n+}\n+\n+/* Make the header bg full width, but the content inline with body */\n+header {\n+ background: var(--accent-bg);\n+ border-bottom: 1px solid var(--border);\n+ padding: 1.5rem 15rem;\n+ margin-bottom: 3rem;\n+}\n+\n+/* Remove margins for header text */\n+header h1,\n+header h2,\n+header p {\n+ margin: 0;\n+}\n+\n+/* Fix header line height when title wraps */\n+header h1 {\n+ line-height: 1.1;\n+}\n+\n+header select,\n+header input,\n+footer select,\n+footer input {\n+ width: auto;\n+}\n+\n+/* Format navigation */\n+nav {\n+ font-size: 1rem;\n+ line-height: 2;\n+ padding: 1rem 0 0;\n+}\n+\n+nav a {\n+ margin: 0.5rem 0.5rem 0 0;\n+ border: 1px solid var(--border);\n+ border-radius: 5px;\n+ color: var(--text) !important;\n+ display: inline-block;\n+ padding: .1rem 1rem;\n+ text-decoration: none;\n+ transition: .4s;\n+}\n+\n+nav a:hover {\n+ color: var(--accent) !important;\n+ border-color: var(--accent);\n+}\n+\n+nav a.current:hover {\n+ text-decoration: none;\n+}\n+\n+footer {\n+ background: var(--accent-bg);\n+ border-top: 1px solid var(--border);\n+ margin: 1rem auto 0;\n+ padding: 1.5rem 15rem;\n+ color: var(--text-light);\n+ font-size: 1rem;\n+ border-top: 1px solid var(--border);\n+}\n+\n+/* Reduces header padding on smaller screens */\n+@media only screen and (max-width: 1200px) {\n+ header, footer {\n+ padding: 1rem;\n+ }\n+\n+ nav {\n+ text-align: center;\n+ }\n+}\n+\n+/* Format headers */\n+h1 {\n+ font-size: calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale) * var(--header-scale) * var(--header-scale));\n+ margin-top: calc(var(--line-height) * 1.5rem);\n+}\n+\n+h2 {\n+ font-size: calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale) * var(--header-scale));\n+ margin-top: calc(var(--line-height) * 1.5rem);\n+}\n+\n+h3 {\n+ font-size: calc(var(--base-fontsize) * var(--header-scale) * var(--header-scale));\n+ margin-top: calc(var(--line-height) * 1.5rem);\n+}\n+\n+h4 {\n+ font-size: calc(var(--base-fontsize) * var(--header-scale));\n+ margin-top: calc(var(--line-height) * 1.5rem);\n+}\n+\n+h5 {\n+ font-size: var(--base-fontsize);\n+ margin-top: calc(var(--line-height) * 1.5rem);\n+}\n+\n+h6 {\n+ font-size: calc(var(--base-fontsize) / var(--header-scale));\n+ margin-top: calc(var(--line-height) * 1.5rem);\n+}\n+\n+/* Format links & buttons */\n+a,\n+a:visited {\n+ color: var(--accent);\n+}\n+\n+a:hover {\n+ text-decoration: none;\n+}\n+\n+a button,\n+button,\n+input[type=\"submit\"],\n+input[type=\"reset\"],\n+input[type=\"button\"] {\n+ border: none;\n+ border-radius: 5px;\n+ background: var(--accent);\n+ font-size: 1rem;\n+ color: var(--bg);\n+ padding: .7rem .9rem;\n+ margin: .5rem 0;\n+ transition: .4s;\n+}\n+\n+a button[disabled],\n+button[disabled],\n+input[type=\"submit\"][disabled],\n+input[type=\"reset\"][disabled],\n+input[type=\"button\"][disabled] {\n+ cursor: default;\n+ opacity: .5;\n+ cursor: not-allowed;\n+}\n+\n+/* Set the cursor to '?' while hovering over an abbreviation */\n+abbr {\n+ cursor: help;\n+}\n+\n+button:focus,\n+button:enabled:hover,\n+input[type=\"submit\"]:focus,\n+input[type=\"submit\"]:enabled:hover,\n+input[type=\"reset\"]:focus,\n+input[type=\"reset\"]:enabled:hover,\n+input[type=\"button\"]:focus,\n+input[type=\"button\"]:enabled:hover {\n+ opacity: .8;\n+}\n+\n+/* Format the expanding box */\n+details {\n+ padding: .6rem 1rem;\n+ background: var(--accent-bg);\n+ border: 1px solid var(--border);\n+ border-radius: 5px;\n+ margin-bottom: 1rem;\n+}\n+\n+summary {\n+ cursor: pointer;\n+ font-weight: bold;\n+}\n+\n+details[open] {\n+ padding-bottom: .75rem;\n+}\n+\n+details[open] summary {\n+ margin-bottom: .5rem;\n+}\n+\n+details[open]>*:last-child {\n+ margin-bottom: 0;\n+}\n+\n+/* Format tables */\n+table {\n+ border-collapse: collapse;\n+ width: 100%\n+}\n+\n+td,\n+th {\n+ border: 1px solid var(--border);\n+ text-align: left;\n+ padding: .5rem;\n+}\n+\n+th {\n+ background: var(--accent-bg);\n+ font-weight: bold;\n+}\n+\n+tr:nth-child(even) {\n+ /* Set every other cell slightly darker. Improves readability. */\n+ background: var(--accent-bg);\n+}\n+\n+table caption {\n+ font-weight: bold;\n+ margin-bottom: .5rem;\n+}\n+\n+/* Lists */\n+ol,\n+ul {\n+ padding-left: 3rem;\n+}\n+\n+/* Format forms */\n+textarea,\n+select,\n+input {\n+ font-size: inherit;\n+ font-family: inherit;\n+ padding: .5rem;\n+ margin-bottom: .5rem;\n+ color: var(--text);\n+ background: var(--bg);\n+ border: 1px solid var(--border);\n+ border-radius: 5px;\n+ box-shadow: none;\n+ box-sizing: border-box;\n+ width: 60%;\n+}\n+\n+/* Make the textarea wider than other inputs */\n+textarea {\n+ width: 80%\n+}\n+\n+/* Makes input fields wider on smaller screens */\n+@media only screen and (max-width: 720px) {\n+ textarea,\n+ select,\n+ input {\n+ width: 100%;\n+ }\n+}\n+\n+/* Ensures the checkbox and radio inputs do not have a set width like other input fields */\n+input[type=\"checkbox\"], input[type=\"radio\"]{\n+ width: auto;\n+}\n+\n+/* do not show border around file selector button */\n+input[type=\"file\"] {\n+ border: 0;\n+}\n+\n+/* Without this any HTML using <fieldset> shows ugly borders and has additional padding/margin. (Issue #3) */\n+fieldset {\n+ border: 0;\n+ padding: 0;\n+ margin: 0;\n+}\n+\n+/* Misc body elements */\n+\n+hr {\n+ color: var(--border);\n+ border-top: 1px;\n+ margin: 1rem auto;\n+}\n+\n+mark {\n+ padding: 2px 5px;\n+ border-radius: 4px;\n+ background: var(--marked);\n+}\n+\n+main img, main video {\n+ max-width: 100%;\n+ border-radius: 5px;\n+}\n+\n+figure {\n+ margin: 0;\n+}\n+\n+figcaption {\n+ font-size: .9rem;\n+ color: var(--text-light);\n+ text-align: center;\n+ margin-bottom: 1rem;\n+}\n+\n+blockquote {\n+ margin: 2rem 0 2rem 2rem;\n+ padding: .4rem .8rem;\n+ border-left: .35rem solid var(--accent);\n+ opacity: .8;\n+ font-style: italic;\n+}\n+\n+cite {\n+ font-size: 0.9rem;\n+ color: var(--text-light);\n+ font-style: normal;\n+}\n+\n+/* Use mono font for code like elements */\n+code,\n+pre,\n+kbd,\n+samp {\n+ font-size: 1rem;\n+ font-family: var(--mono-font);\n+ color: var(--code);\n+}\n+\n+code {\n+ font-size: 1.075rem;\n+}\n+\n+kbd {\n+ color: var(--preformatted);\n+ border: 1px solid var(--preformatted);\n+ border-bottom: 3px solid var(--preformatted);\n+ border-radius: 5px;\n+ padding: .1rem;\n+}\n+\n+pre {\n+ padding: 1rem 1.4rem;\n+ max-width: 100%;\n+ overflow: auto;\n+ color: var(--preformatted);\n+ background: var(--accent-bg);\n+ border: 1px solid var(--border);\n+ border-radius: 5px;\n+}\n+\n+/* Fix embedded code within pre */\n+pre code {\n+ color: var(--preformatted);\n+ background: none;\n+ margin: 0;\n+ padding: 0;\n+}\n+\n+\n+/* CSS Rules below are added for Bolt's Skeleton theme */\n+\n+.callout {\n+ border: 2px dashed rgba(0, 0, 0, 0.2);\n+ background-color: rgba(0, 0, 0, 0.05);\n+ padding: 0.5rem 1rem;\n+ margin: 1rem 0;\n+}\n+\n+\n+.meta {\n+ color: #888;\n+ font-size: 0.9em;\n+}\n+\n+/* Default pagerfanta styles, for pagination */\n+.pagination {\n+ text-align: center;\n+}\n+\n+.pagination li {\n+ display: inline-block;\n+ background: var(--accent-bg);\n+ border: 1px solid var(--accent-light);\n+ color: var(--accent);\n+ padding: 0;\n+ border-radius: 4px;\n+ font-size: 1rem;\n+}\n+\n+.pagination li.active {\n+ background: var(--accent-light);\n+}\n+\n+.pagination a {\n+ text-decoration: none;\n+ display: inline-block;\n+ padding: .25em .6em;\n+}\n+\n+.pagination a:hover {\n+ background: var(--accent-light);\n+ color: var(--accent);\n+}\n+\n+.pagination .dots {\n+ border-width: 0;\n+}\n+\n+.pagination .current {\n+ background: #c0dbe0;\n+ font-weight: bold;\n+}\n+\n+.pagination .disabled {\n+ border-color: #c0dbe0;\n+ color: #abcfd6;\n+}\n+\n+/* Some tweaks to keep Symfony dumps in check */\n+.sf-dump {\n+ font-size: 1rem !important;\n+ line-height: 1.4rem !important;\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/index.twig",
"new_path": "public/theme/skeleton/index.twig",
"diff": "{% if record|default %}\n- <h1><a href=\"{{ record|link }}\">{{ record|title }}</a></h1>\n+ <h1>{{ record|title }}</h1>\n{# Remove this block if you don't need it anymore. #}\n{{ include('partials/_fresh_install.twig') }}\n- {{ record|excerpt }}\n+ {# Output the `introduction` field. If it doesn't exist, 'default' to\n+ the full excerpt of the current Record #}\n+ {{ record.introduction|default(record|excerpt) }}\n{% include 'partials/_image.twig' with ({'image': record|image}) %}\n{% endif %}\n{% endblock main %}\n+\n+{% block aside %}\n+\n+ {{ include('partials/_aside.twig') }}\n+\n+{% endblock aside %}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_aside.twig",
"new_path": "public/theme/skeleton/partials/_aside.twig",
"diff": "<!-- Sidebar -->\n<aside>\n- <hr>\n-\n+ {# Show if there are widgets in the 'aside_top' widgets slot. #}\n{{ widgets('aside_top') }}\n- {# This part is only shown if there are no widgets in the 'aside_top' widgets slot. #}\n- <div>\n+ <hr>\n{# The next section attempts to fill the panel in the sidebar with the contents of the\n'about'-block, if it exists. First, attempt to fetch the block by its slug #}\n{% setcontent block = \"block/about\" %}\n- {# check if we have a title. If so, we know we have content to display. Otherwise, we will\n+ {# check if we have a block. If so, we know we have content to display. Otherwise, we will\noutput a default text, telling the user to create the 'blocks' in the backend. #}\n{% if block %}\n- <h5>{{ block.title }}</h5>\n+ <h5>{{ block|title }}</h5>\n<p>{{ block.content|default(block|excerpt) }}</p>\n{% set edit_link = block|edit_link %}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_footer.twig",
"new_path": "public/theme/skeleton/partials/_footer.twig",
"diff": "<!-- Footer -->\n<footer>\n- <hr>\n<h4>{{ __('Menu') }}</h4>\n{{ menu(template = 'partials/_sub_menu.twig') }}\n<button type=\"submit\">{{ __('action.search') }}</button>\n</form>\n- <hr>\n-\n- <h4>{{ __('general.phrase.select_language') }}</h4>\n-\n- {% include 'helpers/_languageselect.html.twig' with {'type': 'select'} %}\n-\n- <hr>\n-\n<p>\n{{ __('general.phrase.built-with-bolt') }}\n</p>\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_header.twig",
"new_path": "public/theme/skeleton/partials/_header.twig",
"diff": "<header>\n{# the values in the 'config' object are taken directly from the file app/config/config.yml #}\n<h2><a href=\"{{ path('homepage') }}\">{{ config.get('general/sitename') }}</a></h2>\n- {% if config.has('general/payoff') %}\n+ {% if config.has('general/payoff') and record is defined and record|feature == 'homepage' %}\n<p>{{ config.get('general/payoff') }}</p>\n{% endif %}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_image.twig",
"new_path": "public/theme/skeleton/partials/_image.twig",
"diff": "{% if image %}\n- <div class=\"imageholder\">\n+ <figure>\n<a href=\"{{ record|image }}\">\n<img src=\"{{ thumbnail(record, 1368, 1026) }}\" alt=\"{{ (record|image).alt|default(record|title) }}\">\n</a>\n{% if image.alt %}\n- <small>{{ image.alt }}</small>\n+ <figcaption>{{ image.alt }}</figcaption>\n{% endif %}\n- </div>\n+ </figure>\n{% endif %}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_master.twig",
"new_path": "public/theme/skeleton/partials/_master.twig",
"diff": "{{- ' | ' ~ config.get('general/payoff') -}}\n{%- endif -%}\n</title>\n- <link rel=\"stylesheet\" href=\"{{ asset('css/new.css') }}\">\n+ <link rel=\"stylesheet\" href=\"{{ asset('css/simple.css') }}\">\n</head>\n<body>\n+ {{ include('partials/_header.twig') }}\n+\n+ <main>\n{% block body %}\n- {{ include('partials/_header.twig') }}\n{{ widgets('main_top') }}\n{{ widgets('main_bottom') }}\n- {{ include('partials/_aside.twig') }}\n-\n{% endblock body %}\n+ </main>\n+\n+ {% block aside %}\n+ {% endblock aside %}\n{{ include('partials/_footer.twig') }}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_recordfooter.twig",
"new_path": "public/theme/skeleton/partials/_recordfooter.twig",
"diff": "{% endif %}\n{% set related_content_types = record|related_by_type %}\n+\n{% if related_content_types is not empty %}\n- <p class=\"meta\">{{ __('general.phrase.related-content') }}\n- <ul>\n+ <h3>{{ __('general.phrase.related-content') }}</h3>\n{% for content_type, related_records in related_content_types %}\n- <li>\n<h4>Related {{ config.get('contenttypes/' ~ content_type ~ '/name') }}</h4>\n<ul>\n{% for related_record in related_records %}\n<li><a href=\"{{ related_record|link }}\">{{ related_record|title }}</a></li>\n{% endfor %}\n</ul>\n- </li>\n{% endfor %}\n- </ul>\n- </p>\n{% endif %}\n+\n{% endif %}\n"
},
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/partials/_sub_menu_header.twig",
"new_path": "public/theme/skeleton/partials/_sub_menu_header.twig",
"diff": "{% if item.label is defined %}\n{{ display_menu_item(item, loop, withsubmenus) }}\n{% endif %}\n- |\n{% endfor %}\n{% include 'helpers/_languageselect.html.twig' with {'type': 'select'} %}\n</nav>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
New Skeleton theming
|
95,115 |
24.01.2021 22:15:40
| -3,600 |
b1e7726afae2642d443e2bde1dc522adc37b1dc8
|
remove ROLE_ADMIN check, no replacement needed as there is already a check in the locales() method on 'view' permission. (reference: https://github.com/bolt/core/issues/2342)
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/ContentLocalizationController.php",
"new_path": "src/Controller/Backend/ContentLocalizationController.php",
"diff": "@@ -14,8 +14,6 @@ use Symfony\\Component\\Routing\\Annotation\\Route;\n/**\n* Permissions for this controller follow ContentEditController - you can see the localization status if you have\n* 'view' permission on this item.\n- *\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n*/\nclass ContentLocalizationController extends TwigAwareController implements BackendZoneInterface\n{\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
remove ROLE_ADMIN check, no replacement needed as there is already a check in the locales() method on 'view' permission. (reference: https://github.com/bolt/core/issues/2342)
|
95,115 |
28.01.2021 22:52:14
| -3,600 |
9a488d41d483fafef0a351b7e52f9800691b6d95
|
Update ROLE_ADMIN check to specific media_edit permission.
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -42,6 +42,8 @@ global:\nkitchensink: [ ROLE_ADMIN ]\nupload: [ ROLE_EDITOR ] # TODO PERMISSIONS upload media/files ? Or should this be handled by managefiles:files\nextensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\n+ media_edit: [ ROLE_ADMIN ] # edit metadata for images etc.\n+\n# For content type related actions, permissions can be set individually for\n# each content type. For this, we define three groups of permission sets.\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/MediaEditController.php",
"new_path": "src/Controller/Backend/MediaEditController.php",
"diff": "@@ -20,7 +20,7 @@ use Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface;\nuse Webmozart\\PathUtil\\Path;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('media_edit')\")\n*/\nclass MediaEditController extends TwigAwareController implements BackendZoneInterface\n{\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update ROLE_ADMIN check to specific media_edit permission.
|
95,115 |
28.01.2021 23:01:39
| -3,600 |
eb781b5aaddb8ef07c5fd7c2a9d7d630bd418b5f
|
Update ROLE_ADMIN check to specific fetch_embed_data permission.
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -43,6 +43,7 @@ global:\nupload: [ ROLE_EDITOR ] # TODO PERMISSIONS upload media/files ? Or should this be handled by managefiles:files\nextensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\nmedia_edit: [ ROLE_ADMIN ] # edit metadata for images etc.\n+ fetch_embed_data: [ ROLE_ADMIN ] # get embed (meta)data for urls via the back-end (needed to embed youtube etc.)\n# For content type related actions, permissions can be set individually for\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/Async/EmbedController.php",
"new_path": "src/Controller/Backend/Async/EmbedController.php",
"diff": "@@ -17,7 +17,7 @@ use Symfony\\Component\\Security\\Core\\Exception\\InvalidCsrfTokenException;\nuse Symfony\\Component\\Security\\Csrf\\CsrfTokenManagerInterface;\n/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n+ * @Security(\"is_granted('fetch_embed_data')\")\n*/\nclass EmbedController implements AsyncZoneInterface\n{\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update ROLE_ADMIN check to specific fetch_embed_data permission.
|
95,115 |
28.01.2021 23:52:44
| -3,600 |
4b097f3b62593fac5bd091b5536da267b3098a6c
|
Update ROLE_ADMIN check to specific permissions for list_files:config, list_files:files and list_files:themes. Probably only the list_files:files permission should be given to normal editors in the future.
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -44,6 +44,9 @@ global:\nextensionmenus: [ IS_AUTHENTICATED_FULLY ] # allows you to see menu items added by extensions\nmedia_edit: [ ROLE_ADMIN ] # edit metadata for images etc.\nfetch_embed_data: [ ROLE_ADMIN ] # get embed (meta)data for urls via the back-end (needed to embed youtube etc.)\n+ list_files:config: [ ROLE_ADMIN ] # should probably not be used?\n+ list_files:files: [ ROLE_ADMIN ] # get list of files (images?) available for use as site-content\n+ list_files:themes: [ ROLE_ADMIN ] # should probably not be used?\n# For content type related actions, permissions can be set individually for\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/Async/FileListingController.php",
"new_path": "src/Controller/Backend/Async/FileListingController.php",
"diff": "@@ -5,17 +5,15 @@ declare(strict_types=1);\nnamespace Bolt\\Controller\\Backend\\Async;\nuse Bolt\\Configuration\\Config;\n-use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\nuse Symfony\\Component\\Finder\\Finder;\nuse Symfony\\Component\\HttpFoundation\\JsonResponse;\nuse Symfony\\Component\\HttpFoundation\\Request;\nuse Symfony\\Component\\HttpFoundation\\RequestStack;\n+use Symfony\\Component\\HttpFoundation\\Response;\nuse Symfony\\Component\\Routing\\Annotation\\Route;\n+use Symfony\\Component\\Security\\Core\\Security;\nuse Tightenco\\Collect\\Support\\Collection;\n-/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n- */\nclass FileListingController implements AsyncZoneInterface\n{\n/** @var Config */\n@@ -24,10 +22,13 @@ class FileListingController implements AsyncZoneInterface\n/** @var Request */\nprivate $request;\n- public function __construct(Config $config, RequestStack $requestStack)\n+ private $security;\n+\n+ public function __construct(Config $config, RequestStack $requestStack, Security $security)\n{\n$this->config = $config;\n$this->request = $requestStack->getCurrentRequest();\n+ $this->security = $security;\n}\n/**\n@@ -38,6 +39,10 @@ class FileListingController implements AsyncZoneInterface\n$locationName = $this->request->query->get('location', 'files');\n$type = $this->request->query->get('type', '');\n+ if (!$this->security->isGranted('list_files:' . $locationName)) {\n+ return new JsonResponse(\"permission denied\", Response::HTTP_UNAUTHORIZED);\n+ }\n+\n$path = $this->config->getPath($locationName, true);\n$files = $this->getFilesIndex($path, $type);\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update ROLE_ADMIN check to specific permissions for list_files:config, list_files:files and list_files:themes. Probably only the list_files:files permission should be given to normal editors in the future.
|
95,115 |
29.01.2021 13:44:51
| -3,600 |
668b2754d7268005a6227a684f26c49a29c301e6
|
fix ROLE_ADMIN use by deleting unused controller
|
[
{
"change_type": "DELETE",
"old_path": "src/Controller/Backend/MediaController.php",
"new_path": null,
"diff": "-<?php\n-\n-declare(strict_types=1);\n-\n-namespace Bolt\\Controller\\Backend;\n-\n-use Bolt\\Configuration\\FileLocations;\n-use Bolt\\Controller\\TwigAwareController;\n-use Bolt\\Factory\\MediaFactory;\n-use Doctrine\\ORM\\EntityManagerInterface;\n-use Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\n-use Symfony\\Component\\Finder\\Finder;\n-use Symfony\\Component\\HttpFoundation\\Response;\n-use Symfony\\Component\\Routing\\Annotation\\Route;\n-use Webmozart\\PathUtil\\Path;\n-\n-/**\n- * @Security(\"is_granted('ROLE_ADMIN')\")\n- */\n-class MediaController extends TwigAwareController implements BackendZoneInterface\n-{\n- /** @var EntityManagerInterface */\n- private $em;\n-\n- /** @var FileLocations */\n- private $fileLocations;\n-\n- /** @var MediaFactory */\n- private $mediaFactory;\n-\n- public function __construct(EntityManagerInterface $em, FileLocations $fileLocations, MediaFactory $mediaFactory)\n- {\n- $this->em = $em;\n- $this->fileLocations = $fileLocations;\n- $this->mediaFactory = $mediaFactory;\n- }\n-\n- /**\n- * @Route(\"/media/crawl/{location}\", name=\"bolt_media_crawler\", methods={\"GET\"})\n- */\n- public function finder(string $locationName): Response\n- {\n- $basepath = $this->fileLocations->get($locationName)->getBasepath();\n-\n- $finder = $this->findFiles($basepath);\n-\n- foreach ($finder as $file) {\n- $media = $this->mediaFactory->createOrUpdateMedia($file, $locationName);\n-\n- $this->em->persist($media);\n- }\n-\n- $this->em->flush();\n-\n- return $this->render('@bolt/finder/finder.twig', [\n- 'path' => 'path',\n- 'name' => $this->fileLocations->get($locationName)->getName(),\n- 'location' => $locationName,\n- 'finder' => $finder,\n- 'parent' => 'parent',\n- ]);\n- }\n-\n- private function findFiles(string $base): Finder\n- {\n- $fullpath = Path::canonicalize($base);\n-\n- $glob = sprintf('*.{%s}', $this->config->getMediaTypes()->implode(','));\n-\n- $finder = new Finder();\n- $finder->in($fullpath)->depth('< 2')->sortByName()->name($glob)->files();\n-\n- return $finder;\n- }\n-}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
fix ROLE_ADMIN use by deleting unused controller
|
95,147 |
03.02.2021 14:19:48
| -3,600 |
da1fc2a0c291446358257ddbdbbd6c9bc4ea6c7a
|
Show an envelope icon for email fields to distinguish from text
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/editor/Components/Email.vue",
"new_path": "assets/js/app/editor/Components/Email.vue",
"diff": "<template>\n<div>\n+ <div class=\"input-group mb-2\">\n+ <div class=\"input-group-prepend\">\n+ <div class=\"input-group-text\"><i class=\"far fa-envelope mr-0\"></i></div>\n+ </div>\n<input\n:id=\"id\"\nclass=\"form-control\"\n:placeholder=\"placeholder\"\n/>\n</div>\n+ </div>\n</template>\n<script>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Show an envelope icon for email fields to distinguish from text
|
95,144 |
06.02.2021 12:41:29
| -3,600 |
a10b0624d08b5866715dc5d7668b9a87d10e8c51
|
Don't allow Path Traversal
|
[
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/FileEditController.php",
"new_path": "src/Controller/Backend/FileEditController.php",
"diff": "@@ -7,6 +7,7 @@ namespace Bolt\\Controller\\Backend;\nuse Bolt\\Controller\\CsrfTrait;\nuse Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Repository\\MediaRepository;\n+use Bolt\\Utils\\PathCanonicalize;\nuse Doctrine\\ORM\\EntityManagerInterface;\nuse Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\nuse Symfony\\Component\\Filesystem\\Filesystem;\n@@ -53,12 +54,10 @@ class FileEditController extends TwigAwareController implements BackendZoneInter\npublic function edit(string $location): Response\n{\n$file = $this->getFromRequest('file');\n- if (mb_strpos($file, '/') !== 0) {\n- $file = '/' . $file;\n- }\n-\n$basepath = $this->config->getPath($location);\n- $filename = Path::canonicalize($basepath . '/' . $file);\n+\n+ $filename = PathCanonicalize::canonicalize($basepath, $file);\n+\n$contents = file_get_contents($filename);\n$context = [\n@@ -138,7 +137,7 @@ class FileEditController extends TwigAwareController implements BackendZoneInter\n$this->em->flush();\n}\n- $filePath = Path::canonicalize($locationName . '/' . $path);\n+ $filePath = PathCanonicalize::canonicalize($locationName, $path);\ntry {\n$this->filesystem->remove($filePath);\n@@ -175,7 +174,7 @@ class FileEditController extends TwigAwareController implements BackendZoneInter\n$locationName = $this->getFromRequest('location', '');\n$path = $this->getFromRequest('path', '');\n- $originalFilepath = Path::canonicalize($locationName . '/' . $path);\n+ $originalFilepath = PathCanonicalize::canonicalize($locationName, $path);\n$copyFilePath = $this->getCopyFilepath($originalFilepath);\n@@ -205,8 +204,8 @@ class FileEditController extends TwigAwareController implements BackendZoneInter\n$i = 1;\nwhile ($this->filesystem->exists($copyPath)) {\n$pathinfo = pathinfo($path);\n- $basename = basename($pathinfo['basename'], '.' . $pathinfo['extension']) . ' (' . $i . ')';\n- $copyPath = Path::canonicalize($pathinfo['dirname'] . '/' . $basename . '.' . $pathinfo['extension']);\n+ $basename = basename($pathinfo['basename'], '.' . $pathinfo['extension']) . ' (' . $i . ')' . '.' . $pathinfo['extension'];\n+ $copyPath = PathCanonicalize::canonicalize($pathinfo['dirname'], $basename);\n$i++;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Controller/Backend/FilemanagerController.php",
"new_path": "src/Controller/Backend/FilemanagerController.php",
"diff": "@@ -9,6 +9,7 @@ use Bolt\\Configuration\\FileLocations;\nuse Bolt\\Controller\\TwigAwareController;\nuse Bolt\\Repository\\MediaRepository;\nuse Bolt\\Utils\\Excerpt;\n+use Bolt\\Utils\\PathCanonicalize;\nuse Pagerfanta\\Adapter\\ArrayAdapter;\nuse Pagerfanta\\Pagerfanta;\nuse Sensio\\Bundle\\FrameworkExtraBundle\\Configuration\\Security;\n@@ -50,6 +51,9 @@ class FilemanagerController extends TwigAwareController implements BackendZoneIn\nif (str::endsWith($path, '/') === false) {\n$path .= '/';\n}\n+ if (str::startsWith($path, '/') === false) {\n+ $path = '/' . $path;\n+ }\nif ($this->getFromRequest('view')) {\n$view = $this->getFromRequest('view') === 'cards' ? 'cards' : 'list';\n@@ -82,7 +86,7 @@ class FilemanagerController extends TwigAwareController implements BackendZoneIn\nprivate function findFiles(string $base, string $path): Finder\n{\n- $fullpath = Path::canonicalize($base . '/' . $path);\n+ $fullpath = PathCanonicalize::canonicalize($base, $path);\n$finder = new Finder();\n$finder->in($fullpath)->depth('== 0')->files()->sortByName();\n@@ -92,7 +96,7 @@ class FilemanagerController extends TwigAwareController implements BackendZoneIn\nprivate function findFolders(string $base, string $path): Finder\n{\n- $fullpath = Path::canonicalize($base . '/' . $path);\n+ $fullpath = PathCanonicalize::canonicalize($base, $path);\n$finder = new Finder();\n$finder->in($fullpath)->depth('== 0')->directories()->sortByName();\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Utils/PathCanonicalize.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Utils;\n+\n+use Webmozart\\PathUtil\\Path;\n+\n+class PathCanonicalize\n+{\n+ public static function canonicalize(string $basePath, string $filename): string\n+ {\n+ $path = Path::canonicalize($basePath . DIRECTORY_SEPARATOR . $filename);\n+\n+ // If the path is outside the `$basePath`, we do not allow it.\n+ if (mb_strpos(Path::makeRelative($path, $basePath), '..') === 0) {\n+ throw new \\Exception('You are not allowed to do that');\n+ }\n+\n+ return $path;\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Don't allow Path Traversal
|
95,147 |
08.02.2021 12:07:53
| -3,600 |
36ed264f42a634ef63a5853536fd4f3487e4ac0d
|
Make multiselect fields iterable in Twig
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/CollectionField.php",
"new_path": "src/Entity/Field/CollectionField.php",
"diff": "@@ -9,8 +9,8 @@ use Bolt\\Entity\\Field;\nuse Bolt\\Entity\\FieldInterface;\nuse Bolt\\Entity\\FieldParentInterface;\nuse Bolt\\Entity\\FieldParentTrait;\n+use Bolt\\Entity\\IterableFieldTrait;\nuse Bolt\\Entity\\ListFieldInterface;\n-use Bolt\\Entity\\ListFieldTrait;\nuse Bolt\\Repository\\FieldRepository;\nuse Doctrine\\ORM\\Mapping as ORM;\n@@ -20,7 +20,7 @@ use Doctrine\\ORM\\Mapping as ORM;\nclass CollectionField extends Field implements FieldInterface, FieldParentInterface, ListFieldInterface, \\Iterator, RawPersistable\n{\nuse FieldParentTrait;\n- use ListFieldTrait;\n+ use IterableFieldTrait;\npublic const TYPE = 'collection';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/FilelistField.php",
"new_path": "src/Entity/Field/FilelistField.php",
"diff": "@@ -7,8 +7,8 @@ namespace Bolt\\Entity\\Field;\nuse Bolt\\Configuration\\Content\\ContentType;\nuse Bolt\\Entity\\Field;\nuse Bolt\\Entity\\FieldInterface;\n+use Bolt\\Entity\\IterableFieldTrait;\nuse Bolt\\Entity\\ListFieldInterface;\n-use Bolt\\Entity\\ListFieldTrait;\nuse Doctrine\\ORM\\Mapping as ORM;\n/**\n@@ -16,7 +16,7 @@ use Doctrine\\ORM\\Mapping as ORM;\n*/\nclass FilelistField extends Field implements FieldInterface, ListFieldInterface, RawPersistable, \\Iterator\n{\n- use ListFieldTrait;\n+ use IterableFieldTrait;\npublic const TYPE = 'filelist';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/ImagelistField.php",
"new_path": "src/Entity/Field/ImagelistField.php",
"diff": "@@ -7,8 +7,8 @@ namespace Bolt\\Entity\\Field;\nuse Bolt\\Configuration\\Content\\ContentType;\nuse Bolt\\Entity\\Field;\nuse Bolt\\Entity\\FieldInterface;\n+use Bolt\\Entity\\IterableFieldTrait;\nuse Bolt\\Entity\\ListFieldInterface;\n-use Bolt\\Entity\\ListFieldTrait;\nuse Doctrine\\ORM\\Mapping as ORM;\n/**\n@@ -16,7 +16,7 @@ use Doctrine\\ORM\\Mapping as ORM;\n*/\nclass ImagelistField extends Field implements FieldInterface, ListFieldInterface, RawPersistable, \\Iterator\n{\n- use ListFieldTrait;\n+ use IterableFieldTrait;\npublic const TYPE = 'imagelist';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/SelectField.php",
"new_path": "src/Entity/Field/SelectField.php",
"diff": "@@ -6,14 +6,17 @@ namespace Bolt\\Entity\\Field;\nuse Bolt\\Entity\\Field;\nuse Bolt\\Entity\\FieldInterface;\n+use Bolt\\Entity\\IterableFieldTrait;\nuse Doctrine\\ORM\\Mapping as ORM;\nuse Tightenco\\Collect\\Support\\Collection;\n/**\n* @ORM\\Entity\n*/\n-class SelectField extends Field implements FieldInterface, RawPersistable\n+class SelectField extends Field implements FieldInterface, RawPersistable, \\Iterator\n{\n+ use IterableFieldTrait;\n+\npublic const TYPE = 'select';\npublic function setValue($value): Field\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/SetField.php",
"new_path": "src/Entity/Field/SetField.php",
"diff": "@@ -9,8 +9,8 @@ use Bolt\\Entity\\Field;\nuse Bolt\\Entity\\FieldInterface;\nuse Bolt\\Entity\\FieldParentInterface;\nuse Bolt\\Entity\\FieldParentTrait;\n+use Bolt\\Entity\\IterableFieldTrait;\nuse Bolt\\Entity\\ListFieldInterface;\n-use Bolt\\Entity\\ListFieldTrait;\nuse Bolt\\Repository\\FieldRepository;\nuse Doctrine\\ORM\\Mapping as ORM;\nuse Tightenco\\Collect\\Support\\Collection;\n@@ -21,7 +21,7 @@ use Tightenco\\Collect\\Support\\Collection;\nclass SetField extends Field implements FieldInterface, FieldParentInterface, ListFieldInterface, \\Iterator, RawPersistable\n{\nuse FieldParentTrait;\n- use ListFieldTrait;\n+ use IterableFieldTrait;\npublic const TYPE = 'set';\n"
},
{
"change_type": "RENAME",
"old_path": "src/Entity/ListFieldTrait.php",
"new_path": "src/Entity/IterableFieldTrait.php",
"diff": "@@ -4,7 +4,7 @@ declare(strict_types=1);\nnamespace Bolt\\Entity;\n-trait ListFieldTrait\n+trait IterableFieldTrait\n{\nprivate $iteratorCursor = 0;\n@@ -29,7 +29,10 @@ trait ListFieldTrait\nreturn $this->count();\n}\n- public function current(): Field\n+ /**\n+ * @return Field|string\n+ */\n+ public function current()\n{\nreturn $this->fields[$this->iteratorCursor];\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Make multiselect fields iterable in Twig
|
95,147 |
08.02.2021 15:58:24
| -3,600 |
8cf8174e8b7be3c405daae03296fbe4ab0fedf95
|
Content `toArray()` method returns fields according to definition
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Content.php",
"new_path": "src/Entity/Content.php",
"diff": "@@ -460,10 +460,14 @@ class Content\n*/\npublic function getFieldValues(): array\n{\n- $fieldValues = [];\n+ $fieldValues = $this->getFieldValuesFromDefinition();\n+\n+ if ($fieldValues === null) {\n+ // Get the fields according to the database.\nforeach ($this->getFields() as $field) {\n$fieldValues[$field->getName()] = $field->getApiValue();\n}\n+ }\n// Make sure we have a 'slug', even if none is defined in the contentype\nif (! array_key_exists('slug', $fieldValues)) {\n@@ -816,4 +820,26 @@ class Content\nreturn $this;\n}\n+\n+ private function getFieldValuesFromDefinition(): ?array\n+ {\n+ if (! $this->getDefinition() || ! $this->getDefinition()->get('fields', null)) {\n+ // Definition is missing.\n+ return null;\n+ }\n+\n+ $fieldValues = [];\n+\n+ foreach ($this->getDefinition()->get('fields') as $name => $definition) {\n+ if ($this->hasField($name)) {\n+ $field = $this->getField($name);\n+ } else {\n+ $field = FieldRepository::factory($definition, $name);\n+ }\n+\n+ $fieldValues[$name] = $field->getApiValue();\n+ }\n+\n+ return $fieldValues;\n+ }\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Content `toArray()` method returns fields according to definition
|
95,147 |
08.02.2021 15:02:57
| -3,600 |
c3e81790d76a68a0b8b6ce573cf98a115d1b94ab
|
Update bolt/common dependency
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"babdev/pagerfanta-bundle\": \"^2.5\",\n\"beberlei/doctrineextensions\": \"^1.2\",\n\"bobdenotter/yaml-migrations\": \"^1.0\",\n- \"bolt/common\": \"^3.0\",\n+ \"bolt/common\": \"^3.0.3\",\n\"cocur/slugify\": \"^4.0\",\n\"composer/composer\": \"^2.0\",\n\"composer/package-versions-deprecated\": \"^1.11\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update bolt/common dependency
|
95,147 |
09.02.2021 13:11:31
| -3,600 |
1c4f4ebe3617c8ef6e26f9ff839e40b622169912
|
Fix date field with `required: true`
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/app/editor/Components/Date.vue",
"new_path": "assets/js/app/editor/Components/Date.vue",
"diff": ":form=\"form\"\n:name=\"name\"\nplaceholder=\"Select date\"\n- :required=\"required\"\n:data-errormessage=\"errormessage\"\n>\n</flat-pickr>\n</template>\n<script>\n+import $ from 'jquery';\nimport value from '../mixins/value';\nimport flatPickr from 'vue-flatpickr-component';\n@@ -117,5 +117,31 @@ export default {\nthis.config.altFormat = `F j, Y - h:i K`;\n}\n},\n+\n+ updated() {\n+ this.fixRequired();\n+ },\n+\n+ methods: {\n+ fixRequired() {\n+ if (!this.required) {\n+ return;\n+ }\n+\n+ const input = $(this.$el).find('.editor--date.input');\n+\n+ if (this.val === '') {\n+ input.attr('required', true);\n+ } else {\n+ input.removeAttr('required');\n+ }\n+\n+ // This is needed to make sure validation\n+ // popup shows \"please fill in this field\"\n+ // rather than undefined.\n+ input[0].reportValidity();\n+ input[0].setCustomValidity('');\n+ },\n+ },\n};\n</script>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix date field with `required: true`
|
95,147 |
08.02.2021 17:06:06
| -3,600 |
c92896776b2fa6670b75f1ebadab15deedf5e930
|
`ROLE_ADMIN` can access site in maintenance mode
|
[
{
"change_type": "MODIFY",
"old_path": "config/bolt/permissions.yaml",
"new_path": "config/bolt/permissions.yaml",
"diff": "@@ -35,7 +35,7 @@ global:\nuser:status: [ ROLE_ADMIN ] # user enable/disable - only used for changing status outside of add/edit context\nuser:delete: [ ROLE_ADMIN ] # user delete\nuser:edit: [ ROLE_ADMIN ] # user edit all fields, includes user:status permissions\n-# maintenance-mode: [ everyone ] # view the frontend when in maintenance mode\n+ maintenance-mode: [ ROLE_ADMIN ] # view the frontend when in maintenance mode\nsystemlog: [ ROLE_ADMIN ]\napi_admin: [ ROLE_ADMIN ] # WARNING: this only shows/hides api in the bolt admin, it doesn't protect the /api route(s)\nbulk_operations: [ ROLE_ADMIN ]\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Event/Subscriber/MaintenanceModeSubscriber.php",
"new_path": "src/Event/Subscriber/MaintenanceModeSubscriber.php",
"diff": "@@ -10,15 +10,20 @@ use Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\nuse Symfony\\Component\\HttpKernel\\Event\\ControllerEvent;\nuse Symfony\\Component\\HttpKernel\\Exception\\HttpException;\nuse Symfony\\Component\\HttpKernel\\KernelEvents;\n+use Symfony\\Component\\Security\\Core\\Security;\nclass MaintenanceModeSubscriber implements EventSubscriberInterface\n{\n/** @var Config */\nprivate $config;\n- public function __construct(Config $config)\n+ /** @var Security */\n+ private $security;\n+\n+ public function __construct(Config $config, Security $security)\n{\n$this->config = $config;\n+ $this->security = $security;\n}\npublic function onKernelController(ControllerEvent $event): void\n@@ -31,7 +36,7 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface\n$controller = $controller[0];\n}\n- if ($controller instanceof FrontendZoneInterface && $this->config->get('general/maintenance_mode', 'false')) {\n+ if ($controller instanceof FrontendZoneInterface && $this->config->get('general/maintenance_mode', 'false') && ! $this->security->isGranted('maintenance-mode')) {\nthrow new HttpException(503, 'Service Unavailable (Maintenance Mode)');\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/Security/GlobalVoter.php",
"new_path": "src/Security/GlobalVoter.php",
"diff": "@@ -21,12 +21,9 @@ class GlobalVoter extends Voter\n{\n$this->security = $security;\n$this->globalPermissions = $config->get('permissions/global');\n+\nif ($this->globalPermissions instanceof Collection) {\n- // TODO should we also validate that the values are all simple arrays?\n- $globalPermissionNames = array_keys($this->globalPermissions->all());\n- foreach ($globalPermissionNames as $attribute) {\n- $this->supportedAttributes[] = $attribute;\n- }\n+ $this->supportedAttributes = $this->globalPermissions->keys()->toArray();\n} else {\nthrow new \\DomainException('No global permissions config found');\n}\n@@ -58,6 +55,7 @@ class GlobalVoter extends Voter\n}\n$rolesWithPermission = $this->globalPermissions[$attribute];\n+\nforeach ($rolesWithPermission as $role) {\nif ($this->security->isGranted($role)) {\nreturn true;\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
`ROLE_ADMIN` can access site in maintenance mode
|
95,147 |
09.02.2021 10:13:35
| -3,600 |
01ff6db9e55cca090b2f35b72135186a4a444707
|
Add maintenance warning on frontend
|
[
{
"change_type": "MODIFY",
"old_path": "src/Event/Subscriber/WidgetSubscriber.php",
"new_path": "src/Event/Subscriber/WidgetSubscriber.php",
"diff": "@@ -10,6 +10,7 @@ use Bolt\\Widget\\BoltHeaderWidget;\nuse Bolt\\Widget\\CanonicalLinkWidget;\nuse Bolt\\Widget\\Injector\\RequestZone;\nuse Bolt\\Widget\\Injector\\Target;\n+use Bolt\\Widget\\MaintenanceModeWidget;\nuse Bolt\\Widget\\SnippetWidget;\nuse Bolt\\Widgets;\nuse Symfony\\Component\\EventDispatcher\\EventSubscriberInterface;\n@@ -57,6 +58,10 @@ class WidgetSubscriber implements EventSubscriberInterface\n$this->widgets->registerWidget($metaTagSnippet);\n}\n+\n+ if ($this->config->get('general/maintenance_mode', 'false')) {\n+ $this->widgets->registerWidget(new MaintenanceModeWidget());\n+ }\n}\n/**\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Widget/MaintenanceModeWidget.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Widget;\n+\n+use Bolt\\Widget\\Injector\\RequestZone;\n+use Bolt\\Widget\\Injector\\Target;\n+\n+class MaintenanceModeWidget extends BaseWidget implements TwigAwareInterface\n+{\n+ protected $name = 'Maintenance Mode';\n+ protected $target = Target::START_OF_BODY;\n+ protected $zone = RequestZone::FRONTEND;\n+ protected $priority = 300;\n+\n+ protected function run(array $params = []): ?string\n+ {\n+ return $this->getTwig()->render('@bolt/widget/maintenance_mode.twig');\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "translations/messages.en.xlf",
"new_path": "translations/messages.en.xlf",
"diff": "<target>Please enter your password</target>\n</segment>\n</unit>\n- <unit id=\"o2f3RiO\" name=\"form.empty_email\">\n+ <unit id=\"f8zXapF\" name=\"form.empty_email\">\n<segment>\n<source>form.empty_email</source>\n<target>Please enter your email</target>\n<target>Reset Password</target>\n</segment>\n</unit>\n- <unit id=\"3prMgfK\" name=\"reset_password.email_title\">\n+ <unit id=\"dp42qbF\" name=\"reset_password.email_title\">\n<segment>\n<source>reset_password.email_title</source>\n<target>Hi!</target>\n</segment>\n</unit>\n- <unit id=\"oaRkfvE\" name=\"reset_password.email_description\">\n+ <unit id=\"xS2vvXw\" name=\"reset_password.email_description\">\n<segment>\n<source>reset_password.email_description</source>\n<target>To reset your password, please visit the following link</target>\n</segment>\n</unit>\n- <unit id=\"Afb4dal\" name=\"reset_password.email_expire\">\n+ <unit id=\"apkSD11\" name=\"reset_password.email_expire\">\n<segment>\n<source>reset_password.email_expire</source>\n<target>This link will expire in %hours% hour(s).</target>\n</segment>\n</unit>\n- <unit id=\"9ga3FlV\" name=\"reset_password.email_thanks\">\n+ <unit id=\"_gg3hPE\" name=\"reset_password.email_thanks\">\n<segment>\n<source>reset_password.email_thanks</source>\n<target>Cheers!</target>\n</segment>\n</unit>\n- <unit id=\"7d24Grt\" name=\"reset_password.enter_pwd\">\n+ <unit id=\"harDiJR\" name=\"reset_password.enter_pwd\">\n<segment>\n<source>reset_password.enter_pwd</source>\n<target>Please enter a password</target>\n</segment>\n</unit>\n- <unit id=\"a2f1pra\" name=\"label.repeat_password\">\n+ <unit id=\"rU9cSfq\" name=\"label.repeat_password\">\n<segment>\n<source>label.repeat_password</source>\n<target>Repeat Password</target>\n</segment>\n</unit>\n- <unit id=\"2f19Gat\" name=\"reset_password.not_matching_pwds\">\n+ <unit id=\"Tg5zdeo\" name=\"reset_password.not_matching_pwds\">\n<segment>\n<source>reset_password.not_matching_pwds</source>\n<target>The password fields must match.</target>\n</segment>\n</unit>\n- <unit id=\"2ahb7da\" name=\"reset_password.minimum_length\">\n+ <unit id=\"1JZeWxG\" name=\"reset_password.minimum_length\">\n<segment>\n<source>reset_password.minimum_length</source>\n<target>Your password should be at least %s characters</target>\n</segment>\n</unit>\n- <unit id=\"a3frsl4\" name=\"reset_password.no_token\">\n+ <unit id=\"GUQYLn2\" name=\"reset_password.no_token\">\n<segment>\n<source>reset_password.no_token</source>\n<target>No reset password token found in the URL or in the session.</target>\n</segment>\n</unit>\n- <unit id=\"hsg341k\" name=\"reset_password.reset_successful\">\n+ <unit id=\"SjuOnue\" name=\"reset_password.reset_successful\">\n<segment>\n<source>reset_password.reset_successful</source>\n<target>Your password has been reset successfully.</target>\n</segment>\n</unit>\n- <unit id=\"7f2x41k\" name=\"reset_password.problem_with_request\">\n+ <unit id=\"5Xr92sQ\" name=\"reset_password.problem_with_request\">\n<segment>\n<source>reset_password.problem_with_request</source>\n<target>There was a problem handling your password reset request - %s</target>\n<target>impersonate</target>\n</segment>\n</unit>\n+ <unit id=\"qlucRr7\" name=\"maintenance.activated_warning\">\n+ <segment>\n+ <source>maintenance.activated_warning</source>\n+ <target>Maintenance mode is activated</target>\n+ </segment>\n+ </unit>\n</file>\n</xliff>\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add maintenance warning on frontend
|
95,147 |
09.02.2021 14:46:04
| -3,600 |
51773d0af8610398ffc7efd36440c72789b121ec
|
Keep cache timestamps for all `.env` files
|
[
{
"change_type": "MODIFY",
"old_path": "src/Configuration/Config.php",
"new_path": "src/Configuration/Config.php",
"diff": "@@ -147,12 +147,30 @@ class Config\n}\n}\n- $envFilename = $this->projectDir . '/.env';\n- if (file_exists($envFilename)) {\n- $timestamps[$envFilename] = filemtime($envFilename);\n+ return array_merge($timestamps, $this->getEnvFilesTimestamps());\n}\n- return $timestamps;\n+ private function getEnvFilesTimestamps(): array\n+ {\n+ // For filenames see:\n+ // https://symfony.com/doc/current/configuration.html#configuring-environment-variables-in-env-files\n+ $envFilenames = [\n+ '.env',\n+ '.env.local',\n+ '.env.' . $this->kernel->getEnvironment(),\n+ '.env.' . $this->kernel->getEnvironment() . '.local',\n+ ];\n+\n+ $envTimestamps = [];\n+\n+ foreach ($envFilenames as $envFilename) {\n+ $envFilenamePath = $this->projectDir . '/' . $envFilename;\n+ if (file_exists($envFilenamePath)) {\n+ $envTimestamps[$envFilenamePath] = filemtime($envFilenamePath);\n+ }\n+ }\n+\n+ return $envTimestamps;\n}\n/**\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Keep cache timestamps for all `.env` files
|
95,147 |
10.02.2021 16:27:56
| -3,600 |
46b97181197e18fa3888c5641b58334e9f63ea5f
|
Selects with `multiple: true` always have an array value
|
[
{
"change_type": "MODIFY",
"old_path": "src/Entity/Field/SelectField.php",
"new_path": "src/Entity/Field/SelectField.php",
"diff": "@@ -51,6 +51,18 @@ class SelectField extends Field implements FieldInterface, RawPersistable, \\Iter\nreturn array_filter((array) $value);\n}\n+ public function getParsedValue()\n+ {\n+ $parsedValue = parent::getParsedValue();\n+\n+ if ($this->getDefinition()->get('multiple') && ! is_array($parsedValue)) {\n+ // Make sure that multiselects always return an array, even if there's only one item.\n+ $parsedValue = [$parsedValue];\n+ }\n+\n+ return $parsedValue;\n+ }\n+\npublic function getOptions()\n{\nreturn $this->getDefinition()->get('values');\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Selects with `multiple: true` always have an array value
|
95,147 |
10.02.2021 12:06:31
| -3,600 |
456ee44a54f999571ed4db20685ea9699e6e7939
|
Make sure the magic `get` uses the configured `date_format`
|
[
{
"change_type": "MODIFY",
"old_path": "src/Utils/ContentHelper.php",
"new_path": "src/Utils/ContentHelper.php",
"diff": "@@ -130,9 +130,11 @@ class ContentHelper\n$locale = $record->getContentTypeDefaultLocale();\n}\n+ $dateFormat = $this->config->get('general/date_format');\n+\nreturn preg_replace_callback(\n'/{([\\w]+)}/i',\n- function ($match) use ($record, $locale) {\n+ function ($match) use ($record, $locale, $dateFormat) {\nif ($match[1] === 'id') {\nreturn $record->getId();\n}\n@@ -146,19 +148,19 @@ class ContentHelper\n}\nif ($match[1] === 'publishedAt') {\n- return $this->localeExtension->localdate($record->getPublishedAt(), null, $locale);\n+ return $this->localeExtension->localdate($record->getPublishedAt(), $dateFormat, $locale);\n}\nif ($match[1] === 'modifiedAt') {\n- return $this->localeExtension->localdate($record->getModifiedAt(), null, $locale);\n+ return $this->localeExtension->localdate($record->getModifiedAt(), $dateFormat, $locale);\n}\nif ($match[1] === 'createdAt') {\n- return $this->localeExtension->localdate($record->getCreatedAt(), null, $locale);\n+ return $this->localeExtension->localdate($record->getCreatedAt(), $dateFormat, $locale);\n}\nif ($match[1] === 'depublishedAt') {\n- return $this->localeExtension->localdate($record->getDepublishedAt(), null, $locale);\n+ return $this->localeExtension->localdate($record->getDepublishedAt(), $dateFormat, $locale);\n}\nif ($match[1] === 'contenttype') {\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Make sure the magic `get` uses the configured `date_format`
|
95,147 |
10.02.2021 11:49:30
| -3,600 |
16939b56743d45a83f1fd0eb23346cf4f6f8be79
|
Fix `|order` filter by date
|
[
{
"change_type": "MODIFY",
"old_path": "src/Twig/ArrayExtension.php",
"new_path": "src/Twig/ArrayExtension.php",
"diff": "@@ -6,6 +6,7 @@ namespace Bolt\\Twig;\nuse Bolt\\Entity\\Content;\nuse Bolt\\Utils\\ContentHelper;\n+use Carbon\\Carbon;\nuse Pagerfanta\\Pagerfanta;\nuse Twig\\Environment;\nuse Twig\\Extension\\AbstractExtension;\n@@ -136,8 +137,14 @@ final class ArrayExtension extends AbstractExtension\n*/\nprivate function orderHelper(Content $a, Content $b, string $orderOn, bool $orderAscending, string $locale): int\n{\n- $aVal = $this->contentHelper->get($a, sprintf('{%s}', $orderOn));\n- $bVal = $this->contentHelper->get($b, sprintf('{%s}', $orderOn));\n+ $aVal = $this->contentHelper->get($a, sprintf('{%s}', $orderOn), $locale);\n+ $bVal = $this->contentHelper->get($b, sprintf('{%s}', $orderOn), $locale);\n+\n+ // If the values look like dates, convert them to proper date objects.\n+ if (strtotime($aVal) && strtotime($bVal)) {\n+ $aVal = Carbon::createFromTimestamp(strtotime($aVal));\n+ $bVal = Carbon::createFromTimestamp(strtotime($bVal));\n+ }\n// Check the primary sorting criterion.\nif ($orderAscending) {\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Fix `|order` filter by date
|
95,144 |
14.02.2021 11:50:30
| -3,600 |
722281de5f8a74ff4a4b1279741f02aba1b1d2d4
|
Keep `sensiolabs/security-checker` around for now
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"psr/simple-cache\": \"^1.0\",\n\"scienta/doctrine-json-functions\": \"^4.1\",\n\"sensio/framework-extra-bundle\": \"^5.6\",\n+ \"sensiolabs/security-checker\": \"^6.0\",\n\"siriusphp/upload\": \"^3.0.1\",\n\"squirrelphp/twig-php-syntax\": \"^1.5\",\n\"symfony/asset\": \"^5.1\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Keep `sensiolabs/security-checker` around for now
|
95,144 |
15.02.2021 14:10:33
| -3,600 |
e720d67d018be1a7bf375bdd335b246dee678973
|
Move `doctrine/doctrine-migrations-bundle` to `require-dev`
|
[
{
"change_type": "MODIFY",
"old_path": "composer.json",
"new_path": "composer.json",
"diff": "\"composer/package-versions-deprecated\": \"^1.11\",\n\"doctrine/doctrine-bundle\": \"^2.1\",\n\"doctrine/doctrine-fixtures-bundle\": \"^3.3\",\n- \"doctrine/doctrine-migrations-bundle\": \"^2.2\",\n\"doctrine/orm\": \"^2.7\",\n\"drupol/composer-packages\": \"^2.0\",\n\"embed/embed\": \"^3.4\",\n\"bolt/newswidget\": \"^1.2\",\n\"coduo/php-matcher\": \"^4.0.2\",\n\"dama/doctrine-test-bundle\": \"^6.2.0\",\n+ \"doctrine/doctrine-migrations-bundle\": \"^2.2\",\n\"friends-of-behat/mink\": \"^1.8\",\n\"friends-of-behat/mink-browserkit-driver\": \"^1.4\",\n\"friends-of-behat/symfony-extension\": \"^2.1\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Move `doctrine/doctrine-migrations-bundle` to `require-dev`
|
95,144 |
15.02.2021 16:04:38
| -3,600 |
6493bcf00767435eee5ac592102dafdbfdaadf60
|
Add Composer scripts for 4.2
|
[
{
"change_type": "MODIFY",
"old_path": "bin/composer-script/post-install-cmd.php",
"new_path": "bin/composer-script/post-install-cmd.php",
"diff": "<?php\n+declare(strict_types=1);\n+\n// this script makes sure the install scripts are not required for composer install in CI\n// @see https://github.com/bolt/core/pull/1918#issuecomment-701460769\n@@ -14,6 +16,7 @@ $symfonyStyle = $symfonyStyleFactory->create();\n$ciDetector = new CiDetector();\nif ($ciDetector->isCiDetected()) {\n$symfonyStyle->warning(sprintf('\"php %s\" skipped in CI composer', __FILE__));\n+\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "bin/composer-script/post-update-cmd.php",
"new_path": "bin/composer-script/post-update-cmd.php",
"diff": "<?php\n+declare(strict_types=1);\n+\n// this script makes sure the install scripts are not required for composer update in CI\n// @see https://github.com/bolt/core/pull/1918#issuecomment-701460769\n@@ -14,6 +16,7 @@ $symfonyStyle = $symfonyStyleFactory->create();\n$ciDetector = new CiDetector();\nif ($ciDetector->isCiDetected()) {\n$symfonyStyle->warning(sprintf('\"php %s\" skipped in CI composer', __FILE__));\n+\nreturn;\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "bin/composer-script/project-post-create-project-cmd.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+/**\n+ * This file runs after `composer create-project` is run in bolt/project, in Bolt 4.2 and later.\n+ */\n+use Symplify\\PackageBuilder\\Console\\Style\\SymfonyStyleFactory;\n+\n+require __DIR__ . '/../../../../../vendor/autoload.php';\n+require __DIR__ . '/run.php';\n+\n+$symfonyStyleFactory = new SymfonyStyleFactory();\n+$symfonyStyle = $symfonyStyleFactory->create();\n+\n+$symfonyStyle->note('Running composer \"post-create-project-cmd\" scripts');\n+\n+// Run bolt/project post-create-project script\n+run('php bin/post-create-project.php', $symfonyStyle);\n+\n+// Copy the default themes\n+run('php bin/console bolt:copy-themes', $symfonyStyle);\n+\n+// Run the welcome command\n+run('php bin/console bolt:welcome', $symfonyStyle, true);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "bin/composer-script/project-post-install-cmd.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+/**\n+ * This file runs after `composer install` is run in bolt/project, in Bolt 4.2 and later.\n+ */\n+use Symplify\\PackageBuilder\\Console\\Style\\SymfonyStyleFactory;\n+\n+require __DIR__ . '/../../../../../vendor/autoload.php';\n+require __DIR__ . '/run.php';\n+\n+$symfonyStyleFactory = new SymfonyStyleFactory();\n+$symfonyStyle = $symfonyStyleFactory->create();\n+\n+// Run the auto scripts.\n+run('php bin/console bolt:copy-assets --ansi', $symfonyStyle);\n+run('php bin/console cache:clear --no-warmup --ansi', $symfonyStyle);\n+run('php bin/console assets:install --ansi', $symfonyStyle);\n+\n+// Configure the extensions\n+run('php bin/console extensions:configure --ansi', $symfonyStyle);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "bin/composer-script/project-post-update-cmd.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+/**\n+ * This file runs after `composer update` is run in bolt/project, in Bolt 4.2 and later.\n+ */\n+use Symplify\\PackageBuilder\\Console\\Style\\SymfonyStyleFactory;\n+\n+require __DIR__ . '/../../../../../vendor/autoload.php';\n+require __DIR__ . '/run.php';\n+\n+$symfonyStyleFactory = new SymfonyStyleFactory();\n+$symfonyStyle = $symfonyStyleFactory->create();\n+\n+$symfonyStyle->note('Running composer \"post-update-cmd\" scripts');\n+\n+// Install and copy the Bolt assets.\n+run('php bin/console assets:install --symlink --relative public', $symfonyStyle);\n+run('php bin/console bolt:copy-assets', $symfonyStyle);\n+\n+// (Re-)configure Bolt extensions\n+run('php bin/console extensions:configure --with-config --ansi', $symfonyStyle);\n+\n+// Clear cache, show Bolt info\n+run('php bin/console cache:clear --no-warmup', $symfonyStyle);\n+run('php bin/console bolt:info --ansi', $symfonyStyle, true);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "bin/composer-script/project-pre-install-cmd.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+/**\n+ * This file runs before `composer install` is run in bolt/project, in Bolt 4.2 and later.\n+ */\n+\n+// No operations done here. This file is here for (potential) future use.\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "bin/composer-script/project-pre-update-cmd.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+/**\n+ * This file runs before `composer install` is run in bolt/project, in Bolt 4.2 and later.\n+ */\n+use Symplify\\PackageBuilder\\Console\\Style\\SymfonyStyleFactory;\n+\n+require __DIR__ . '/../../../../../vendor/autoload.php';\n+require __DIR__ . '/run.php';\n+\n+$symfonyStyleFactory = new SymfonyStyleFactory();\n+$symfonyStyle = $symfonyStyleFactory->create();\n+\n+// Configure the extensions\n+run('php bin/console extensions:configure --remove-services', $symfonyStyle);\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "bin/composer-script/run.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+use Symfony\\Component\\Console\\Style\\SymfonyStyle;\n+\n+function run(string $command, SymfonyStyle $symfonyStyle, bool $withOutput = false, string $message = ''): void\n+{\n+ exec($command, $output, $return);\n+ if ($return) {\n+ // Some error occurred.\n+ if (empty($message)) {\n+ $message = sprintf(\"Command '%s' failed. %s\", $command, implode(\"\\n\", $output));\n+ }\n+ $symfonyStyle->error($message);\n+ } else {\n+ if ($withOutput) {\n+ $symfonyStyle->text($output);\n+ }\n+ $message = sprintf(\"Command '%s' executed successfully.\", $command);\n+ $symfonyStyle->success($message);\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Add Composer scripts for 4.2
|
95,144 |
17.02.2021 14:38:40
| -3,600 |
1bafac7867cc30150c8f09a1e38f2bff165d04ad
|
Update CSS for Skeleton theme
|
[
{
"change_type": "MODIFY",
"old_path": "public/theme/skeleton/css/simple.css",
"new_path": "public/theme/skeleton/css/simple.css",
"diff": "--code: #D81B60;\n--preformatted: #444;\n--marked: #FFDD33;\n+ --disabled: #EFEFEF;\n}\n/* Dark theme */\n--accent-light: #FFECB3;\n--code: #F06292;\n--preformatted: #CCC;\n+ --disabled: #111;\n}\nimg, video {\n}\n}\n-html {\n+* {\n/* Set the font globally */\nfont-family: var(--sans-font);\n+}\n+\n+html {\nfont-size: 16px;\n}\n@@ -105,7 +110,7 @@ footer input {\nnav {\nfont-size: 1rem;\nline-height: 2;\n- padding: 1rem 0 0;\n+ padding: 1rem 0;\n}\nnav a {\n@@ -215,6 +220,16 @@ input[type=\"button\"][disabled] {\ncursor: not-allowed;\n}\n+input:disabled,\n+textarea:disabled {\n+ cursor: not-allowed;\n+ background: var(--disabled);\n+}\n+\n+input[type=\"range\"] {\n+ padding: 0;\n+}\n+\n/* Set the cursor to '?' while hovering over an abbreviation */\nabbr {\ncursor: help;\n@@ -306,6 +321,9 @@ input {\nbox-shadow: none;\nbox-sizing: border-box;\nwidth: 60%;\n+ appearance: none;\n+ -moz-appearance: none;\n+ -webkit-appearance: none;\n}\n/* Make the textarea wider than other inputs */\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Update CSS for Skeleton theme
|
95,144 |
22.02.2021 15:51:09
| -3,600 |
25e8cec26d3b1ddd36e5f81e3946119491091dc0
|
Delete ProjectComposerEventHandler.php
|
[
{
"change_type": "DELETE",
"old_path": "src/Composer/ProjectComposerEventHandler.php",
"new_path": null,
"diff": "-<?php\n-\n-namespace Bolt\\Composer;\n-\n-use Composer\\Script\\Event;\n-\n-\n-class ProjectComposerEventHandler\n-{\n- public static function postInstall(Event $event): void\n- {\n- $composer = $event->getComposer();\n-\n- $config = $composer->getConfig();\n-\n- $composer->\n-\n- // Contains all the config.\n- var_dump($config->all());\n- die;\n- }\n-}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Delete ProjectComposerEventHandler.php
|
95,136 |
17.02.2021 11:39:42
| -3,600 |
91d05260c834881ea363bdd265cd2d3732415bab
|
check if variable is not defined
|
[
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/file.html.twig",
"new_path": "templates/_partials/fields/file.html.twig",
"diff": "{% endset %}\n{% block field %}\n+ {% if setPath is not defined %}\n{% set setPath = field.definition.get('upload')|placeholders({'contenttype': record.contenttype}) %}\n+ {% endif %}\n{% set directory = path('bolt_async_upload', {'location': location|default('files'), 'path': setPath}) %}\n{% set filelist = path('bolt_async_filelisting', {'location': location|default('files') }) %}\n{% set labels = {\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/filelist.html.twig",
"new_path": "templates/_partials/fields/filelist.html.twig",
"diff": "{% endset %}\n{% block field %}\n+ {% if setPath is not defined %}\n{% set setPath = field.definition.get('upload')|placeholders({'contenttype': record.contenttype}) %}\n+ {% endif %}\n{% set directory = path('bolt_async_upload', {'location': location|default('files'), 'path': setPath}) %}\n{% set filelist = path('bolt_async_filelisting', {'location': location|default('files') }) %}\n{% set labels = {\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/image.html.twig",
"new_path": "templates/_partials/fields/image.html.twig",
"diff": "{% endset %}\n{% block field %}\n-\n+ {% if setPath is not defined %}\n{% set setPath = field.definition.get('upload')|placeholders({'contenttype': record.contenttype}) %}\n+ {% endif %}\n{% set directory = path('bolt_async_upload', {'location': location|default('files'), 'path': setPath}) %}\n{% set directoryurl = path('bolt_async_upload_url', {'location': location|default('files'), 'path': setPath}) %}\n{% set filelist = path('bolt_async_filelisting', {'location': location|default('files'), 'type': 'images' }) %}\n"
},
{
"change_type": "MODIFY",
"old_path": "templates/_partials/fields/imagelist.html.twig",
"new_path": "templates/_partials/fields/imagelist.html.twig",
"diff": "{% endset %}\n{% block field %}\n+ {% if setPath is not defined %}\n{% set setPath = field.definition.get('upload')|placeholders({'contenttype': record.contenttype}) %}\n+ {% endif %}\n{% set directory = path('bolt_async_upload', {'location': location|default('files'), 'path': setPath}) %}\n{% set filelist = path('bolt_async_filelisting', {'location': location|default('files'), 'type': 'images' }) %}\n{% set labels = {\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
check if variable is not defined
|
95,144 |
26.02.2021 11:13:38
| -3,600 |
df6bf8acc86c4a9c029f340e0e6a36a84a7ee1fa
|
Prepare release 4.1.14
|
[
{
"change_type": "MODIFY",
"old_path": "assets/js/version.js",
"new_path": "assets/js/version.js",
"diff": "// generated by genversion\n-export const version = '4.1.13';\n+export const version = '4.1.14';\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"name\": \"bolt\",\n- \"version\": \"4.1.13\",\n+ \"version\": \"4.1.14\",\n\"homepage\": \"https://boltcms.io\",\n\"author\": \"Bob den Otter <bob@twokings.nl> (https://boltcms.io)\",\n\"license\": \"MIT\",\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Prepare release 4.1.14
|
95,144 |
27.02.2021 13:27:49
| -3,600 |
37cd91a3909141d2180ede17b6f114f70cee7588
|
Tweaking the composer scripts
|
[
{
"change_type": "MODIFY",
"old_path": "bin/composer-script/CreateProjectScript.php",
"new_path": "bin/composer-script/CreateProjectScript.php",
"diff": "@@ -32,6 +32,9 @@ class CreateProjectScript extends Script\nif (file_exists('public/.gitignore')) {\nunlink('public/.gitignore');\n}\n+ if (file_exists('config/extensions/.gitignore')) {\n+ unlink('config/extensions/.gitignore');\n+ }\n}\nprivate static function createReadme(): void\n"
},
{
"change_type": "MODIFY",
"old_path": "bin/composer-script/PostInstallScript.php",
"new_path": "bin/composer-script/PostInstallScript.php",
"diff": "@@ -11,7 +11,6 @@ class PostInstallScript extends Script\nself::run('php bin/console bolt:copy-assets --ansi');\nself::run('php bin/console cache:clear --no-warmup --ansi');\nself::run('php bin/console assets:install --ansi');\n- self::run('php bin/console doctrine:migrations:up-to-date --ansi');\nself::run('php bin/console extensions:configure --ansi');\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "bin/composer-script/PostUpdateScript.php",
"new_path": "bin/composer-script/PostUpdateScript.php",
"diff": "@@ -11,7 +11,6 @@ class PostUpdateScript extends Script\nself::run('php bin/console extensions:configure --with-config --ansi');\nself::run('php bin/console cache:clear --no-warmup --ansi');\nself::run('php bin/console assets:install --symlink --relative public --ansi');\n- self::run('php bin/console doctrine:migrations:up-to-date --ansi');\nself::run('php bin/console bolt:info --ansi');\n}\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "bin/composer-script/PrePackageUninstallScript.php",
"diff": "+<?php\n+\n+namespace Bolt\\ComposerScripts;\n+\n+class PrePackageUninstallScript extends Script\n+{\n+ public static function execute(): void\n+ {\n+ parent::init('Running composer \"pre-package-uninstall\" scripts');\n+\n+ self::run('php bin/console extensions:configure --remove-services --ansi');\n+ }\n+}\n"
},
{
"change_type": "MODIFY",
"old_path": "bin/composer-script/ProjectEventHandler.php",
"new_path": "bin/composer-script/ProjectEventHandler.php",
"diff": "@@ -4,6 +4,7 @@ declare(strict_types=1);\nnamespace Bolt\\ComposerScripts;\n+use Composer\\Installer\\PackageEvent;\nuse Composer\\Script\\Event;\n/**\n@@ -38,4 +39,10 @@ class ProjectEventHandler\n{\nPostUpdateScript::execute();\n}\n+\n+ public static function prePackageUninstall(PackageEvent $event): void\n+ {\n+ PrePackageUninstallScript::execute();\n+ }\n+\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Tweaking the composer scripts
|
95,144 |
27.02.2021 14:25:17
| -3,600 |
2ab2ee0fedfb29c7fda72454b603f2eb3adae93f
|
Don't remove these lines
|
[
{
"change_type": "MODIFY",
"old_path": "bin/composer-script/PostInstallScript.php",
"new_path": "bin/composer-script/PostInstallScript.php",
"diff": "@@ -11,6 +11,7 @@ class PostInstallScript extends Script\nself::run('php bin/console bolt:copy-assets --ansi');\nself::run('php bin/console cache:clear --no-warmup --ansi');\nself::run('php bin/console assets:install --ansi');\n+ self::run('php bin/console doctrine:migrations:up-to-date --ansi');\nself::run('php bin/console extensions:configure --ansi');\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "bin/composer-script/PostUpdateScript.php",
"new_path": "bin/composer-script/PostUpdateScript.php",
"diff": "@@ -11,6 +11,7 @@ class PostUpdateScript extends Script\nself::run('php bin/console extensions:configure --with-config --ansi');\nself::run('php bin/console cache:clear --no-warmup --ansi');\nself::run('php bin/console assets:install --symlink --relative public --ansi');\n+ self::run('php bin/console doctrine:migrations:up-to-date --ansi');\nself::run('php bin/console bolt:info --ansi');\n}\n}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Don't remove these lines
|
95,144 |
27.02.2021 15:15:46
| -3,600 |
ae09664bdbed34c04caa1f1fd448643cca2dd483
|
Create Welcome command for Bolt 4.2
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/Command/WelcomeCommand.php",
"diff": "+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Bolt\\Command;\n+\n+use Symfony\\Component\\Console\\Command\\Command;\n+use Symfony\\Component\\Console\\Input\\InputInterface;\n+use Symfony\\Component\\Console\\Output\\OutputInterface;\n+use Symfony\\Component\\Console\\Style\\SymfonyStyle;\n+\n+class WelcomeCommand extends Command\n+{\n+ use ImageTrait;\n+\n+ /** @var string */\n+ protected static $defaultName = 'bolt:welcome';\n+\n+ /**\n+ * {@inheritdoc}\n+ */\n+ protected function configure(): void\n+ {\n+ $this\n+ ->setDescription('Welcome command with basic resources about Bolt.')\n+ ->setHelp(\n+ <<<'HELP'\n+The <info>%command.name%</info> command shows some information and resources to get started with your Bolt project.\n+HELP\n+ );\n+ }\n+\n+ /**\n+ * This method is executed after initialize(). It usually contains the logic\n+ * to execute to complete this command task.\n+ */\n+ protected function execute(InputInterface $input, OutputInterface $output)\n+ {\n+ $io = new SymfonyStyle($input, $output);\n+\n+ $this->outputImage($io);\n+\n+ $io->info('Welcome to your new Bolt project. To set up the database, run `bin/console bolt:setup` inside your new project folder.');\n+ $io->text('For the full setup instructions, and other documentation, visit <href=https://docs.bolt.cm/installation/installation>https://docs.bolt.cm/installation/installation</>');\n+ $io->text('To ask questions and learn from our community, join our Slack channel: <href=https://slack.bolt.cm/>https://slack.bolt.cm/</>');\n+ $io->text('Additional resources and tips are available at <href=https://bolt.tips/>https://bolt.tips/</>');\n+\n+ $io->note('Do you develop websites with Bolt? You can join the growing list of fellow Bolters at people.boltcms.io, open source and free.');\n+\n+ $io->info('Happy building!');\n+\n+ return 0;\n+ }\n+}\n"
}
] |
PHP
|
MIT License
|
bolt/core
|
Create Welcome command for Bolt 4.2 - #2209
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.