mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
4f67f84ff8
Conflicts: app/config/acl.ini.php app/config/bootstrap.php app/config/core.php app/config/database.php.default app/config/inflections.php app/config/routes.php app/config/schema/db_acl.php app/config/schema/i18n.php app/config/schema/sessions.php app/config/sql/db_acl.sql app/config/sql/i18n.sql app/index.php app/webroot/css.php app/webroot/css/cake.generic.css app/webroot/index.php app/webroot/js/vendors.php app/webroot/test.php cake/LICENSE.txt cake/basics.php cake/bootstrap.php cake/config/config.php cake/config/paths.php cake/config/unicode/casefolding/0080_00ff.php cake/config/unicode/casefolding/0100_017f.php cake/config/unicode/casefolding/0180_024F.php cake/config/unicode/casefolding/0250_02af.php cake/config/unicode/casefolding/0370_03ff.php cake/config/unicode/casefolding/0400_04ff.php cake/config/unicode/casefolding/0500_052f.php cake/config/unicode/casefolding/0530_058f.php cake/config/unicode/casefolding/1e00_1eff.php cake/config/unicode/casefolding/1f00_1fff.php cake/config/unicode/casefolding/2100_214f.php cake/config/unicode/casefolding/2150_218f.php cake/config/unicode/casefolding/2460_24ff.php cake/config/unicode/casefolding/2c00_2c5f.php cake/config/unicode/casefolding/2c60_2c7f.php cake/config/unicode/casefolding/2c80_2cff.php cake/config/unicode/casefolding/ff00_ffef.php cake/console/cake cake/console/cake.bat cake/console/cake.php cake/console/error.php cake/console/libs/acl.php cake/console/libs/api.php cake/console/libs/bake.php cake/console/libs/console.php cake/console/libs/i18n.php cake/console/libs/schema.php cake/console/libs/shell.php cake/console/libs/tasks/controller.php cake/console/libs/tasks/db_config.php cake/console/libs/tasks/extract.php cake/console/libs/tasks/model.php cake/console/libs/tasks/plugin.php cake/console/libs/tasks/project.php cake/console/libs/tasks/test.php cake/console/libs/tasks/view.php cake/console/libs/templates/skel/config/bootstrap.php cake/console/libs/templates/skel/config/inflections.php cake/console/libs/templates/skel/config/sql/sessions.sql cake/console/libs/templates/skel/index.php cake/console/libs/templates/skel/views/elements/email/html/default.ctp cake/console/libs/templates/skel/views/elements/email/text/default.ctp cake/console/libs/templates/skel/views/layouts/ajax.ctp cake/console/libs/templates/skel/views/layouts/default.ctp cake/console/libs/templates/skel/views/layouts/email/html/default.ctp cake/console/libs/templates/skel/views/layouts/email/text/default.ctp cake/console/libs/templates/skel/webroot/js/vendors.php cake/console/libs/templates/skel/webroot/test.php cake/console/libs/templates/views/form.ctp cake/console/libs/templates/views/index.ctp cake/console/libs/testsuite.php cake/console/templates/default/views/view.ctp cake/console/templates/skel/app_controller.php cake/console/templates/skel/app_helper.php cake/console/templates/skel/app_model.php cake/console/templates/skel/config/acl.ini.php cake/console/templates/skel/config/core.php cake/console/templates/skel/config/database.php.default cake/console/templates/skel/config/routes.php cake/console/templates/skel/config/schema/db_acl.php cake/console/templates/skel/config/schema/db_acl.sql cake/console/templates/skel/config/schema/i18n.php cake/console/templates/skel/config/schema/i18n.sql cake/console/templates/skel/config/schema/sessions.php cake/console/templates/skel/config/schema/sessions.sql cake/console/templates/skel/controllers/pages_controller.php cake/console/templates/skel/views/layouts/flash.ctp cake/console/templates/skel/webroot/css.php cake/console/templates/skel/webroot/css/cake.generic.css cake/console/templates/skel/webroot/index.php cake/dispatcher.php cake/libs/cache.php cake/libs/cache/apc.php cake/libs/cache/file.php cake/libs/cache/memcache.php cake/libs/cache/xcache.php cake/libs/cake_log.php cake/libs/cake_session.php cake/libs/cake_socket.php cake/libs/class_registry.php cake/libs/configure.php cake/libs/controller/app_controller.php cake/libs/controller/component.php cake/libs/controller/components/acl.php cake/libs/controller/components/auth.php cake/libs/controller/components/cookie.php cake/libs/controller/components/email.php cake/libs/controller/components/request_handler.php cake/libs/controller/components/security.php cake/libs/controller/components/session.php cake/libs/controller/controller.php cake/libs/controller/pages_controller.php cake/libs/controller/scaffold.php cake/libs/debugger.php cake/libs/error.php cake/libs/file.php cake/libs/flay.php cake/libs/folder.php cake/libs/http_socket.php cake/libs/i18n.php cake/libs/inflector.php cake/libs/l10n.php cake/libs/magic_db.php cake/libs/model/app_model.php cake/libs/model/behaviors/acl.php cake/libs/model/behaviors/containable.php cake/libs/model/behaviors/translate.php cake/libs/model/behaviors/tree.php cake/libs/model/cake_schema.php cake/libs/model/connection_manager.php cake/libs/model/datasources/datasource.php cake/libs/model/datasources/dbo/dbo_adodb.php cake/libs/model/datasources/dbo/dbo_db2.php cake/libs/model/datasources/dbo/dbo_firebird.php cake/libs/model/datasources/dbo/dbo_mssql.php cake/libs/model/datasources/dbo/dbo_mysql.php cake/libs/model/datasources/dbo/dbo_mysqli.php cake/libs/model/datasources/dbo/dbo_odbc.php cake/libs/model/datasources/dbo/dbo_oracle.php cake/libs/model/datasources/dbo/dbo_postgres.php cake/libs/model/datasources/dbo/dbo_sqlite.php cake/libs/model/datasources/dbo/dbo_sybase.php cake/libs/model/datasources/dbo_source.php cake/libs/model/db_acl.php cake/libs/model/model.php cake/libs/model/model_behavior.php cake/libs/multibyte.php cake/libs/object.php cake/libs/overloadable.php cake/libs/overloadable_php4.php cake/libs/overloadable_php5.php cake/libs/router.php cake/libs/sanitize.php cake/libs/security.php cake/libs/set.php cake/libs/string.php cake/libs/validation.php cake/libs/view/elements/dump.ctp cake/libs/view/elements/email/html/default.ctp cake/libs/view/elements/email/text/default.ctp cake/libs/view/errors/error404.ctp cake/libs/view/errors/missing_action.ctp cake/libs/view/errors/missing_component_class.ctp cake/libs/view/errors/missing_component_file.ctp cake/libs/view/errors/missing_connection.ctp cake/libs/view/errors/missing_controller.ctp cake/libs/view/errors/missing_helper_class.ctp cake/libs/view/errors/missing_helper_file.ctp cake/libs/view/errors/missing_layout.ctp cake/libs/view/errors/missing_model.ctp cake/libs/view/errors/missing_scaffolddb.ctp cake/libs/view/errors/missing_table.ctp cake/libs/view/errors/missing_view.ctp cake/libs/view/errors/private_action.ctp cake/libs/view/errors/scaffold_error.ctp cake/libs/view/helper.php cake/libs/view/helpers/ajax.php cake/libs/view/helpers/app_helper.php cake/libs/view/helpers/cache.php cake/libs/view/helpers/form.php cake/libs/view/helpers/html.php cake/libs/view/helpers/javascript.php cake/libs/view/helpers/js.php cake/libs/view/helpers/number.php cake/libs/view/helpers/paginator.php cake/libs/view/helpers/rss.php cake/libs/view/helpers/session.php cake/libs/view/helpers/text.php cake/libs/view/helpers/time.php cake/libs/view/helpers/xml.php cake/libs/view/layouts/ajax.ctp cake/libs/view/layouts/default.ctp cake/libs/view/layouts/email/html/default.ctp cake/libs/view/layouts/email/text/default.ctp cake/libs/view/layouts/flash.ctp cake/libs/view/media.php cake/libs/view/pages/home.ctp cake/libs/view/scaffolds/edit.ctp cake/libs/view/scaffolds/index.ctp cake/libs/view/scaffolds/view.ctp cake/libs/view/theme.php cake/libs/view/view.php cake/libs/xml.php cake/tests/cases/basics.test.php cake/tests/cases/console/cake.test.php cake/tests/cases/console/libs/acl.test.php cake/tests/cases/console/libs/api.test.php cake/tests/cases/console/libs/schema.test.php cake/tests/cases/console/libs/shell.test.php cake/tests/cases/console/libs/tasks/extract.test.php cake/tests/cases/console/libs/tasks/model.test.php cake/tests/cases/console/libs/tasks/test.test.php cake/tests/cases/dispatcher.test.php cake/tests/cases/libs/cache.test.php cake/tests/cases/libs/cache/apc.test.php cake/tests/cases/libs/cache/file.test.php cake/tests/cases/libs/cache/memcache.test.php cake/tests/cases/libs/cache/xcache.test.php cake/tests/cases/libs/cake_log.test.php cake/tests/cases/libs/cake_session.test.php cake/tests/cases/libs/cake_socket.test.php cake/tests/cases/libs/cake_test_case.test.php cake/tests/cases/libs/cake_test_fixture.test.php cake/tests/cases/libs/class_registry.test.php cake/tests/cases/libs/code_coverage_manager.test.php cake/tests/cases/libs/configure.test.php cake/tests/cases/libs/controller/component.test.php cake/tests/cases/libs/controller/components/acl.test.php cake/tests/cases/libs/controller/components/auth.test.php cake/tests/cases/libs/controller/components/cookie.test.php cake/tests/cases/libs/controller/components/email.test.php cake/tests/cases/libs/controller/components/request_handler.test.php cake/tests/cases/libs/controller/components/security.test.php cake/tests/cases/libs/controller/components/session.test.php cake/tests/cases/libs/controller/controller.test.php cake/tests/cases/libs/controller/controller_merge_vars.test.php cake/tests/cases/libs/controller/pages_controller.test.php cake/tests/cases/libs/controller/scaffold.test.php cake/tests/cases/libs/debugger.test.php cake/tests/cases/libs/error.test.php cake/tests/cases/libs/file.test.php cake/tests/cases/libs/flay.test.php cake/tests/cases/libs/folder.test.php cake/tests/cases/libs/http_socket.test.php cake/tests/cases/libs/i18n.test.php cake/tests/cases/libs/inflector.test.php cake/tests/cases/libs/l10n.test.php cake/tests/cases/libs/magic_db.test.php cake/tests/cases/libs/model/behaviors/acl.test.php cake/tests/cases/libs/model/behaviors/containable.test.php cake/tests/cases/libs/model/behaviors/translate.test.php cake/tests/cases/libs/model/behaviors/tree.test.php cake/tests/cases/libs/model/cake_schema.test.php cake/tests/cases/libs/model/connection_manager.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_adodb.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_mssql.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_mysql.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_mysqli.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_postgres.test.php cake/tests/cases/libs/model/datasources/dbo/dbo_sqlite.test.php cake/tests/cases/libs/model/datasources/dbo_source.test.php cake/tests/cases/libs/model/db_acl.test.php cake/tests/cases/libs/model/model.test.php cake/tests/cases/libs/model/model_behavior.test.php cake/tests/cases/libs/model/model_delete.test.php cake/tests/cases/libs/model/model_integration.test.php cake/tests/cases/libs/model/model_read.test.php cake/tests/cases/libs/model/model_validation.test.php cake/tests/cases/libs/model/model_write.test.php cake/tests/cases/libs/model/models.php cake/tests/cases/libs/multibyte.test.php cake/tests/cases/libs/object.test.php cake/tests/cases/libs/overloadable.test.php cake/tests/cases/libs/router.test.php cake/tests/cases/libs/sanitize.test.php cake/tests/cases/libs/security.test.php cake/tests/cases/libs/set.test.php cake/tests/cases/libs/string.test.php cake/tests/cases/libs/test_manager.test.php cake/tests/cases/libs/validation.test.php cake/tests/cases/libs/view/helper.test.php cake/tests/cases/libs/view/helpers/ajax.test.php cake/tests/cases/libs/view/helpers/cache.test.php cake/tests/cases/libs/view/helpers/form.test.php cake/tests/cases/libs/view/helpers/html.test.php cake/tests/cases/libs/view/helpers/javascript.test.php cake/tests/cases/libs/view/helpers/js.test.php cake/tests/cases/libs/view/helpers/number.test.php cake/tests/cases/libs/view/helpers/paginator.test.php cake/tests/cases/libs/view/helpers/rss.test.php cake/tests/cases/libs/view/helpers/session.test.php cake/tests/cases/libs/view/helpers/text.test.php cake/tests/cases/libs/view/helpers/time.test.php cake/tests/cases/libs/view/helpers/xml.test.php cake/tests/cases/libs/view/theme.test.php cake/tests/cases/libs/view/view.test.php cake/tests/cases/libs/xml.test.php cake/tests/fixtures/account_fixture.php cake/tests/fixtures/aco_action_fixture.php cake/tests/fixtures/aco_fixture.php cake/tests/fixtures/aco_two_fixture.php cake/tests/fixtures/advertisement_fixture.php cake/tests/fixtures/another_article_fixture.php cake/tests/fixtures/apple_fixture.php cake/tests/fixtures/aro_fixture.php cake/tests/fixtures/aro_two_fixture.php cake/tests/fixtures/aros_aco_fixture.php cake/tests/fixtures/aros_aco_two_fixture.php cake/tests/fixtures/article_featured_fixture.php cake/tests/fixtures/article_featureds_tags_fixture.php cake/tests/fixtures/article_fixture.php cake/tests/fixtures/articles_tag_fixture.php cake/tests/fixtures/attachment_fixture.php cake/tests/fixtures/auth_user_custom_field_fixture.php cake/tests/fixtures/auth_user_fixture.php cake/tests/fixtures/author_fixture.php cake/tests/fixtures/basket_fixture.php cake/tests/fixtures/bid_fixture.php cake/tests/fixtures/binary_test_fixture.php cake/tests/fixtures/book_fixture.php cake/tests/fixtures/cache_test_model_fixture.php cake/tests/fixtures/callback_fixture.php cake/tests/fixtures/category_fixture.php cake/tests/fixtures/category_thread_fixture.php cake/tests/fixtures/cd_fixture.php cake/tests/fixtures/comment_fixture.php cake/tests/fixtures/content_account_fixture.php cake/tests/fixtures/content_fixture.php cake/tests/fixtures/counter_cache_post_fixture.php cake/tests/fixtures/counter_cache_post_nonstandard_primary_key_fixture.php cake/tests/fixtures/counter_cache_user_fixture.php cake/tests/fixtures/counter_cache_user_nonstandard_primary_key_fixture.php cake/tests/fixtures/data_test_fixture.php cake/tests/fixtures/datatype_fixture.php cake/tests/fixtures/dependency_fixture.php cake/tests/fixtures/device_fixture.php cake/tests/fixtures/device_type_category_fixture.php cake/tests/fixtures/device_type_fixture.php cake/tests/fixtures/document_directory_fixture.php cake/tests/fixtures/document_fixture.php cake/tests/fixtures/exterior_type_category_fixture.php cake/tests/fixtures/feature_set_fixture.php cake/tests/fixtures/featured_fixture.php cake/tests/fixtures/film_file_fixture.php cake/tests/fixtures/flag_tree_fixture.php cake/tests/fixtures/fruit_fixture.php cake/tests/fixtures/fruits_uuid_tag_fixture.php cake/tests/fixtures/home_fixture.php cake/tests/fixtures/image_fixture.php cake/tests/fixtures/item_fixture.php cake/tests/fixtures/items_portfolio_fixture.php cake/tests/fixtures/join_a_b_fixture.php cake/tests/fixtures/join_a_c_fixture.php cake/tests/fixtures/join_a_fixture.php cake/tests/fixtures/join_b_fixture.php cake/tests/fixtures/join_c_fixture.php cake/tests/fixtures/join_thing_fixture.php cake/tests/fixtures/message_fixture.php cake/tests/fixtures/my_categories_my_products_fixture.php cake/tests/fixtures/my_categories_my_users_fixture.php cake/tests/fixtures/my_category_fixture.php cake/tests/fixtures/my_product_fixture.php cake/tests/fixtures/my_user_fixture.php cake/tests/fixtures/node_fixture.php cake/tests/fixtures/number_tree_fixture.php cake/tests/fixtures/number_tree_two_fixture.php cake/tests/fixtures/numeric_article_fixture.php cake/tests/fixtures/overall_favorite_fixture.php cake/tests/fixtures/person_fixture.php cake/tests/fixtures/portfolio_fixture.php cake/tests/fixtures/post_fixture.php cake/tests/fixtures/posts_tag_fixture.php cake/tests/fixtures/primary_model_fixture.php cake/tests/fixtures/product_fixture.php cake/tests/fixtures/project_fixture.php cake/tests/fixtures/sample_fixture.php cake/tests/fixtures/secondary_model_fixture.php cake/tests/fixtures/session_fixture.php cake/tests/fixtures/something_else_fixture.php cake/tests/fixtures/something_fixture.php cake/tests/fixtures/stories_tag_fixture.php cake/tests/fixtures/story_fixture.php cake/tests/fixtures/syfile_fixture.php cake/tests/fixtures/tag_fixture.php cake/tests/fixtures/test_plugin_article_fixture.php cake/tests/fixtures/test_plugin_comment_fixture.php cake/tests/fixtures/the_paper_monkies_fixture.php cake/tests/fixtures/thread_fixture.php cake/tests/fixtures/translate_article_fixture.php cake/tests/fixtures/translate_fixture.php cake/tests/fixtures/translate_table_fixture.php cake/tests/fixtures/translated_article_fixture.php cake/tests/fixtures/translated_item_fixture.php cake/tests/fixtures/unconventional_tree_fixture.php cake/tests/fixtures/underscore_field_fixture.php cake/tests/fixtures/user_fixture.php cake/tests/fixtures/uuid_fixture.php cake/tests/fixtures/uuid_tag_fixture.php cake/tests/fixtures/uuid_tree_fixture.php cake/tests/fixtures/uuiditem_fixture.php cake/tests/fixtures/uuiditems_uuidportfolio_fixture.php cake/tests/fixtures/uuiditems_uuidportfolio_numericid_fixture.php cake/tests/fixtures/uuidportfolio_fixture.php cake/tests/groups/acl.group.php cake/tests/groups/cache.group.php cake/tests/groups/components.group.php cake/tests/groups/configure.group.php cake/tests/groups/console.group.php cake/tests/groups/controller.group.php cake/tests/groups/database.group.php cake/tests/groups/helpers.group.php cake/tests/groups/lib.group.php cake/tests/groups/model.group.php cake/tests/groups/no_cross_contamination.group.php cake/tests/groups/routing_system.group.php cake/tests/groups/socket.group.php cake/tests/groups/test_suite.group.php cake/tests/groups/view.group.php cake/tests/groups/xml.group.php cake/tests/lib/cake_reporter.php cake/tests/lib/cake_test_case.php cake/tests/lib/cake_test_fixture.php cake/tests/lib/cake_test_model.php cake/tests/lib/cake_web_test_case.php cake/tests/lib/cli_reporter.php cake/tests/lib/code_coverage_manager.php cake/tests/lib/templates/footer.php cake/tests/lib/templates/header.php cake/tests/lib/templates/menu.php cake/tests/lib/templates/simpletest.php cake/tests/lib/test_manager.php cake/tests/lib/xdebug.php cake/tests/test_app/config/acl.ini.php cake/tests/test_app/controllers/tests_apps_controller.php cake/tests/test_app/controllers/tests_apps_posts_controller.php cake/tests/test_app/models/behaviors/persister_one_behavior.php cake/tests/test_app/models/behaviors/persister_two_behavior.php cake/tests/test_app/models/comment.php cake/tests/test_app/models/persister_one.php cake/tests/test_app/models/persister_two.php cake/tests/test_app/models/post.php cake/tests/test_app/plugins/test_plugin/controllers/components/other_component.php cake/tests/test_app/plugins/test_plugin/controllers/components/plugins_component.php cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_component.php cake/tests/test_app/plugins/test_plugin/controllers/components/test_plugin_other_component.php cake/tests/test_app/plugins/test_plugin/controllers/tests_controller.php cake/tests/test_app/plugins/test_plugin/models/test_plugin_post.php cake/tests/test_app/plugins/test_plugin/test_plugin_app_controller.php cake/tests/test_app/plugins/test_plugin/test_plugin_app_model.php cake/tests/test_app/plugins/test_plugin/vendors/sample/sample_plugin.php cake/tests/test_app/plugins/test_plugin/vendors/shells/example.php cake/tests/test_app/plugins/test_plugin/vendors/welcome.php cake/tests/test_app/plugins/test_plugin/views/helpers/other_helper.php cake/tests/test_app/plugins/test_plugin/views/helpers/plugged_helper.php cake/tests/test_app/plugins/test_plugin_two/vendors/shells/example.php cake/tests/test_app/plugins/test_plugin_two/vendors/shells/welcome.php cake/tests/test_app/vendors/Test/MyTest.php cake/tests/test_app/vendors/Test/hello.php cake/tests/test_app/vendors/sample/configure_test_vendor_sample.php cake/tests/test_app/vendors/shells/sample.php cake/tests/test_app/vendors/somename/some.name.php cake/tests/test_app/vendors/welcome.php cake/tests/test_app/views/elements/email/html/default.ctp cake/tests/test_app/views/elements/email/text/default.ctp cake/tests/test_app/views/elements/email/text/wide.ctp cake/tests/test_app/views/layouts/ajax.ctp cake/tests/test_app/views/layouts/ajax2.ctp cake/tests/test_app/views/layouts/cache_layout.ctp cake/tests/test_app/views/layouts/default.ctp cake/tests/test_app/views/layouts/email/html/default.ctp cake/tests/test_app/views/layouts/email/html/thin.ctp cake/tests/test_app/views/layouts/email/text/default.ctp cake/tests/test_app/views/layouts/flash.ctp cake/tests/test_app/views/layouts/multi_cache.ctp cake/tests/test_app/views/posts/sequencial_nocache.ctp cake/tests/test_app/views/posts/test_nocache_tags.ctp index.php
737 lines
No EOL
19 KiB
PHP
737 lines
No EOL
19 KiB
PHP
<?php
|
|
/**
|
|
* Short description for file.
|
|
*
|
|
* PHP versions 4 and 5
|
|
*
|
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
*
|
|
* Licensed under The MIT License
|
|
* Redistributions of files must retain the above copyright notice.
|
|
*
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
|
* @link http://cakephp.org CakePHP(tm) Project
|
|
* @package cake
|
|
* @subpackage cake.cake.libs.controller.components
|
|
* @since CakePHP(tm) v 0.10.8.2156
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
|
*/
|
|
|
|
/**
|
|
* Short description for file.
|
|
*
|
|
* @package cake
|
|
* @subpackage cake.cake.libs.controller.components
|
|
*/
|
|
class SecurityComponent extends Object {
|
|
|
|
/**
|
|
* The controller method that will be called if this request is black-hole'd
|
|
*
|
|
* @var string
|
|
* @access public
|
|
*/
|
|
var $blackHoleCallback = null;
|
|
|
|
/**
|
|
* List of controller actions for which a POST request is required
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requirePost()
|
|
*/
|
|
var $requirePost = array();
|
|
|
|
/**
|
|
* List of controller actions for which a GET request is required
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireGet()
|
|
*/
|
|
var $requireGet = array();
|
|
|
|
/**
|
|
* List of controller actions for which a PUT request is required
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requirePut()
|
|
*/
|
|
var $requirePut = array();
|
|
|
|
/**
|
|
* List of controller actions for which a DELETE request is required
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireDelete()
|
|
*/
|
|
var $requireDelete = array();
|
|
|
|
/**
|
|
* List of actions that require an SSL-secured connection
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireSecure()
|
|
*/
|
|
var $requireSecure = array();
|
|
|
|
/**
|
|
* List of actions that require a valid authentication key
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireAuth()
|
|
*/
|
|
var $requireAuth = array();
|
|
|
|
/**
|
|
* List of actions that require an HTTP-authenticated login (basic or digest)
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireLogin()
|
|
*/
|
|
var $requireLogin = array();
|
|
|
|
/**
|
|
* Login options for SecurityComponent::requireLogin()
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireLogin()
|
|
*/
|
|
var $loginOptions = array('type' => '', 'prompt' => null);
|
|
|
|
/**
|
|
* An associative array of usernames/passwords used for HTTP-authenticated logins.
|
|
* If using digest authentication, passwords should be MD5-hashed.
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireLogin()
|
|
*/
|
|
var $loginUsers = array();
|
|
|
|
/**
|
|
* Controllers from which actions of the current controller are allowed to receive
|
|
* requests.
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireAuth()
|
|
*/
|
|
var $allowedControllers = array();
|
|
|
|
/**
|
|
* Actions from which actions of the current controller are allowed to receive
|
|
* requests.
|
|
*
|
|
* @var array
|
|
* @access public
|
|
* @see SecurityComponent::requireAuth()
|
|
*/
|
|
var $allowedActions = array();
|
|
|
|
/**
|
|
* Form fields to disable
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $disabledFields = array();
|
|
|
|
/**
|
|
* Whether to validate POST data. Set to false to disable for data coming from 3rd party
|
|
* services, etc.
|
|
*
|
|
* @var boolean
|
|
* @access public
|
|
*/
|
|
var $validatePost = true;
|
|
|
|
/**
|
|
* Other components used by the Security component
|
|
*
|
|
* @var array
|
|
* @access public
|
|
*/
|
|
var $components = array('RequestHandler', 'Session');
|
|
|
|
/**
|
|
* Holds the current action of the controller
|
|
*
|
|
* @var string
|
|
*/
|
|
var $_action = null;
|
|
|
|
/**
|
|
* Initialize the SecurityComponent
|
|
*
|
|
* @param object $controller Controller instance for the request
|
|
* @param array $settings Settings to set to the component
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function initialize(&$controller, $settings = array()) {
|
|
$this->_set($settings);
|
|
}
|
|
|
|
/**
|
|
* Component startup. All security checking happens here.
|
|
*
|
|
* @param object $controller Instantiating controller
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function startup(&$controller) {
|
|
$this->_action = strtolower($controller->action);
|
|
$this->_methodsRequired($controller);
|
|
$this->_secureRequired($controller);
|
|
$this->_authRequired($controller);
|
|
$this->_loginRequired($controller);
|
|
|
|
$isPost = ($this->RequestHandler->isPost() || $this->RequestHandler->isPut());
|
|
$isRequestAction = (
|
|
!isset($controller->params['requested']) ||
|
|
$controller->params['requested'] != 1
|
|
);
|
|
|
|
if ($isPost && $isRequestAction && $this->validatePost) {
|
|
if ($this->_validatePost($controller) === false) {
|
|
if (!$this->blackHole($controller, 'auth')) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
$this->_generateToken($controller);
|
|
}
|
|
|
|
/**
|
|
* Sets the actions that require a POST request, or empty for all actions
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function requirePost() {
|
|
$args = func_get_args();
|
|
$this->_requireMethod('Post', $args);
|
|
}
|
|
|
|
/**
|
|
* Sets the actions that require a GET request, or empty for all actions
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function requireGet() {
|
|
$args = func_get_args();
|
|
$this->_requireMethod('Get', $args);
|
|
}
|
|
|
|
/**
|
|
* Sets the actions that require a PUT request, or empty for all actions
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function requirePut() {
|
|
$args = func_get_args();
|
|
$this->_requireMethod('Put', $args);
|
|
}
|
|
|
|
/**
|
|
* Sets the actions that require a DELETE request, or empty for all actions
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function requireDelete() {
|
|
$args = func_get_args();
|
|
$this->_requireMethod('Delete', $args);
|
|
}
|
|
|
|
/**
|
|
* Sets the actions that require a request that is SSL-secured, or empty for all actions
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function requireSecure() {
|
|
$args = func_get_args();
|
|
$this->_requireMethod('Secure', $args);
|
|
}
|
|
|
|
/**
|
|
* Sets the actions that require an authenticated request, or empty for all actions
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function requireAuth() {
|
|
$args = func_get_args();
|
|
$this->_requireMethod('Auth', $args);
|
|
}
|
|
|
|
/**
|
|
* Sets the actions that require an HTTP-authenticated request, or empty for all actions
|
|
*
|
|
* @return void
|
|
* @access public
|
|
*/
|
|
function requireLogin() {
|
|
$args = func_get_args();
|
|
$base = $this->loginOptions;
|
|
|
|
foreach ($args as $i => $arg) {
|
|
if (is_array($arg)) {
|
|
$this->loginOptions = $arg;
|
|
unset($args[$i]);
|
|
}
|
|
}
|
|
$this->loginOptions = array_merge($base, $this->loginOptions);
|
|
$this->_requireMethod('Login', $args);
|
|
|
|
if (isset($this->loginOptions['users'])) {
|
|
$this->loginUsers =& $this->loginOptions['users'];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Attempts to validate the login credentials for an HTTP-authenticated request
|
|
*
|
|
* @param string $type Either 'basic', 'digest', or null. If null/empty, will try both.
|
|
* @return mixed If successful, returns an array with login name and password, otherwise null.
|
|
* @access public
|
|
*/
|
|
function loginCredentials($type = null) {
|
|
switch (strtolower($type)) {
|
|
case 'basic':
|
|
$login = array('username' => env('PHP_AUTH_USER'), 'password' => env('PHP_AUTH_PW'));
|
|
if (!empty($login['username'])) {
|
|
return $login;
|
|
}
|
|
break;
|
|
case 'digest':
|
|
default:
|
|
$digest = null;
|
|
|
|
if (version_compare(PHP_VERSION, '5.1') != -1) {
|
|
$digest = env('PHP_AUTH_DIGEST');
|
|
} elseif (function_exists('apache_request_headers')) {
|
|
$headers = apache_request_headers();
|
|
if (isset($headers['Authorization']) && !empty($headers['Authorization']) && substr($headers['Authorization'], 0, 7) == 'Digest ') {
|
|
$digest = substr($headers['Authorization'], 7);
|
|
}
|
|
} else {
|
|
// Server doesn't support digest-auth headers
|
|
trigger_error(__('SecurityComponent::loginCredentials() - Server does not support digest authentication', true), E_USER_WARNING);
|
|
}
|
|
|
|
if (!empty($digest)) {
|
|
return $this->parseDigestAuthData($digest);
|
|
}
|
|
break;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Generates the text of an HTTP-authentication request header from an array of options.
|
|
*
|
|
* @param array $options Set of options for header
|
|
* @return string HTTP-authentication request header
|
|
* @access public
|
|
*/
|
|
function loginRequest($options = array()) {
|
|
$options = array_merge($this->loginOptions, $options);
|
|
$this->_setLoginDefaults($options);
|
|
$auth = 'WWW-Authenticate: ' . ucfirst($options['type']);
|
|
$out = array('realm="' . $options['realm'] . '"');
|
|
|
|
if (strtolower($options['type']) == 'digest') {
|
|
$out[] = 'qop="auth"';
|
|
$out[] = 'nonce="' . uniqid("") . '"';
|
|
$out[] = 'opaque="' . md5($options['realm']) . '"';
|
|
}
|
|
|
|
return $auth . ' ' . implode(',', $out);
|
|
}
|
|
|
|
/**
|
|
* Parses an HTTP digest authentication response, and returns an array of the data, or null on failure.
|
|
*
|
|
* @param string $digest Digest authentication response
|
|
* @return array Digest authentication parameters
|
|
* @access public
|
|
*/
|
|
function parseDigestAuthData($digest) {
|
|
if (substr($digest, 0, 7) == 'Digest ') {
|
|
$digest = substr($digest, 7);
|
|
}
|
|
$keys = array();
|
|
$match = array();
|
|
$req = array('nonce' => 1, 'nc' => 1, 'cnonce' => 1, 'qop' => 1, 'username' => 1, 'uri' => 1, 'response' => 1);
|
|
preg_match_all('@(\w+)=([\'"]?)([a-zA-Z0-9=./\_-]+)\2@', $digest, $match, PREG_SET_ORDER);
|
|
|
|
foreach ($match as $i) {
|
|
$keys[$i[1]] = $i[3];
|
|
unset($req[$i[1]]);
|
|
}
|
|
|
|
if (empty($req)) {
|
|
return $keys;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Generates a hash to be compared with an HTTP digest-authenticated response
|
|
*
|
|
* @param array $data HTTP digest response data, as parsed by SecurityComponent::parseDigestAuthData()
|
|
* @return string Digest authentication hash
|
|
* @access public
|
|
* @see SecurityComponent::parseDigestAuthData()
|
|
*/
|
|
function generateDigestResponseHash($data) {
|
|
return md5(
|
|
md5($data['username'] . ':' . $this->loginOptions['realm'] . ':' . $this->loginUsers[$data['username']]) .
|
|
':' . $data['nonce'] . ':' . $data['nc'] . ':' . $data['cnonce'] . ':' . $data['qop'] . ':' .
|
|
md5(env('REQUEST_METHOD') . ':' . $data['uri'])
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Black-hole an invalid request with a 404 error or custom callback. If SecurityComponent::$blackHoleCallback
|
|
* is specified, it will use this callback by executing the method indicated in $error
|
|
*
|
|
* @param object $controller Instantiating controller
|
|
* @param string $error Error method
|
|
* @return mixed If specified, controller blackHoleCallback's response, or no return otherwise
|
|
* @access public
|
|
* @see SecurityComponent::$blackHoleCallback
|
|
*/
|
|
function blackHole(&$controller, $error = '') {
|
|
if ($this->blackHoleCallback == null) {
|
|
$code = 404;
|
|
if ($error == 'login') {
|
|
$code = 401;
|
|
$controller->header($this->loginRequest());
|
|
}
|
|
$controller->redirect(null, $code, true);
|
|
} else {
|
|
return $this->_callback($controller, $this->blackHoleCallback, array($error));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sets the actions that require a $method HTTP request, or empty for all actions
|
|
*
|
|
* @param string $method The HTTP method to assign controller actions to
|
|
* @param array $actions Controller actions to set the required HTTP method to.
|
|
* @return void
|
|
* @access protected
|
|
*/
|
|
function _requireMethod($method, $actions = array()) {
|
|
if (isset($actions[0]) && is_array($actions[0])) {
|
|
$actions = $actions[0];
|
|
}
|
|
$this->{'require' . $method} = (empty($actions)) ? array('*'): $actions;
|
|
}
|
|
|
|
/**
|
|
* Check if HTTP methods are required
|
|
*
|
|
* @param object $controller Instantiating controller
|
|
* @return bool true if $method is required
|
|
* @access protected
|
|
*/
|
|
function _methodsRequired(&$controller) {
|
|
foreach (array('Post', 'Get', 'Put', 'Delete') as $method) {
|
|
$property = 'require' . $method;
|
|
if (is_array($this->$property) && !empty($this->$property)) {
|
|
$require = array_map('strtolower', $this->$property);
|
|
|
|
if (in_array($this->_action, $require) || $this->$property == array('*')) {
|
|
if (!$this->RequestHandler->{'is' . $method}()) {
|
|
if (!$this->blackHole($controller, strtolower($method))) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Check if access requires secure connection
|
|
*
|
|
* @param object $controller Instantiating controller
|
|
* @return bool true if secure connection required
|
|
* @access protected
|
|
*/
|
|
function _secureRequired(&$controller) {
|
|
if (is_array($this->requireSecure) && !empty($this->requireSecure)) {
|
|
$requireSecure = array_map('strtolower', $this->requireSecure);
|
|
|
|
if (in_array($this->_action, $requireSecure) || $this->requireSecure == array('*')) {
|
|
if (!$this->RequestHandler->isSSL()) {
|
|
if (!$this->blackHole($controller, 'secure')) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Check if authentication is required
|
|
*
|
|
* @param object $controller Instantiating controller
|
|
* @return bool true if authentication required
|
|
* @access protected
|
|
*/
|
|
function _authRequired(&$controller) {
|
|
if (is_array($this->requireAuth) && !empty($this->requireAuth) && !empty($controller->data)) {
|
|
$requireAuth = array_map('strtolower', $this->requireAuth);
|
|
|
|
if (in_array($this->_action, $requireAuth) || $this->requireAuth == array('*')) {
|
|
if (!isset($controller->data['_Token'] )) {
|
|
if (!$this->blackHole($controller, 'auth')) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
if ($this->Session->check('_Token')) {
|
|
$tData = unserialize($this->Session->read('_Token'));
|
|
|
|
if (!empty($tData['allowedControllers']) && !in_array($controller->params['controller'], $tData['allowedControllers']) || !empty($tData['allowedActions']) && !in_array($controller->params['action'], $tData['allowedActions'])) {
|
|
if (!$this->blackHole($controller, 'auth')) {
|
|
return null;
|
|
}
|
|
}
|
|
} else {
|
|
if (!$this->blackHole($controller, 'auth')) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Check if login is required
|
|
*
|
|
* @param object $controller Instantiating controller
|
|
* @return bool true if login is required
|
|
* @access protected
|
|
*/
|
|
function _loginRequired(&$controller) {
|
|
if (is_array($this->requireLogin) && !empty($this->requireLogin)) {
|
|
$requireLogin = array_map('strtolower', $this->requireLogin);
|
|
|
|
if (in_array($this->_action, $requireLogin) || $this->requireLogin == array('*')) {
|
|
$login = $this->loginCredentials($this->loginOptions['type']);
|
|
|
|
if ($login == null) {
|
|
$controller->header($this->loginRequest());
|
|
|
|
if (!empty($this->loginOptions['prompt'])) {
|
|
$this->_callback($controller, $this->loginOptions['prompt']);
|
|
} else {
|
|
$this->blackHole($controller, 'login');
|
|
}
|
|
} else {
|
|
if (isset($this->loginOptions['login'])) {
|
|
$this->_callback($controller, $this->loginOptions['login'], array($login));
|
|
} else {
|
|
if (strtolower($this->loginOptions['type']) == 'digest') {
|
|
if ($login && isset($this->loginUsers[$login['username']])) {
|
|
if ($login['response'] == $this->generateDigestResponseHash($login)) {
|
|
return true;
|
|
}
|
|
}
|
|
$this->blackHole($controller, 'login');
|
|
} else {
|
|
if (
|
|
!(in_array($login['username'], array_keys($this->loginUsers)) &&
|
|
$this->loginUsers[$login['username']] == $login['password'])
|
|
) {
|
|
$this->blackHole($controller, 'login');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Validate submitted form
|
|
*
|
|
* @param object $controller Instantiating controller
|
|
* @return bool true if submitted form is valid
|
|
* @access protected
|
|
*/
|
|
function _validatePost(&$controller) {
|
|
if (empty($controller->data)) {
|
|
return true;
|
|
}
|
|
$data = $controller->data;
|
|
|
|
if (!isset($data['_Token']) || !isset($data['_Token']['fields']) || !isset($data['_Token']['key'])) {
|
|
return false;
|
|
}
|
|
$token = $data['_Token']['key'];
|
|
|
|
if ($this->Session->check('_Token')) {
|
|
$tokenData = unserialize($this->Session->read('_Token'));
|
|
|
|
if ($tokenData['expires'] < time() || $tokenData['key'] !== $token) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$locked = null;
|
|
$check = $controller->data;
|
|
$token = urldecode($check['_Token']['fields']);
|
|
|
|
if (strpos($token, ':')) {
|
|
list($token, $locked) = explode(':', $token, 2);
|
|
}
|
|
unset($check['_Token']);
|
|
|
|
$lockedFields = array();
|
|
$fields = Set::flatten($check);
|
|
$fieldList = array_keys($fields);
|
|
$locked = unserialize(str_rot13($locked));
|
|
$multi = array();
|
|
|
|
foreach ($fieldList as $i => $key) {
|
|
if (preg_match('/\.\d+$/', $key)) {
|
|
$multi[$i] = preg_replace('/\.\d+$/', '', $key);
|
|
unset($fieldList[$i]);
|
|
}
|
|
}
|
|
if (!empty($multi)) {
|
|
$fieldList += array_unique($multi);
|
|
}
|
|
|
|
foreach ($fieldList as $i => $key) {
|
|
$isDisabled = false;
|
|
$isLocked = (is_array($locked) && in_array($key, $locked));
|
|
|
|
if (!empty($this->disabledFields)) {
|
|
foreach ((array)$this->disabledFields as $disabled) {
|
|
$disabled = explode('.', $disabled);
|
|
$field = array_values(array_intersect(explode('.', $key), $disabled));
|
|
$isDisabled = ($field === $disabled);
|
|
if ($isDisabled) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($isDisabled || $isLocked) {
|
|
unset($fieldList[$i]);
|
|
if ($isLocked) {
|
|
$lockedFields[$key] = $fields[$key];
|
|
}
|
|
}
|
|
}
|
|
sort($fieldList, SORT_STRING);
|
|
ksort($lockedFields, SORT_STRING);
|
|
|
|
$fieldList += $lockedFields;
|
|
$check = Security::hash(serialize($fieldList) . Configure::read('Security.salt'));
|
|
return ($token === $check);
|
|
}
|
|
|
|
/**
|
|
* Add authentication key for new form posts
|
|
*
|
|
* @param object $controller Instantiating controller
|
|
* @return bool Success
|
|
* @access protected
|
|
*/
|
|
function _generateToken(&$controller) {
|
|
if (isset($controller->params['requested']) && $controller->params['requested'] === 1) {
|
|
if ($this->Session->check('_Token')) {
|
|
$tokenData = unserialize($this->Session->read('_Token'));
|
|
$controller->params['_Token'] = $tokenData;
|
|
}
|
|
return false;
|
|
}
|
|
$authKey = Security::generateAuthKey();
|
|
$expires = strtotime('+' . Security::inactiveMins() . ' minutes');
|
|
$token = array(
|
|
'key' => $authKey,
|
|
'expires' => $expires,
|
|
'allowedControllers' => $this->allowedControllers,
|
|
'allowedActions' => $this->allowedActions,
|
|
'disabledFields' => $this->disabledFields
|
|
);
|
|
|
|
if (!isset($controller->data)) {
|
|
$controller->data = array();
|
|
}
|
|
|
|
if ($this->Session->check('_Token')) {
|
|
$tokenData = unserialize($this->Session->read('_Token'));
|
|
$valid = (
|
|
isset($tokenData['expires']) &&
|
|
$tokenData['expires'] > time() &&
|
|
isset($tokenData['key'])
|
|
);
|
|
|
|
if ($valid) {
|
|
$token['key'] = $tokenData['key'];
|
|
}
|
|
}
|
|
$controller->params['_Token'] = $token;
|
|
$this->Session->write('_Token', serialize($token));
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Sets the default login options for an HTTP-authenticated request
|
|
*
|
|
* @param array $options Default login options
|
|
* @return void
|
|
* @access protected
|
|
*/
|
|
function _setLoginDefaults(&$options) {
|
|
$options = array_merge(array(
|
|
'type' => 'basic',
|
|
'realm' => env('SERVER_NAME'),
|
|
'qop' => 'auth',
|
|
'nonce' => String::uuid()
|
|
), array_filter($options));
|
|
$options = array_merge(array('opaque' => md5($options['realm'])), $options);
|
|
}
|
|
|
|
/**
|
|
* Calls a controller callback method
|
|
*
|
|
* @param object $controller Controller to run callback on
|
|
* @param string $method Method to execute
|
|
* @param array $params Parameters to send to method
|
|
* @return mixed Controller callback method's response
|
|
* @access protected
|
|
*/
|
|
function _callback(&$controller, $method, $params = array()) {
|
|
if (is_callable(array($controller, $method))) {
|
|
return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
?>
|