@param Request $request

@return JsonResponse

@throws \Exception
@Route("/identities", name="accesscontrol_identities")
8912
public function identitiesAction(Request $request)
    {
        $objectType = $request->get('objectType');
        $objectId = $request->get('objectId', null);

        $objectIdentityResolver = $this->get('phlexible_access_control.object_identity_resolver');
        $objectIdentity = $objectIdentityResolver->resolve($objectType, $objectId);

        if (!$objectIdentity) {
            throw new \InvalidArgumentException("Unsupported object type $objectType");
        }

        $accessManager = $this->get('phlexible_access_control.access_manager');

        $acl = $accessManager->findAcl($objectIdentity);

        return new JsonResponse(array('identities' => $this->createIdentities($acl)));
    }
243216
protected function attemptAuthentication(Request $request)
    {
        $samlResponse = $this->receiveSamlResponse();

        $token = new SamlSpResponseToken($samlResponse, $this->providerKey);

        $token = $this->authenticationManager->authenticate($token);

        return $token;
    }
756468
public function signinAction(Request $request) {
        try {
            $data = $this->getAuthClientIdentifiers($request);

            // exports $client_id, $redirect_uri
            extract($data);

            if(!(($client = $this->clientProvider->getClient($client_id)) && $this->clientProvider->isValid($client, $redirect_uri))) {
                throw new SoauthException(sprintf('No client found with id %s', $client_id));
            }

            $data['client'] = $client;

            $this->info('> Sign in request', ['method' => $request->getMethod(), 'query' => $data]);
            $response = new Response($this->renderer->renderSignInForm($data));
        } catch (BadDataException $e) {
            $this->error('Bad Data Exception: ' . $e->getMessage(), ['errors' => $e->getErrors(), 'exception' => $e]);
            $response = $this->getBadRequestResponse();
        } catch (SoauthException $e) {
            $this->error('Soauth Exception: ' . $e->getMessage(), ['exception' => $e]);
            $response = $this->getBadRequestResponse();
        }

        $this->info('< Response', ['status_code' => $response->getStatusCode()]);
        return $response;
    }
145044
public function authorized(Request $request): JsonResponse
    {
        $channel = $request->input('channel_name');
        $socketId = $request->input('socket_id');
        $data = json_decode(
            $this->pusher->socket_auth($channel, $socketId),
            true
        );

        return response()->json($data, 200);
    }
310796
public function verify(Request $request)
    {
        if ($request->route('id') != $request->user()->getKey()) {
            throw new AuthorizationException();
        }

        if ($request->user()->hasVerifiedEmail()) {
            return redirect($this->redirectPath());
        }

        if ($request->user()->markEmailAsVerified()) {
            event(new Verified($request->user()));
        }

        return redirect($this->redirectPath())->with('verified', true);
    }
169800
public function callback(Request $request)
    {
        if ($request->has('error')) {
            switch ($request->get('error')) {
                case 'access_denied':
                    abort(401);
                    break;
                case 'temporarily_unavailable':
                    abort(503);
                    break;
                case 'invalid_request':
                case 'unauthorized_client':
                case 'unsupported_response_type':
                case 'invalid_scope':
                case 'server_error':
                default:
                    abort($request->server->get('REDIRECT_STATUS', 500));
                    break;
            }
        }

        $code = $request->get('code');
        $http = new Client();

        try {
            $response = $http->post(config('openid.server') . '/oauth/token', [
                'form_params' => [
                    'grant_type'    => 'authorization_code',
                    'client_id'     => config('openid.client.id'),
                    'client_secret' => config('openid.client.secret'),
                    'redirect_uri'  => route('openid.callback'),
                    'code'          => $code,
                ],
            ]);

            $this->checkError($response);
            $response = json_decode($response->getBody());

            session([
                'openid_token'  => $response->id_token,
                'access_token'  => $response->access_token,
                'refresh_token' => $response->refresh_token,
                'expires_at'    => Carbon::now()->addSeconds($response->expires_in),
            ]);
        } catch (\Exception $exception) {
            if ($exception instanceof ServerException || $exception instanceof ClientException) {
                $this->checkError($exception->getResponse());
            }

            abort($exception->getCode() !== 0 ? $exception->getCode() : 500);
        }

        return redirect()->intended();
    }
