|
|
@@ -108,16 +108,13 @@ class SecurityComponent extends Component
|
|
|
{
|
|
|
$controller = $event->subject();
|
|
|
$this->session = $this->request->session();
|
|
|
- $this->_action = $this->request->params['action'];
|
|
|
- $hasData = !empty($this->request->data);
|
|
|
+ $this->_action = $this->request->param('action');
|
|
|
+ $hasData = !empty($this->request->data());
|
|
|
try {
|
|
|
$this->_secureRequired($controller);
|
|
|
$this->_authRequired($controller);
|
|
|
|
|
|
- $isNotRequestAction = (
|
|
|
- !isset($controller->request->params['requested']) ||
|
|
|
- $controller->request->params['requested'] != 1
|
|
|
- );
|
|
|
+ $isNotRequestAction = !$controller->request->param('requested');
|
|
|
|
|
|
if ($this->_action === $this->_config['blackHoleCallback']) {
|
|
|
throw new AuthSecurityException(sprintf('Action %s is defined as the blackhole callback.', $this->_action));
|
|
|
@@ -134,7 +131,7 @@ class SecurityComponent extends Component
|
|
|
}
|
|
|
|
|
|
$this->generateToken($controller->request);
|
|
|
- if ($hasData && is_array($controller->request->data)) {
|
|
|
+ if ($hasData && is_array($controller->request->data())) {
|
|
|
unset($controller->request->data['_Token']);
|
|
|
}
|
|
|
}
|
|
|
@@ -269,12 +266,12 @@ class SecurityComponent extends Component
|
|
|
{
|
|
|
if (is_array($this->_config['requireAuth']) &&
|
|
|
!empty($this->_config['requireAuth']) &&
|
|
|
- !empty($this->request->data)
|
|
|
+ !empty($this->request->data())
|
|
|
) {
|
|
|
$requireAuth = $this->_config['requireAuth'];
|
|
|
|
|
|
- if (in_array($this->request->params['action'], $requireAuth) || $requireAuth == ['*']) {
|
|
|
- if (!isset($controller->request->data['_Token'])) {
|
|
|
+ if (in_array($this->request->param('action'), $requireAuth) || $requireAuth == ['*']) {
|
|
|
+ if (!isset($this->request->data['_Token'])) {
|
|
|
throw new AuthSecurityException('\'_Token\' was not found in request data.');
|
|
|
}
|
|
|
|
|
|
@@ -282,23 +279,23 @@ class SecurityComponent extends Component
|
|
|
$tData = $this->session->read('_Token');
|
|
|
|
|
|
if (!empty($tData['allowedControllers']) &&
|
|
|
- !in_array($this->request->params['controller'], $tData['allowedControllers'])) {
|
|
|
+ !in_array($this->request->param('controller'), $tData['allowedControllers'])) {
|
|
|
throw new AuthSecurityException(
|
|
|
sprintf(
|
|
|
'Controller \'%s\' was not found in allowed controllers: \'%s\'.',
|
|
|
- $this->request->params['controller'],
|
|
|
+ $this->request->param('controller'),
|
|
|
implode(', ', (array)$tData['allowedControllers'])
|
|
|
)
|
|
|
);
|
|
|
}
|
|
|
if (!empty($tData['allowedActions']) &&
|
|
|
- !in_array($this->request->params['action'], $tData['allowedActions'])
|
|
|
+ !in_array($this->request->param('action'), $tData['allowedActions'])
|
|
|
) {
|
|
|
throw new AuthSecurityException(
|
|
|
sprintf(
|
|
|
'Action \'%s::%s\' was not found in allowed actions: \'%s\'.',
|
|
|
- $this->request->params['controller'],
|
|
|
- $this->request->params['action'],
|
|
|
+ $this->request->param('controller'),
|
|
|
+ $this->request->param('action'),
|
|
|
implode(', ', (array)$tData['allowedActions'])
|
|
|
)
|
|
|
);
|
|
|
@@ -321,7 +318,7 @@ class SecurityComponent extends Component
|
|
|
*/
|
|
|
protected function _validatePost(Controller $controller)
|
|
|
{
|
|
|
- if (empty($controller->request->data)) {
|
|
|
+ if (empty($controller->request->data())) {
|
|
|
return true;
|
|
|
}
|
|
|
$token = $this->_validToken($controller);
|
|
|
@@ -384,8 +381,8 @@ class SecurityComponent extends Component
|
|
|
*/
|
|
|
protected function _hashParts(Controller $controller)
|
|
|
{
|
|
|
- $fieldList = $this->_fieldsList($controller->request->data);
|
|
|
- $unlocked = $this->_sortedUnlocked($controller->request->data);
|
|
|
+ $fieldList = $this->_fieldsList($controller->request->data());
|
|
|
+ $unlocked = $this->_sortedUnlocked($controller->request->data());
|
|
|
|
|
|
return [
|
|
|
$controller->request->here(),
|
|
|
@@ -570,7 +567,7 @@ class SecurityComponent extends Component
|
|
|
*/
|
|
|
public function generateToken(Request $request)
|
|
|
{
|
|
|
- if (isset($request->params['requested']) && $request->params['requested'] === 1) {
|
|
|
+ if ($request->is('requested')) {
|
|
|
if ($this->session->check('_Token')) {
|
|
|
$request->params['_Token'] = $this->session->read('_Token');
|
|
|
}
|