Validate the user has the correct CRUD access permission.

@param array $user
@return bool
@throws ForbiddenException
@throws UnauthorizedException
185009
public function isAuthorized($user = null) {
        parent::isAuthorized($user);

        if (empty($this->params['model'])) {
            throw new ForbiddenException(__d('admin', 'Invalid Model'));
        }

        list($plugin, $model, $class) = Admin::parseName($this->params['model']);

        // Don't allow certain models
        if (in_array($class, Configure::read('Admin.ignoreModels'))) {
            throw new ForbiddenException(__d('admin', 'Restricted Model'));
        }

        $action = $this->action;

        // Allow non-crud actions
        if (in_array($action, array('type_ahead', 'proxy', 'process_behavior', 'process_model'))) {
            return true;

        // Index counts as a read
        } else if ($action === 'index') {
            $action = 'read';
        }

        if ($this->Acl->check(array(USER_MODEL => $user), $class, $action)) {
            return true;
        }

        throw new UnauthorizedException(__d('admin', 'Insufficient Access Permissions'));
    }
223217
public function validateCredentials(Authenticatable $user, array $credentials)
    {
        if (! app('hash')->check($credentials['password'], $user->password)) {
            return false;
        }

        return true;
    }
1109636
public function isAuthenticated($user = null)
    {
        $user = $user ?: $this->getUser();

        return $this->isGranted('IS_AUTHENTICATED_FULLY', $user) || $this->isGranted('IS_AUTHENTICATED_REMEMBERED', $user);
    }
1259180
public function accessPossible(User $user, $controller, $action) {
        $userRoles = $user->getRoles();
        try {
            $controllerAccess = CacheHelper::getControllerAccess($controller);
            $allowedRoles = isset($controllerAccess['actions'][$action])
                ? array_merge($controllerAccess['module'], $controllerAccess['actions'][$action])
                : $controllerAccess['module'];
            
            $accessAllowed = count(array_intersect($userRoles, $allowedRoles)) > 0;
        } catch (\ReflectionException $e) {
            \common_Logger::i('Unknown controller '.$controller);
            $accessAllowed = false;
        }
        
        return (bool) $accessAllowed;
    }
183188
protected function getUserPermissions($user)
    {
        $permissions = $this->manager->getDriver()->getCallerPermissions($user);
        $collection = new Collection();
        foreach ($permissions as $permission) {
            if ($permission instanceof Restriction) {
                continue;
            }
            $collection->allow($permission->getAction(), $permission->getResourceType(), $permission->getResourceId());
        }
        return $collection;
    }
1200392
public function is_available(User $user)
    {
        if (! $this->app['registration.manager']->isRegistrationEnabled()) {
            return false;
        }

        return $this->app->getAclForUser($user)->has_right(\ACL::CANADMIN);
    }
47270
protected function _check(array $user, array $params) {
		if ($this->getConfig('includeAuthentication') && $this->_isPublic($params)) {
			return true;
		}

		if (!$user) {
			return false;
		}

		if ($this->getConfig('superAdmin')) {
			$superAdminColumn = $this->getConfig('superAdminColumn');
			if (!$superAdminColumn) {
				$superAdminColumn = $this->getConfig('idColumn');
			}
			if (!isset($user[$superAdminColumn])) {
				throw new Exception('Missing super Admin Column in user table');
			}
			if ($user[$superAdminColumn] === $this->getConfig('superAdmin')) {
				return true;
			}
		}

		// Give any logged in user access to ALL actions when `allowUser` is
		// enabled except when the `adminPrefix` is being used.
		if ($this->getConfig('allowUser')) {
			if (empty($params['prefix'])) {
				return true;
			}
			if ($params['prefix'] !== $this->getConfig('adminPrefix')) {
				return true;
			}
		}

		$userRoles = $this->_getUserRoles($user);

		// Allow access to all prefixed actions for users belonging to
		// the specified role that matches the prefix.
		if ($this->getConfig('authorizeByPrefix') && !empty($params['prefix'])) {
			if (in_array($params['prefix'], $this->getConfig('prefixes'))) {
				$roles = $this->_getAvailableRoles();
				$role = isset($roles[$params['prefix']]) ? $roles[$params['prefix']] : null;
				if ($role && in_array($role, $userRoles)) {
					return true;
				}
			}
		}

		// Allow logged in super admins access to all resources
		if ($this->getConfig('superAdminRole')) {
			foreach ($userRoles as $userRole) {
				if ((string)$userRole === (string)$this->getConfig('superAdminRole')) {
					return true;
				}
			}
		}

		if ($this->_acl === null) {
			$this->_acl = $this->_getAcl($this->getConfig('aclFilePath'));
		}

		// Allow access if user has a role with wildcard access to the resource
		$iniKey = $this->_constructIniKey($params);
		if (isset($this->_acl[$iniKey]['actions']['*'])) {
			$matchArray = $this->_acl[$iniKey]['actions']['*'];
			foreach ($userRoles as $userRole) {
				if (in_array((string)$userRole, $matchArray)) {
					return true;
				}
			}
		}

		// Allow access if user has been granted access to the specific resource
		if (isset($this->_acl[$iniKey]['actions'])) {
			if (array_key_exists($params['action'], $this->_acl[$iniKey]['actions']) && !empty($this->_acl[$iniKey]['actions'][$params['action']])) {
				$matchArray = $this->_acl[$iniKey]['actions'][$params['action']];
				foreach ($userRoles as $userRole) {
					if (in_array((string)$userRole, $matchArray)) {
						return true;
					}
				}
			}
		}
		return false;
	}