889255
public function authentication(Request $request)
    {
        try {
            $this->authRepositoryInterface->authenticate($request->all());
        } catch (FormValidationException $e) {
            Flash::error($e->getMessage());

            return redirect()
              ->route('auth.login')
              ->withErrors($e->getErrors());
        } catch (AuthenticationException $e) {
            Flash::error($e->getMessage());

            return redirect()->route('auth.login');
        }

        return redirect()->route('dashboard.index');
    }
1003458
public function listAction(Request $request)
    {
        $query = $this->addOrganizationFilter($request->query->all());

        return new JsonResponse($this->finder->search(
            $this->getClass(),
            $query,
            []
        ));
    }
449683
public function refreshAction(Request $request) {
        try {
            $refreshCode = $this->getRefreshCode($request);

            $clientSecret = $this->getClientSecret($request);
            $credentials = $this->accessProvider->refresh($request, $refreshCode, $clientSecret);

            $response = new JsonResponse([
                'access_code' => $credentials->getAccessCode(),
                'refresh_code' => $credentials->getRefreshCode(),
                'lifetime' => $credentials->getLifetime()
            ]);
        } catch (SoauthException $e) {
            $data = [];

            if($e instanceof BadDataException) {
                $data['errors'] = $e->getErrors();
            }

            $response = new JsonResponse($data, Response::HTTP_BAD_REQUEST);
        }

        $this->info('< Response', ['status_code' => $response->getStatusCode()]);

        return $response;
    }
734296
public function changeAction(Request $request)
    {
        $regionManager = $this->get('compo_region.manager.region');

        $currentRegion = $request->request->get('current_region', $regionManager->getCurrentRegion());

        $regionManager->setCurrentRegion($currentRegion);

        return new JsonResponse($currentRegion);
    }
1295867
public function clearPermissionsPageAction(Request $request)
    {
        $page = $request->attributes->get('uid');
        $group = $request->attributes->get('group');

        $aclManager = $this->getContainer()->get('security.acl_manager');
        $securityIdentity = new UserSecurityIdentity($group, 'BackBee\Security\Group');

        try{

            if(true === $page->isRoot()){

                try{
                    $aclManager->deleteClassAce(new ObjectIdentity('all', $page->getType()), $securityIdentity);
                }
                catch(\Exception $e){
                    // do nothing
                }
            }
            else{
                $aclManager->deleteObjectAce($page, $securityIdentity);
            }
        }
        catch (\Exception $e){
            // do nothing
        }

        return $this->createJsonResponse([], 200);
    }
523839
public function cgetAction(Request $request)
    {
        $checkForPermissions = $request->get('checkForPermissions', true);
        $locale = $this->getRequestParameter($request, 'locale', true);
        $webspaces = [];

        $securityChecker = $this->get('sulu_security.security_checker');
        foreach ($this->get('sulu_core.webspace.webspace_manager')->getWebspaceCollection() as $webspace) {
            if ($checkForPermissions) {
                $securityContext = $this->getSecurityContextByWebspace($webspace->getKey());
                if (!$securityChecker->hasPermission(new SecurityCondition($securityContext), PermissionTypes::VIEW)) {
                    continue;
                }
            }

            $webspaces[] = $webspace;
        }

        $context = new Context();
        $context->setAttribute('locale', $locale);
        $view = $this->view(new CollectionRepresentation($webspaces, 'webspaces'));
        $view->setContext($context);

        return $this->handleView($view);
    }
442552
public function deleteAction(Request $request)
    {
        try {
            $manager = $this->get('ongr_settings.settings_manager');
            $manager->delete($request->get('name'));

            return new JsonResponse(['error' => false]);
        } catch (\Exception $e) {
            return new JsonResponse(
                [
                    'error' => true,
                    'message' => 'Error occurred please try to delete setting again.'
                ]
            );
        }
    }
