Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #26787 [Security] Make security.providers optional (MatTheCat)
This PR was squashed before being merged into the 4.1-dev branch (closes #26787). Discussion ---------- [Security] Make security.providers optional | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21998 | License | MIT Don't really know if it's viable but I just hit #21998 so I would like to tackle this. Commits ------- ee54bfa [Security] Make security.providers optional
- Loading branch information
Showing
9 changed files
with
138 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ityBundle/Tests/Functional/Bundle/MissingUserProviderBundle/MissingUserProviderBundle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\MissingUserProviderBundle; | ||
|
||
use Symfony\Component\HttpKernel\Bundle\Bundle; | ||
|
||
class MissingUserProviderBundle extends Bundle | ||
{ | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Symfony/Bundle/SecurityBundle/Tests/Functional/MissingUserProviderTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Bundle\SecurityBundle\Tests\Functional; | ||
|
||
class MissingUserProviderTest extends WebTestCase | ||
{ | ||
/** | ||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException | ||
* @expectedExceptionMessage "default" firewall requires a user provider but none was defined. | ||
*/ | ||
public function testUserProviderIsNeeded() | ||
{ | ||
$client = $this->createClient(array('test_case' => 'MissingUserProvider', 'root_config' => 'config.yml')); | ||
|
||
$client->request('GET', '/', array(), array(), array( | ||
'PHP_AUTH_USER' => 'username', | ||
'PHP_AUTH_PW' => 'pa$$word', | ||
)); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/MissingUserProvider/bundles.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
use Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\MissingUserProviderBundle\MissingUserProviderBundle; | ||
use Symfony\Bundle\SecurityBundle\SecurityBundle; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
|
||
return array( | ||
new FrameworkBundle(), | ||
new SecurityBundle(), | ||
new MissingUserProviderBundle(), | ||
); |
7 changes: 7 additions & 0 deletions
7
src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/MissingUserProvider/config.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
imports: | ||
- { resource: ./../config/framework.yml } | ||
|
||
security: | ||
firewalls: | ||
default: | ||
http_basic: ~ |
2 changes: 2 additions & 0 deletions
2
src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/MissingUserProvider/routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
home: | ||
path: / |
55 changes: 55 additions & 0 deletions
55
src/Symfony/Component/Security/Core/User/MissingUserProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\Security\Core\User; | ||
|
||
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException; | ||
|
||
/** | ||
* MissingUserProvider is a dummy user provider used to throw proper exception | ||
* when a firewall requires a user provider but none was defined. | ||
* | ||
* @internal | ||
*/ | ||
class MissingUserProvider implements UserProviderInterface | ||
{ | ||
/** | ||
* @param string $firewall the firewall missing a provider | ||
*/ | ||
public function __construct(string $firewall) | ||
{ | ||
throw new InvalidConfigurationException(sprintf('"%s" firewall requires a user provider but none was defined.', $firewall)); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function loadUserByUsername($username) | ||
{ | ||
throw new \BadMethodCallException(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function refreshUser(UserInterface $user) | ||
{ | ||
throw new \BadMethodCallException(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function supportsClass($class) | ||
{ | ||
throw new \BadMethodCallException(); | ||
} | ||
} |