8000 [SecurityBundle] Allow for custom request matchers by ro0NL · Pull Request #20272 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[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

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
poc
  • Loading branch information
ro0NL committed Oct 22, 2016
commit cdc2f9586cd69eb8845e9e8bb0964e37ae72202c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ private function addAccessControlSection(ArrayNodeDefinition $rootNode)
->prototype('array')
->fixXmlConfig('ip')
->fixXmlConfig('method')
->fixXmlConfig('role')
->children()
->scalarNode('matcher')->defaultNUll()->end()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defaultNUll should be defaultNull 😄

->scalarNode('requires_channel')->defaultNull()->end()
->scalarNode('path')
->defaultNull()
Expand All @@ -180,9 +182,6 @@ private function addAccessControlSection(ArrayNodeDefinition $rootNode)
->prototype('scalar')->end()
->end()
->scalarNode('allow_if')->defaultNull()->end()
Copy link
Member

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

->end()
->fixXmlConfig('role')
->children()
->arrayNode('roles')
->beforeNormalization()->ifString()->then(function ($v) { return preg_split('/\s*,\s*/', $v); })->end()
->prototype('scalar')->end()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the currently created matcher is configured by many props in $access. Thus, is this extension point really enough when you don't give it these parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 matcher|<combination of other keys>.

DX-wise i think - { route: foo, roles: [] } is best and probably same for firewalls? (using an array of routes).

As goes for - { expression: foo }. But that could work counter-intuitive with allow_if.

} else {
$matcher = $this->createRequestMatcher($container, $access['path'], $access['host'], $access['methods'], $access['ips']);
}

$attributes = $access['roles'];
if ($access['allow_if']) {
Expand Down
0