1024264
public function permissionsAction(Request $request)
    {
        $objectType = $request->get('objectType');

        $permissionRegistry = $this->get('phlexible_access_control.permission_registry');
        $permissions = array();
        foreach ($permissionRegistry->get($objectType)->all() as $permission) {
            $permissions[] = array(
                'name' => $permission->getName(),
                'bit' => $permission->getBit(),
                'iconCls' => 'null',
            );
        }

        return new JsonResponse(array('permissions' => $permissions));
    }
985209
public function searchAction(Request $request)
    {
        $this->denyAccessIfProfilerDisabled();

        $ip = preg_replace('/[^:\d\.]/', '', $request->query->get('ip'));
        $method = $request->query->get('method');
        $statusCode = $request->query->get('status_code');
        $url = $request->query->get('url');
        $start = $request->query->get('start', null);
        $end = $request->query->get('end', null);
        $limit = $request->query->get('limit');
        $token = $request->query->get('token');

        if ($request->hasSession()) {
            $session = $request->getSession();

            $session->set('_profiler_search_ip', $ip);
            $session->set('_profiler_search_method', $method);
            $session->set('_profiler_search_status_code', $statusCode);
            $session->set('_profiler_search_url', $url);
            $session->set('_profiler_search_start', $start);
            $session->set('_profiler_search_end', $end);
            $session->set('_profiler_search_limit', $limit);
            $session->set('_profiler_search_token', $token);
        }

        if (!empty($token)) {
            return new RedirectResponse($this->generator->generate('_profiler', ['token' => $token]), 302, ['Content-Type' => 'text/html']);
        }

        $tokens = $this->profiler->find($ip, $url, $limit, $method, $start, $end, $statusCode);

        return new RedirectResponse($this->generator->generate('_profiler_search_results', [
            'token' => $tokens ? $tokens[0]['token'] : 'empty',
            'ip' => $ip,
            'method' => $method,
            'status_code' => $statusCode,
            'url' => $url,
            'start' => $start,
            'end' => $end,
            'limit' => $limit,
        ]), 302, ['Content-Type' => 'text/html']);
    }
828043
public static function fromSymfonyRequest(Request $request) {
		if (!$request->headers->has('C-AAUID') || !$request->headers->has('C-Access-Token'))
			return null;

		$context = new AccountContext(
			new IRI('aauid:'.$request->headers->get('C-AAUID')),
			$request->headers->get('C-Access-Token'));

		$psr7Factory = new DiactorosFactory;
		$context->parsePsrRequest($psr7Factory->createRequest($request));

		return $context;
	}
675559
public function getOAuthCallbackAction(Request $request)
    {
        $this->initSessionBag();

        if ($request->query->get("state") != $this->sessionBag->get("hash")) {
            throw new UserException("Invalid session verification hash");
        }

        $guzzle = new GuzzleClient();
        try {
            $response = $guzzle->post($this->getTokenUrl(), array("body" => array(
                "client_id" => $this->getClientId(),
                "client_secret" => $this->getClientSecret(),
                "grant_type" => $this->grantType,
                "redirect_uri" => $this->getCallbackUrl($request),
                "code" => $request->query->get("code")
            )));
        } catch (ClientException $e) {
            $errCode = $e->getResponse()->getStatusCode();
            if ($errCode == 400) {
                $desc = jsonDecode($e->getResponse()->getBody(true), true);
                $code = empty($desc["code"]) ? 0 : $desc["code"];
                $message = empty($desc["error_message"]) ? "Unknown error from API." : $desc["error_message"];

                throw new UserException(
                    "OAuth authentication failed[{$code}]: {$message}",
                    null,
                    [
                        'response' => $e->getResponse()->getBody()
                    ]
                );
            } else {
                throw $e;
            }
        }

        $responseData = jsonDecode($response->getBody(true));

        $this->storeOAuthData($responseData);
        return $this->returnResult($responseData);
    }