Resolve if authorization can if action exists.

@param  string  $action
@param  \Orchestra\Contracts\Authorization\Authorizable|null  $user

@return bool
516010
protected function canIf(string $action, ?Authorizable $user = null): bool
    {
        return ! \is_null($user)
                    ? $this->acl->canIfAs($user, $action)
                    : $this->acl->canIf($action);
    }
1184912
public function isAuthorized($user = null) {
		$result = false;
		if (empty($this->prefixes) || !is_array($this->prefixes)) {
			return $result;
		}
		$rolePrefix = (string)$this->_objUserInfo->getUserField('prefix', $user);
		if (!empty($rolePrefix)) {
			if (!in_array($rolePrefix, $this->prefixes)) {
				return $result;
			}
			$prefixes = [$rolePrefix];
		} else {
			$prefixes = $this->prefixes;
		}

		$action = $this->_controller->request->param('action');
		foreach ($prefixes as $prefix) {
			if (mb_stripos($action, $prefix . '_') === 0) {
				$result |= true;
			} else {
				$result |= false;
			}
		}
		if (empty($rolePrefix)) {
			$result = !$result;
		}

		return (bool)$result;
	}
1304548
public function cannot($action, $resource = null, $resourceId = null)
    {
        $this->assertLockInstanceIsSet();

        return $this->lock->cannot($action, $resource, $resourceId);
    }
495832
public function isAction($action)
    {
        $isAction = parent::isAction($action);
        if ($isAction) {
            return true;
        }

        if ($this->_isActionMapped()) {
            return true;
        }

        return false;
    }
762020
protected function requireAuth($action) {
		if (isset ( $this->restCache ["authorizations"] )) {
			return array_search ( $action, $this->restCache ["authorizations"] ) !== false;
		}
		return false;
	}
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;
    }
523865
def ensure(user, action, subject):
    
    ability = Ability(user, get_authorization_method())
    if ability.cannot(action, subject):
        raise AccessDenied()
99569
public static function canAny($action, $objectType)
    {
        if (!isset($_SESSION['ACL_INFO'])) {
            return false;
        };
        $acl = $_SESSION['ACL_INFO'];
        foreach (array('*', $action) as $act) {
            if (array_key_exists($act, $acl)) {
                $acl2 = $acl[$act];
                foreach (array('*', $objectType) as $typ) {
                    if (array_key_exists($typ, $acl2)) {
                        foreach ($acl2[$typ] as $id) {
                            return true;
                        };
                    };
                };
            };
        };
        return false;
    }
393550
protected function setAuthorizer($user)
	{
		if($user !== false && $this->authorizer !== null && $user instanceof AuthorizableInterface)
		{
			$user->setAuthorizer($this->authorizer);
		}

		return $user;
	}
1170009
private function isAllowedAction(Action $action): bool
    {
        if ($this->owner instanceof Module) {
            $ownerId = $this->owner->getUniqueId();
            $id = $action->getUniqueId();
            if (!empty($ownerId) && strpos($id, $ownerId . '/') === 0) {
                $id = substr($id, strlen($ownerId) + 1);
            }
        } else {
            $id = $action->id;
        }

        foreach ($this->allowActions as $route) {
            if (substr($route, -1) === '*') {
                $route = rtrim($route, '*');
                if ($route === '' || strpos($id, $route) === 0) {
                    return true;
                }
            } else {
                if ($id === $route) {
                    return true;
                }
            }
        }

        return false;
    }
37642
private function roles(Response $response, User $user)
    {
        try {
            return $this->injector->getInstance(AuthorizationProvider::class)
                    ->roles($user);
        } catch (AuthProviderException $ahe) {
            $this->handleAuthProviderException($ahe, $response);
            return null;
        }
    }
905009
private function hasPermission(AuthenticatedUserInterface $user, string $uri) {

        // Collect permissions
        $permissions = $this->getParameterByKey("permissions");

        // Iterate over permission
        foreach ($permissions as $permissionPath => $acceptableRoles) {
            if($permissionPath[0] !== "/") {
                $permissionPath = "/".$permissionPath;
            }
            if(substr($permissionPath,-1) !== "/") {
                $permissionPath = $permissionPath."/";
            }
            $match = preg_match($permissionPath,$uri);
            if ($match == 1) {
                if(in_array(Role::ANON_USER,$acceptableRoles)) return true;
                foreach ($acceptableRoles as $permissionRole) {
                    if(in_array($permissionRole,$user->getRoles())) return true;
                }
                return false;
            }
        }
        return false;
    }
1223419
public function isGranted($resource, $action = 'view')
    {
        return $this->aclOperator->isAccessGranted($resource, $this->getPermission($action));
    }
1350022
protected function resolvePermissions($action, Resource $resource)
    {
        $permissions = $this->getInheritedRolePermissions($this->role);

        // Search for restrictions in the permissions. We'll do this first
        // because restrictions should override any privileges.
        if (! $this->resolveRestrictions($permissions, $action, $resource)) {
            return false;
        }

        // If there are restrictions on the roles but caller specific privileges are set, allow this to pass.
        return $this->resolvePrivileges($permissions, $action, $resource);
    }
822689
protected function checkAuth($action,$resource)
	{
		return true; // remove after testing
		try {
			$userModel  = new User();
			$auth       = new BasicAuthenticator($userModel);
			$user       = $auth->currentUser();
			if ($user instanceof UserInterface) {
				$authorizer = new Authorizer( $user );
				$result     = $authorizer->can( $action, $resource );
			} else {
				$result = false;
			}
		} catch (\Exception $e) {
			\error_log($e->getMessage());
			$result = false;
		}
		return $result;
	}
325203
public function hasPermissionTo($action)
    {
        return $this->allPermissions->has(
            function($permission) use ($action) {
                return $permission->action == $action;
            }
        );
    }
349545
protected function checkThrottling($action, UserInterface $user = null)
    {
        // If we are just checking an existing logged in person, the global delay
        // shouldn't stop them being logged in at all. Only their IP address and
        // user a
        if ($action === 'login') {
            $globalDelay = $this->throttle->globalDelay();

            if ($globalDelay > 0) {
                $this->throwException("Too many unsuccessful attempts have been made globally, logins are locked for another [{$globalDelay}] second(s).", 'global', $globalDelay);
            }
        }

        // Suspicious activity from a single IP address will not only lock
        // logins but also any logged in users from that IP address. This
        // should deter a single hacker who may have guessed a password
        // within the configured throttling limit.
        if (isset($this->ipAddress)) {
            $ipDelay = $this->throttle->ipDelay($this->ipAddress);

            if ($ipDelay > 0) {
                $this->throwException("Suspicious activity has occured on your IP address and you have been denied access for another [{$ipDelay}] second(s).", 'ip', $ipDelay);
            }
        }

        // We will only suspend people logging into a user account. This will
        // leave the logged in user unaffected. Picture a famous person who's
        // account is being locked as they're logged in, purely because
        // others are trying to hack it.
        if ($action === 'login' && isset($user)) {
            $userDelay = $this->throttle->userDelay($user);

            if ($userDelay > 0) {
                $this->throwException("Too many unsuccessful login attempts have been made against your account. Please try again after another [{$userDelay}] second(s).", 'user', $userDelay);
            }
        }

        return true;
    }