Skip to content

Commit 80a0264

Browse files
committed
Merge branch '2.2'
Conflicts: components/http_foundation/trusting_proxies.rst cookbook/session/index.rst reference/dic_tags.rst
2 parents 27dbceb + 9766699 commit 80a0264

File tree

12 files changed

+112
-22
lines changed

12 files changed

+112
-22
lines changed

components/filesystem.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ Return the relative path of a directory given another one::
200200
'/var/lib/symfony/src/Symfony/Component'
201201
);
202202
// returns 'videos'
203-
$fs->makePathRelative('/tmp', '/tmp/videos');
203+
$fs->makePathRelative('/tmp/videos', '/tmp')
204204

205205
mirror
206206
~~~~~~

components/http_foundation/trusting_proxies.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ your proxy.
2323
use Symfony\Component\HttpFoundation\Request;
2424
2525
$request = Request::createFromGlobals();
26+
2627
// only trust proxy headers coming from this IP addresses
2728
$request->setTrustedProxies(array('192.0.0.1', '10.0.0.0/8'));
2829

cookbook/form/dynamic_form_modification.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ This can be used to get the ``SportMeetup`` id and retrieve it from the database
462462
given you have a reference to the object manager (if using doctrine). In
463463
the end, you have an event subscriber that listens to two different events,
464464
requires some external services and customizes the form. In such a situation,
465-
it's probably better to define this as a service rather than using an anonymouse
465+
it's probably better to define this as a service rather than using an anonymous
466466
function as the event listener callback.
467467

468468
The subscriber would now look like::

cookbook/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The Cookbook
1414
configuration/index
1515
serializer
1616
service_container/index
17+
session/index
1718
bundles/index
1819
email/index
1920
testing/index

cookbook/map.rst.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@
143143
* :doc:`/cookbook/service_container/scopes`
144144
* :doc:`/cookbook/service_container/compiler_passes`
145145

146+
* :doc:`/cookbook/session/index`
147+
148+
* :doc:`/cookbook/session/proxy_examples`
149+
146150
* **symfony1**
147151

148152
* :doc:`/cookbook/symfony1`

cookbook/session/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Sessions
55
:maxdepth: 2
66

77
php_bridge
8+
proxy_examples

cookbook/session/proxy_examples.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
.. index::
2+
single: Sessions, session proxy, proxy
3+
4+
Session Proxy Examples
5+
----------------------
6+
7+
The session proxy mechanism has a variety of uses and this example demonstrates
8+
two common uses. Rather than injecting the session handler as normal, a handler
9+
is injected into the proxy and registered with the session storage driver::
10+
11+
use Symfony\Component\HttpFoundation\Session\Session;
12+
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
13+
use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionStorage;
14+
15+
$proxy = new YourProxy(new PdoSessionStorage());
16+
$session = new Session(new NativeSessionStorage($proxy));
17+
18+
Below, you'll learn two real examples that can be used for ``YourProxy``:
19+
encryption of session data and readonly guest session.
20+
21+
Encryption of Session Data
22+
--------------------------
23+
24+
If you wanted to encrypt the session data, you could use the proxy to encrypt
25+
and decrypt the session as required::
26+
27+
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
28+
29+
class EncryptedSessionProxy extends SessionHandlerProxy
30+
{
31+
private $key;
32+
33+
public function __construct(\SessionHandlerInterface $handler, $key)
34+
{
35+
$this->key = $key;
36+
37+
parent::__construct($handler);
38+
}
39+
40+
public function read($id)
41+
{
42+
$data = parent::write($id, $data);
43+
44+
return mcrypt_decrypt(\MCRYPT_3DES, $this->key, $data);
45+
}
46+
47+
public function write($id, $data)
48+
{
49+
$data = mcrypt_encrypt(\MCRYPT_3DES, $this->key, $data);
50+
51+
return parent::write($id, $data);
52+
}
53+
}
54+
55+
Readonly Guest Sessions
56+
-----------------------
57+
58+
There are some applications where a session is required for guest users, but
59+
there is no particular need to persist the session. In this case you can
60+
intercept the session before it writes::
61+
62+
use Foo\User;
63+
use Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy;
64+
65+
class ReadOnlyGuestSessionProxy extends SessionHandlerProxy
66+
{
67+
private $user;
68+
69+
public function __construct(\SessionHandlerInterface $handler, User $user)
70+
{
71+
$this->user = $user;
72+
73+
parent::__construct($handler);
74+
}
75+
76+
public function write($id, $data)
77+
{
78+
if ($this->user->isGuest()) {
79+
return;
80+
}
81+
82+
return parent::write($id, $data);
83+
}
84+
}

