Checks that a given path matches the Request.
public checkRequestPath ( |
||
$request | A Request instance | |
$path | string | A path (an absolute path (/foo), an absolute URL (http://...), or a route name (foo)) |
return | boolean | true if the path is the same as the one from the Request, false otherwise |
/** * Gets the appropriate resource owner for a request. * * @param Request $request * * @return null|array */ public function getResourceOwnerByRequest(Request $request) { foreach ($this->resourceOwners as $name => $checkPath) { if ($this->httpUtils->checkRequestPath($request, $checkPath)) { return array($this->getResourceOwnerByName($name), $checkPath); } } }
public function testCheckRequestPath() { $utils = new HttpUtils($this->getUrlGenerator()); $this->assertTrue($utils->checkRequestPath($this->getRequest(), '/')); $this->assertFalse($utils->checkRequestPath($this->getRequest(), '/foo')); $this->assertFalse($utils->checkRequestPath($this->getRequest(), 'foobar')); $this->assertTrue($utils->checkRequestPath($this->getRequest('/foo/bar'), 'foobar')); }
/** * @param \Symfony\Component\HttpFoundation\Request $request * @return bool */ public function supports(Request $request) { if ($this->httpUtils->checkRequestPath($request, $request->attributes->get('failure_path'))) { return false; } $token = $this->securityContext->getToken(); $result = $token != null && $token->isAuthenticated() && $token instanceof SamlSpToken && $token->getSamlSpInfo() != null && $token->getSamlSpInfo()->getAuthnStatement() != null; return $result; }
/** * {@inheritDoc} */ public function start(Request $request, AuthenticationException $authException = null) { if (!$this->httpUtils->checkRequestPath($request, $this->checkPath)) { if ($this->httpUtils->checkRequestPath($request, $this->loginPath)) { $request->getSession()->remove('_security.target_path'); } $authorizationUrl = $this->oauthProvider->getAuthorizationUrl($request); return $this->httpUtils->createRedirectResponse($request, $authorizationUrl); } throw $authException; }
public function onFilterController(FilterControllerEvent $event) { if (!$this->shouldCheckTerms($event)) { return; } $request = $event->getRequest(); if ($this->httpUtils->checkRequestPath($request, 'tos_agree') || $this->httpUtils->checkRequestPath($request, 'tos_terms') || $request->attributes->get('_controller') == 'LoginCidadaoTOSBundle:Agreement' || $request->attributes->get('_controller') == 'LoginCidadaoTOSBundle:TermsOfService:showLatest' || $event->getRequestType() === HttpKernelInterface::SUB_REQUEST) { return; } $user = $this->securityContext->getToken()->getUser(); if (!$this->termsManager->hasAgreedToLatestTerms($user)) { throw new TermsNotAgreedException(); } }
/** * @expectedException \RuntimeException */ public function testCheckRequestPathWithRouterLoadingException() { $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface'); $router->expects($this->any())->method('match')->will($this->throwException(new \RuntimeException())); $utils = new HttpUtils($router); $utils->checkRequestPath($this->getRequest(), 'foobar'); }
public function testCheckRequestPath() { $utils = new HttpUtils($this->getRouter()); $this->assertTrue($utils->checkRequestPath($this->getRequest(), '/')); $this->assertFalse($utils->checkRequestPath($this->getRequest(), '/foo')); $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface'); $router->expects($this->any())->method('match')->will($this->returnValue(array())); $utils = new HttpUtils($router); $this->assertFalse($utils->checkRequestPath($this->getRequest(), 'foobar')); $router = $this->getMock('Symfony\\Component\\Routing\\RouterInterface'); $router->expects($this->any())->method('match')->will($this->returnValue(array('_route' => 'foobar'))); $utils = new HttpUtils($router); $this->assertTrue($utils->checkRequestPath($this->getRequest('/foo/bar'), 'foobar')); }
public function checkRequestPath(Request $request, $path) { return parent::checkRequestPath($request, $this->analyzeLink($path)); }
/** * @param \Symfony\Component\HttpFoundation\Request $request * @return bool */ public function supports(Request $request) { return $this->httpUtils->checkRequestPath($request, $request->attributes->get('oauth_callback_path')); }