Compare the user's entitlements to one or more entitlements for authorizing access in an application.

@param mixed $authZ

@return bool
976980
public function isAuthorized($authZ)
    {
        // We have a list of entitlements to check against.
        if (is_array($authZ)) {
            foreach ($authZ as $currentAuthZ) {
                if ($this->checkEntitlement($currentAuthZ)) {
                    return true;
                }
            }
        } else {
            return $this->checkEntitlement($authZ);
        }

        return false;
    }
1044696
public function auth(string $requestHandler, ServerRequestInterface $request): bool
    {
        throw new AuthException(ErrorCode::POST_DATA_NOT_PROVIDED, sprintf('AuthUserService::auth() method should be implemented in %s', static::class));
    }
755005
private function assertAuthSite($authSite)
    {
        if (!array_key_exists($authSite, $this->authSites)) {
            $validValues = array_keys($this->authSites);
            $validValues = implode(', ', $validValues);
            $template = 'Valid values for authSite are only: %s';
            $message = sprintf($template, $validValues);
            throw new InvalidArgumentException($message);
        }
    }
953849
public function hasAccess(User $user, $controller, $action, $requestParameters) {
        $required = array();
        try {
            // $rights = ServiceManager::getServiceManager()->get(RouteAnnotationService::SERVICE_ID)->getRights($controller, $action);
            // todo use $rights when PHPDoc Annotations will be moved to the Doctrines annotations
            $requiredRights = ControllerHelper::getRequiredRights($controller, $action);
            $uris = $this->extractAndGroupUriFromParameters($requestParameters, array_keys($requiredRights));

            foreach($uris as $name => $urisValue) {
                $required[] = array_fill_keys($urisValue, $requiredRights[$name]);
            }
        } catch (ActionNotFoundException $e) {
            // action not found, no access
            return false;
        }
        
        return empty($required)
            ? true
            : $this->hasPrivileges($user, array_merge(...$required));
    }
757589
private function isUserConflict(EzUser $user, TokenInterface $previousToken = null)
    {
        if ($previousToken === null || !$previousToken instanceof UsernamePasswordToken) {
            return false;
        }

        $previousUser = $previousToken->getUser();
        if (!$previousUser instanceof EzUser) {
            return false;
        }

        $wasAnonymous = $previousUser->getAPIUser()->getUserId() == $this->configResolver->getParameter('anonymous_user_id');
        // TODO: isEqualTo is not on the interface
        return !$wasAnonymous && !$user->isEqualTo($previousUser);
    }
578895
public function forAuthorization()
    {
        $this->router->group(['middleware' => ['web', 'auth']], function ($router) {
            $router->get('/authorize', [
                'uses' => 'AuthorizationController@authorize',
            ]);

            $router->post('/authorize', [
                'uses' => 'ApproveAuthorizationController@approve',
            ]);

            $router->delete('/authorize', [
                'uses' => 'DenyAuthorizationController@deny',
            ]);
        });
    }
87113
protected function approveRequest($authRequest, $user)
    {
        $authRequest->setUser(new User($user->getKey()));

        $authRequest->setAuthorizationApproved(true);

        return $this->convertResponse(
            $this->server->completeAuthorizationRequest($authRequest, new Psr7Response)
        );
    }
202931
private function isAccessAuthorized($uri)
    {
        foreach ($this->forbiddenUriPatterns as $forbiddenUriPattern)
        {
            if (preg_match("@$forbiddenUriPattern@", $uri))
            {
                return false;
            }
        }
        return true;
    }
206840
public function authorize()
    {
        $response = $this->client->b2AuthorizeAccount();
        if ($response->isOk()) {
            $this->apiURL = $response->get('apiUrl');
            $this->token = $response->get('authorizationToken');
            $this->downloadURL = $response->get('downloadUrl');
            $this->minimumPartSize = $response->get('minimumPartSize');

            return true;
        }

        return false;
    }
325227
public function matchFull($permissions, array $authzGroups)
    {
        $privileges = [];

        foreach ($permissions as $permissionAuthzGroup => $permissionPrivileges) {
            $matchingAuthzGroup = $this->getMatchingAuthzGroup($permissionAuthzGroup, $authzGroups);
            
            if (!$matchingAuthzGroup) {
                continue;
            }
            
            $privileges = $this->addAuthzGroupsToPrivileges($privileges, $permissionPrivileges, [
                $permissionAuthzGroup, $matchingAuthzGroup
            ]);
        }

        return $privileges;
    }
1246022
final public function getAuthority()
    {

        $self = $this;
        $auth = $self->get("handler", "auth");

        //$authority = \Platform\Authorize::getInstance();

        if (is_a($auth, Authenticate::class)) {
            if (isset($auth->authenticated)) {
                //Read Rights if we have a userId
                //$self->authority = $authority->getPermissions($auth);
            }
        }

        //return $self->authority;
    }
134537
public function authorize(Request $request): bool
    {
        try {
            $subscriber = $this->storage->subscriberByRequest(
                $request->input(),
                $request->headers->all()
            );

            if (! $subscriber) {
                return false;
            }

            $subscriptions = $this->registry->subscriptions($subscriber);

            if ($subscriptions->isEmpty()) {
                return false;
            }

            $authorized = $subscriptions->reduce(
                function ($authorized, GraphQLSubscription $subscription) use ($subscriber, $request): bool {
                    return $authorized === false
                        ? false
                        : $subscription->authorize($subscriber, $request);
                }
            );

            if (! $authorized) {
                $this->storage->deleteSubscriber($subscriber->channel);
            }

            return $authorized;
        } catch (Exception $e) {
            $this->exceptionHandler->handleAuthError($e);

            return false;
        }
    }
1011518
public static function canEdit()
    {
		// Get current user
		$user = eZUser::currentUser();
		$user_has_access = $user->hasAccessTo( 'userpaex', 'editpaex' );

		if ( $user_has_access['accessWord'] == "yes" )
            return true;

        return false;
    }
186909
public function isAuthorized($user = null) {
        if (!$user) {
            throw new ForbiddenException(__d('admin', 'Invalid User'));
        }

        $aro = Admin::introspectModel('Admin.RequestObject');

        if ($aro->isAdmin($user['id'])) {
            if (!$this->Session->read('Admin.crud')) {
                $this->Session->write('Admin.crud', $aro->getCrudPermissions($user['id']));
            }

            return true;
        }

        throw new UnauthorizedException(__d('admin', 'Insufficient Access Permissions'));
    }
1187066
public function auth($auth = true)
    {
        $headers = $this->headers();
        if ($auth === false) {
            unset($headers['Authorization']);
        }
        if (!$auth) {
            return;
        }
        if (is_array($auth) && !empty($auth['nonce'])) {
            $data = ['method' => $this->method(), 'uri' => $this->path()];
            $data += $auth;
        } else {
            $data = [];
        }
        $auth = $this->_classes['auth'];
        $data = $auth::encode($this->username(), $this->password(), $data);
        $headers['Authorization'] = $auth::header($data);
        return $this;
    }
872840
function get($authId)
    {
        if (isset($this->users[$authId])) {
            return $this->users[$authId];
        } else {
            return false;
        }
    }
1286028
public function checkAccessToken($access_token = null)
    {
        $token = is_null($access_token) ? $this->access_token : $access_token;
        if (is_null($token)) return false;

        $rs = $this->api('getUserSettings', array('access_token' => $token));
        return isset($rs['response']);
    }