forked from symfony/symfony-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
[Cookbook/security] Added missing formats #7
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -354,13 +354,13 @@ to service ids that do not exist yet: ``wsse.security.authentication.provider`` | |
|
||
# src/Acme/DemoBundle/Resources/config/services.yml | ||
services: | ||
wsse.security.authentication.provider: | ||
class: Acme\DemoBundle\Security\Authentication\Provider\WsseProvider | ||
arguments: ['', %kernel.cache_dir%/security/nonces] | ||
wsse.security.authentication.provider: | ||
class: Acme\DemoBundle\Security\Authentication\Provider\WsseProvider | ||
arguments: ['', %kernel.cache_dir%/security/nonces] | ||
|
||
wsse.security.authentication.listener: | ||
class: Acme\DemoBundle\Security\Firewall\WsseListener | ||
arguments: [@security.context, @security.authentication.manager] | ||
wsse.security.authentication.listener: | ||
class: Acme\DemoBundle\Security\Firewall\WsseListener | ||
arguments: [@security.context, @security.authentication.manager] | ||
|
||
|
||
.. code-block:: xml | ||
|
@@ -370,19 +370,19 @@ to service ids that do not exist yet: ``wsse.security.authentication.provider`` | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
||
<services> | ||
<service id="wsse.security.authentication.provider" | ||
class="Acme\DemoBundle\Security\Authentication\Provider\WsseProvider" public="false"> | ||
<argument /> <!-- User Provider --> | ||
<argument>%kernel.cache_dir%/security/nonces</argument> | ||
</service> | ||
|
||
<service id="wsse.security.authentication.listener" | ||
class="Acme\DemoBundle\Security\Firewall\WsseListener" public="false"> | ||
<argument type="service" id="security.context"/> | ||
<argument type="service" id="security.authentication.manager" /> | ||
</service> | ||
</services> | ||
<services> | ||
<service id="wsse.security.authentication.provider" | ||
class="Acme\DemoBundle\Security\Authentication\Provider\WsseProvider" public="false"> | ||
<argument /> <!-- User Provider --> | ||
<argument>%kernel.cache_dir%/security/nonces</argument> | ||
</service> | ||
|
||
<service id="wsse.security.authentication.listener" | ||
class="Acme\DemoBundle\Security\Firewall\WsseListener" public="false"> | ||
<argument type="service" id="security.context"/> | ||
<argument type="service" id="security.authentication.manager" /> | ||
</service> | ||
</services> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
@@ -392,17 +392,22 @@ to service ids that do not exist yet: ``wsse.security.authentication.provider`` | |
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
$container->setDefinition('wsse.security.authentication.provider', | ||
new Definition( | ||
'Acme\DemoBundle\Security\Authentication\Provider\WsseProvider', | ||
array('', '%kernel.cache_dir%/security/nonces') | ||
)); | ||
new Definition( | ||
'Acme\DemoBundle\Security\Authentication\Provider\WsseProvider', array( | ||
'', | ||
'%kernel.cache_dir%/security/nonces', | ||
) | ||
) | ||
); | ||
|
||
$container->setDefinition('wsse.security.authentication.listener', | ||
new Definition( | ||
'Acme\DemoBundle\Security\Firewall\WsseListener', array( | ||
new Reference('security.context'), | ||
new Reference('security.authentication.manager')) | ||
)); | ||
new Definition( | ||
'Acme\DemoBundle\Security\Firewall\WsseListener', array( | ||
new Reference('security.context'), | ||
new Reference('security.authentication.manager'), | ||
) | ||
) | ||
); | ||
|
||
Now that your services are defined, tell your security context about your | ||
factory. Factories must be included in an individual configuration file, | ||
|
@@ -435,6 +440,20 @@ factory service, tagged as ``security.listener.factory``: | |
</services> | ||
</container> | ||
|
||
.. code-block:: php | ||
|
||
// src/Acme/DemoBundle/Resources/config/security_factories.php | ||
use Symfony\Component\DependencyInjection\Definition; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
$definition = new Definition('Acme\DemoBundle\DependencyInjection\Security\Factory\WsseFactory', array( | ||
'', | ||
'%kernel.cache_dir%/security/nonces', | ||
)); | ||
$definition->addTag('security.listener.factory'); | ||
|
||
$container->setDefinition('security.authentication.factory.wsse', $definition); | ||
|
||
Now, import the factory configuration via the the ``factories`` key in your | ||
security configuration: | ||
|
||
|
@@ -467,13 +486,36 @@ security configuration: | |
|
||
You are finished! You can now define parts of your app as under WSSE protection. | ||
|
||
.. code-block:: yaml | ||
.. configuration-block:: | ||
|
||
security: | ||
firewalls: | ||
wsse_secured: | ||
pattern: /api/.* | ||
wsse: true | ||
.. code-block:: yaml | ||
|
||
security: | ||
firewalls: | ||
wsse_secured: | ||
pattern: /api/.* | ||
wsse: true | ||
|
||
.. code-block:: xml | ||
|
||
<config> | ||
<firewall name="wsse_secured" | ||
pattern="/api/.*" | ||
wsse="true" | ||
/> | ||
</config> | ||
|
||
.. code-block:: php | ||
|
||
$container->loadFromExtension('security', array( | ||
'firewalls' => array( | ||
'wsse_secured' => array( | ||
'pattern' => '/api/.*', | ||
'wsse' => true, | ||
), | ||
), | ||
)); | ||
|
||
|
||
Congratulations! You have written your very own custom security authentication | ||
provider! | ||
|
@@ -546,13 +588,38 @@ in order to put it to use. | |
The lifetime of each wsse request is now configurable, and can be | ||
set to any desirable value per firewall. | ||
|
||
.. code-block:: yaml | ||
.. configuration-block:: | ||
|
||
.. code-block:: yaml | ||
|
||
security: | ||
firewalls: | ||
wsse_secured: | ||
pattern: /api/.* | ||
wsse: { lifetime: 30 } | ||
|
||
.. code-block:: xml | ||
|
||
<config> | ||
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. Same here, etc... |
||
<firewall name="wsse_secured" | ||
pattern="/api/.*" | ||
> | ||
<wsse lifetime="30" /> | ||
</firewall> | ||
</config> | ||
|
||
security: | ||
firewalls: | ||
wsse_secured: | ||
pattern: /api/.* | ||
wsse: { lifetime: 30 } | ||
.. code-block:: php | ||
|
||
$container->loadFromExtension('security', array( | ||
'firewalls' => array( | ||
'wsse_secured' => array( | ||
'pattern' => '/api/.*', | ||
'wsse' => array( | ||
'lifetime' => 30, | ||
), | ||
), | ||
), | ||
)); | ||
|
||
The rest is up to you! Any relevant configuration items can be defined | ||
in the factory and consumed or passed to the other classes in the container. | ||
|
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Isn't it <security:config> ?
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.
@ricardclau, as far as I know, the security file uses very rare XML elements which don't use namespaces. for instance, see this security configuration example
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.
Then http://symfony.com/doc/2.0/reference/configuration/security.html seems to be wrong... I am not 100% sure to be honest, I've always used YML for security config :)