Skip to content

Commit

Permalink
Merge branch '2.8' into 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Jan 18, 2016
2 parents 14d2afb + f792232 commit f31a965
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 45 deletions.
10 changes: 7 additions & 3 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1810,7 +1810,7 @@ The CSRF token can be customized on a form-by-form basis. For example::
'csrf_protection' => true,
'csrf_field_name' => '_token',
// a unique key to help generate the secret token
'intention' => 'task_item',
'csrf_token_id' => 'task_item',
));
}

Expand All @@ -1826,8 +1826,12 @@ section.

.. note::

The ``intention`` option is optional but greatly enhances the security of
the generated token by making it different for each form.
The ``csrf_token_id`` option is optional but greatly enhances the security
of the generated token by making it different for each form.

.. versionadded:: 2.4
The ``csrf_token_id`` option was introduced in Symfony 2.4. Prior, you
had to use the ``intention`` option.

.. caution::

Expand Down
73 changes: 73 additions & 0 deletions components/dependency_injection/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,79 @@ You can change the inner service name if you want to:
->setPublic(false)
->setDecoratedService('foo', 'bar.wooz');
.. versionadded:: 2.8
The ability to define the decoration priority was introduced in Symfony 2.8.
Prior to Symfony 2.8, the priority depends on the order in
which definitions are found.

If you want to apply more than one decorator to a service, you can control their
order by configuring the priority of decoration, this can be any integer number
(decorators with higher priorities will be applied first).

.. configuration-block::

.. code-block:: yaml
foo:
class: Foo
bar:
class: Bar
public: false
decorates: foo
decoration_priority: 5
arguments: ['@bar.inner']
baz:
class: Baz
public: false
decorates: foo
decoration_priority: 1
arguments: ['@baz.inner']
.. code-block:: xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
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="foo" class="Foo" />
<service id="bar" class="Bar" decorates="foo" decoration-priority="5" public="false">
<argument type="service" id="bar.inner" />
</service>
<service id="baz" class="Baz" decorates="foo" decoration-priority="1" public="false">
<argument type="service" id="baz.inner" />
</service>
</services>
</container>
.. code-block:: php
use Symfony\Component\DependencyInjection\Reference;
$container->register('foo', 'Foo')
$container->register('bar', 'Bar')
->addArgument(new Reference('bar.inner'))
->setPublic(false)
->setDecoratedService('foo', null, 5);
$container->register('baz', 'Baz')
->addArgument(new Reference('baz.inner'))
->setPublic(false)
->setDecoratedService('foo', null, 1);
The generated code will be the following:

.. code-block:: php
$this->services['foo'] = new Baz(new Bar(new Foo())));
Deprecating Services
--------------------

Expand Down
4 changes: 2 additions & 2 deletions components/expression_language/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Expression Language
===================
ExpressionLanguage
==================

.. toctree::
:maxdepth: 2
Expand Down
3 changes: 2 additions & 1 deletion components/form/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ builder:

.. code-block:: php-standalone
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\DateType;
Expand All @@ -461,7 +462,7 @@ builder:
'dueDate' => new \DateTime('tomorrow'),
);
$form = $formFactory->createBuilder('form', $defaults)
$form = $formFactory->createBuilder(FormType::class, $defaults)
->add('task', TextType::class)
->add('dueDate', DateType::class)
->getForm();
Expand Down
11 changes: 2 additions & 9 deletions components/http_foundation/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,22 +151,15 @@ exist::

When PHP imports the request query, it handles request parameters like
``foo[bar]=bar`` in a special way as it creates an array. So you can get the
``foo`` parameter and you will get back an array with a ``bar`` element. But
sometimes, you might want to get the value for the "original" parameter name:
``foo[bar]``. This is possible with all the ``ParameterBag`` getters like
:method:`Symfony\\Component\\HttpFoundation\\Request::get` via the third
argument::
``foo`` parameter and you will get back an array with a ``bar`` element::

// the query string is '?foo[bar]=bar'

$request->query->get('foo');
// returns array('bar' => 'bar')

$request->query->get('foo[bar]');
// returns null

$request->query->get('foo[bar]', null, true);
// returns 'bar'
// returns null

.. _component-foundation-attributes:

Expand Down
2 changes: 1 addition & 1 deletion cookbook/configuration/override_dir_structure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Override the ``cache`` Directory
--------------------------------

You can change the default cache directory by overriding the ``getCacheDir`` method
in the ``AppKernel`` class of you application::
in the ``AppKernel`` class of your application::

// app/AppKernel.php

Expand Down
5 changes: 0 additions & 5 deletions cookbook/controller/upload_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ Then, add a new ``brochure`` field to the form that manages the ``Product`` enti
'data_class' => 'AppBundle\Entity\Product',
));
}

public function getName()
{
return 'product';
}
}

Now, update the template that renders the form to display the new ``brochure``
Expand Down
4 changes: 2 additions & 2 deletions cookbook/form/create_form_type_extension.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ by your extension.
.. tip::

The value you return in the ``getExtendedType`` method corresponds
to the value returned by the ``getName`` method in the form type class
you wish to extend.
to the fully qualified class name of the form type class you wish to
extend.

In addition to the ``getExtendedType`` function, you will probably want
to override one of the following methods:
Expand Down
5 changes: 0 additions & 5 deletions cookbook/form/dynamic_form_modification.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,6 @@ a bare form class looks like::
'data_class' => 'AppBundle\Entity\Product'
));
}

public function getName()
{
return 'product';
}
}