reference/configuration/framework.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Configuration
2626
* enabled
2727
* field_name
2828
* `session`_
29+
* `name`_
2930
* `cookie_lifetime`_
3031
* `cookie_path`_
3132
* `cookie_domain`_
@@ -158,6 +159,14 @@ csrf_protection
158159
session
159160
~~~~~~~
160161

162+
name
163+
....
164+
165+
**type**: ``string`` **default**: ``null``
166+
167+
This specifies the name of the session cookie. By default it will use the cookie
168+
name which is defined in the ``php.ini`` with the ``session.name`` directive.
169+
161170
cookie_lifetime
162171
...............
163172

reference/constraints/CardScheme.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ on an object that will contain a credit card number.
3535
cardNumber:
3636
- CardScheme:
3737
schemes: [VISA]
38-
message: You credit card number is invalid.
38+
message: Your credit card number is invalid.
3939
4040
.. code-block:: xml
4141
@@ -46,7 +46,7 @@ on an object that will contain a credit card number.
4646
<option name="schemes">
4747
<value>VISA</value>
4848
</option>
49-
<option name="message">You credit card number is invalid.</option>
49+
<option name="message">Your credit card number is invalid.</option>
5050
</constraint>
5151
</property>
5252
</class>
@@ -61,7 +61,7 @@ on an object that will contain a credit card number.
6161
class Transaction
6262
{
6363
/**
64-
* @Assert\CardScheme(schemes = {"VISA"}, message = "You credit card number is invalid.")
64+
* @Assert\CardScheme(schemes = {"VISA"}, message = "Your credit card number is invalid.")
6565
*/
6666
protected $cardNumber;
6767
}
@@ -84,7 +84,7 @@ on an object that will contain a credit card number.
8484
'schemes' => array(
8585
'VISA'
8686
),
87-
'message' => 'You credit card number is invalid.',
87+
'message' => 'Your credit card number is invalid.',
8888
)));
8989
}
9090
}

reference/constraints/Range.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ the following:
4848
{
4949
/**
5050
* @Assert\Range(
51-
* min = "120",
52-
* max = "180",
51+
* min = 120,
52+
* max = 180,
5353
* minMessage = "You must be at least 120cm tall to enter",
5454
* maxMessage = "You cannot be taller than 180cm to enter"
5555
* )

reference/constraints/UserPassword.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ UserPassword
33

44
.. note::
55

6-
Since Symfony 2.2, the `UserPassword*` classes in the
7-
`Symfony\Component\Security\Core\Validator\Constraint` namespace are
6+
Since Symfony 2.2, the ``UserPassword*`` classes in the
7+
``Symfony\\Component\\Security\\Core\\Validator\\Constraint`` namespace are
88
deprecated and will be removed in Symfony 2.3. Please use the
9-
`UserPassword*` classes in the
10-
`Symfony\Component\Security\Core\Validator\Constraints` namespace instead.
9+
``UserPassword*`` classes in the
10+
``Symfony\\Component\\Security\\Core\\Validator\\Constraints`` namespace instead.
1111

1212
This validates that an input value is equal to the current authenticated
1313
user's password. This is useful in a form where a user can change his password,

reference/dic_tags.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ may also be tags in other bundles you use that aren't listed here.
5555
+-----------------------------------+---------------------------------------------------------------------------+
5656
| `security.remember_me_aware`_ | To allow remember me authentication |
5757
+-----------------------------------+---------------------------------------------------------------------------+
58-
| `security.listener.factory`_ | Necessary when creating a custom authentication system |
59-
+-----------------------------------+---------------------------------------------------------------------------+
6058
| `serializer.encoder`_ | Register a new encoder in the ``serializer`` service |
6159
+-----------------------------------+---------------------------------------------------------------------------+
6260
| `serializer.normalizer`_ | Register a new normalizer in the ``serializer`` service |
@@ -712,14 +710,6 @@ of your configuration, and tag it with ``routing.loader``:
712710
713711
For more information, see :doc:`/cookbook/routing/custom_route_loader`.
714712
715-
security.listener.factory
716-
-------------------------
717-
718-
**Purpose**: Necessary when creating a custom authentication system
719-
720-
This tag is used when creating your own custom authentication system. For
721-
details, see :doc:`/cookbook/security/custom_authentication_provider`.
722-
723713
security.remember_me_aware
724714
--------------------------
725715

0 commit comments

Comments
 (0)