681834
public function hasResponsible($user)
    {
        return $this->users()->where('user_id', $user->id)->first()->pivot->responsible;
    }
75559
public function validateCredentials(Authenticatable $user, array $credentials)
    {
        //TODO determine if we even want to store the passowrd.
        if (! $this->authenticate($user, $credentials)) {

            $plain = $credentials['password'];

            return $this->hasher->check($plain, $user->getAuthPassword());
        }
        return true;
    }
90812
public function makeUserLoggedIn($user)
    {
        if (!is_array($user) && !is_object($user)) {
            $user = $this->getUser($user);
        } elseif (!($user instanceof UserDataInterface)) {
            $user = new UserData($user);
        }

        if ($user->isNull()) {
            return false;
        }

        return $this->getHandler()->login($user);
    }
9033
protected function filterItemPermissions($user, array $items)
    {
        if (!$user) {
            return $items;
        }

        $items = array_filter($items, function ($item) use ($user) {
            if (!$item->permissions || !count($item->permissions)) {
                return true;
            }

            return $user->hasAnyAccess($item->permissions);
        });

        return $items;
    }
762206
public function hasAccess(array $url, array $user): bool
    {
        if (!empty($url['action']) && !empty($url['controller'])) {
            $controllerName = Utils::normalizeControllerName($url);
            if ($this->isSkipAction($controllerName, $url['action'])) {
                return true;
            }
        }

        if (!empty($url['controller']) && $this->isSkipController($url['controller'])) {
            return true;
        }

        if (!empty($url['action']) && $this->isSkipControllerActions($url['controller'], $url['action'])) {
            return true;
        }

        return false;
    }
955365
public function hasAccess(array $url, array $user): bool
    {
        $result = parent::hasAccess($url, $user);
        if (!$result) {
            return false;
        }

        $controllerName = Utils::getControllerFullName($url);

        $actionCapabilities = [];
        if (!empty($url['action'])) {
            $actionCapabilities = Utils::getCapabilities($controllerName, [$url['action']]);
        }

        // if action capabilities is empty, means that current controller or action are skipped
        if (empty($actionCapabilities)) {
            return true;
        }

        // User has full access
        $hasAccess = Utils::hasTypeAccess(Utils::getTypeFull(), $actionCapabilities, $user, $url);
        if ($hasAccess) {
            return true;
        }

        // if user has no full access capabilities
        $hasAccess = Utils::hasTypeAccess(Utils::getTypeOwner(), $actionCapabilities, $user, $url);
        if ($hasAccess) {
            return true;
        }

        $hasAccess = Utils::hasTypeAccess(Utils::getTypeBelongs(), $actionCapabilities, $user, $url);
        if ($hasAccess) {
            return true;
        }

        if (in_array($url['action'], $this->parentAccessActions)) {
            $hasAccess = $this->hasParentAccess($url);
            if ($hasAccess) {
                return true;
            }
        }

        return false;
    }
990046
public function logInRememberMe(array $user): bool
    {
        if (!$user) {
            return false;
        }

        $this->session->set('user', $user);

        return true;
    }
713498
protected function hasValidCredentials($user, $credentials)
    {
        return $user !== null && $this->provider->validateCredentials($user, $credentials);
    }
629119
public function isAuthorized($user)
    {
        $this->Authorizer->action(['*'], function ($auth, $user) {
            $auth->allowRole([1]);
        });

        return $this->Authorizer->authorize();
    }
294320
public function validateCredentials(UserInterface $user, array $credentials)
	{
		if($user == NULL)
			return FALSE;
		if(isset($credentials['NTLM']))
			return TRUE;
		if($credentials['password'] == '')
			return FALSE;

		if(!$result = @ldap_bind($this->conn, $user->id, $credentials['password']))
			return FALSE;

		return TRUE;
	}