checkRequestPath() public method

Checks that a given path matches the Request.
public checkRequestPath ( Request $request, string $path ) : boolean
$request Symfony\Component\HttpFoundation\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
コード例 #1
0
 /**
  * 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);
         }
     }
 }
コード例 #2
0
 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'));
 }
コード例 #3
0
 /**
  * @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;
 }
コード例 #4
0
 /**
  * {@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;
 }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
ファイル: HttpUtilsTest.php プロジェクト: laubosslink/lab
 /**
  * @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');
 }
コード例 #7
0
 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'));
 }
コード例 #8
0
ファイル: HttpUtils.php プロジェクト: Pixy/ezpublish-kernel
 public function checkRequestPath(Request $request, $path)
 {
     return parent::checkRequestPath($request, $this->analyzeLink($path));
 }
コード例 #9
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @return bool
  */
 public function supports(Request $request)
 {
     return $this->httpUtils->checkRequestPath($request, $request->attributes->get('oauth_callback_path'));
 }