-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[SecurityBundle] Allow for custom request matchers #20272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -195,13 +195,11 @@ private function createAuthorization($config, ContainerBuilder $container) | |
)); | ||
|
||
foreach ($config['access_control'] as $access) { | ||
$matcher = $this->createRequestMatcher( | ||
$container, | ||
$access['path'], | ||
$access['host'], | ||
$access['methods'], | ||
$access['ips'] | ||
); | ||
if (null !== $access['matcher']) { | ||
$matcher = new Reference($access['matcher']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the currently created matcher is configured by many props in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im not sure about the "right" approach here. Perhaps we should talk config/API first. But we could do DX-wise i think As goes for |
||
} else { | ||
$matcher = $this->createRequestMatcher($container, $access['path'], $access['host'], $access['methods'], $access['ips']); | ||
} | ||
|
||
$attributes = $access['roles']; | ||
if ($access['allow_if']) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\HttpFoundation; | ||
|
||
/** | ||
* @author Roland Franssen <[email protected]> | ||
*/ | ||
class ChainRequestMatcher implements RequestMatcherInterface | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this class related to this PR? It's not used anywhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope. It's outdate-ish. I moved it to #20274. |
||
{ | ||
private $matchers; | ||
|
||
/** | ||
* @param RequestMatcherInterface[] $matchers | ||
*/ | ||
public function __construct(array $matchers) | ||
{ | ||
$this->matchers = $matchers; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function matches(Request $request) | ||
{ | ||
foreach ($this->matchers as $matcher) { | ||
if (!$matcher->matches($request)) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this CS should be applied to a lower branch