.. note::
Expand Down
4 changes: 2 additions & 2 deletions cookbook/form/form_customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,8 @@ will be able to change the widget for each task as follows:

{% block _tasks_entry_widget %}
<tr>
<td>{{ form_widget(task.task) }}</td>
<td>{{ form_widget(task.dueDate) }}</td>
<td>{{ form_widget(form.task) }}</td>
<td>{{ form_widget(form.dueDate) }}</td>
</tr>
{% endblock %}

Expand Down
4 changes: 2 additions & 2 deletions cookbook/profiler/data_collector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ block and set the value of two variables called ``icon`` and ``text``:
{% endset %}

{# the 'link' value set to 'false' means that this panel doesn't
show a section in the web profiler (default is 'true'). #}
show a section in the web profiler #}
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { link: false }) }}
{% endblock %}

Expand Down Expand Up @@ -203,7 +203,7 @@ must also define additional blocks:
</div>
{% endset %}

{{ include('@WebProfiler/Profiler/toolbar_item.html.twig') }}
{{ include('@WebProfiler/Profiler/toolbar_item.html.twig', { 'link': true }) }}
{% endblock %}

{% block head %}
Expand Down
8 changes: 8 additions & 0 deletions cookbook/security/acl_advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ Security Identities
This is analog to the object identity, but represents a user, or a role in
your application. Each role, or user has its own security identity.

.. caution::

For users, the security identity is based on the username. This means that,
if for any reason, a user's username was to change, you must ensure its
security identity is updated too. The
:method:`MutableAclProvider::updateUserSecurityIdentity() <Symfony\\Component\\Security\\Acl\\Dbal\\MutableAclProvider::updateUserSecurityIdentity>`
method is there to handle the update.

Database Table Structure
------------------------

Expand Down
22 changes: 15 additions & 7 deletions cookbook/security/csrf_in_login_form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ provider available in the Security component:
# ...
form_login:
# ...
csrf_provider: security.csrf.token_manager
csrf_token_generator: security.csrf.token_manager
.. code-block:: xml
Expand All @@ -50,7 +50,7 @@ provider available in the Security component:
<firewall name="secured_area">
<!-- ... -->
<form-login csrf-provider="security.csrf.token_manager" />
<form-login csrf-token-generator="security.csrf.token_manager" />
</firewall>
</config>
</srv:container>
Expand All @@ -66,12 +66,16 @@ provider available in the Security component:
// ...
'form_login' => array(
// ...
'csrf_provider' => 'security.csrf.token_manager',
'csrf_token_generator' => 'security.csrf.token_manager',
),
),
),
));
.. versionadded:: 2.4
The ``csrf_token_generator`` option was introduced in Symfony 2.4. Prior,
you had to use the ``csrf_provider`` option.

The Security component can be configured further, but this is all information
it needs to be able to use CSRF in the login form.

Expand Down Expand Up @@ -124,7 +128,7 @@ After this, you have protected your login form against CSRF attacks.
.. tip::

You can change the name of the field by setting ``csrf_parameter`` and change
the token ID by setting ``intention`` in your configuration:
the token ID by setting ``csrf_token_id`` in your configuration:

.. configuration-block::

Expand All @@ -140,7 +144,7 @@ After this, you have protected your login form against CSRF attacks.
form_login:
# ...
csrf_parameter: _csrf_security_token
intention: a_private_string
csrf_token_id: a_private_string
.. code-block:: xml
Expand All @@ -158,7 +162,7 @@ After this, you have protected your login form against CSRF attacks.
<firewall name="secured_area">
<!-- ... -->
<form-login csrf-parameter="_csrf_security_token"
intention="a_private_string"
csrf-token-id="a_private_string"
/>
</firewall>
</config>
Expand All @@ -176,11 +180,15 @@ After this, you have protected your login form against CSRF attacks.
'form_login' => array(
// ...
'csrf_parameter' => '_csrf_security_token',
'intention' => 'a_private_string',
'csrf_token_id' => 'a_private_string'
),
),
),
));
.. versionadded:: 2.4
The ``csrf_token_id`` option was introduced in Symfony 2.4. Prior, you
had to use the ``intention`` option.

.. _`Cross-site request forgery`: https://en.wikipedia.org/wiki/Cross-site_request_forgery
.. _`Forging Login Requests`: https://en.wikipedia.org/wiki/Cross-site_request_forgery#Forging_login_requests
2 changes: 1 addition & 1 deletion cookbook/security/guard-authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ Each authenticator needs the following methods:
object that should be sent to the client. The ``$exception`` will tell you
*what* went wrong during authentication.

**start**
**start(Request $request, AuthenticationException $authException = null)**
This is called if the client accesses a URI/resource that requires authentication,
but no authentication details were sent (i.e. you returned ``null`` from
``getCredentials()``). Your job is to return a
Expand Down
10 changes: 5 additions & 5 deletions reference/configuration/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ Each part will be explained in the next section.
password_parameter: _password
# csrf token options
csrf_parameter: _csrf_token
intention: authenticate
csrf_provider: my.csrf_provider.id
csrf_parameter: _csrf_token
csrf_token_id: authenticate
csrf_token_generator: my.csrf_token_generator.id
# by default, the login form *must* be a POST, not a GET
post_only: true
Expand Down Expand Up @@ -209,8 +209,8 @@ Each part will be explained in the next section.
context: ~
logout:
csrf_parameter: _csrf_token
csrf_provider: ~
intention: logout
csrf_token_generator: ~
csrf_token_id: logout
path: /logout
target: /
success_handler: ~
Expand Down

0 comments on commit f31a965

Please sign in to comment.