Skip to content

Commit 5b65654

Browse files
committed
feature #3912 [Security] Added remote_user firewall info and documentation for pre authenticated firewalls (Maxime Douailin, mdouailin)
This PR was merged into the master branch. Discussion ---------- [Security] Added remote_user firewall info and documentation for pre authenticated firewalls | Q | A | ------------- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#10698) | Applies to | 2.6+ | Fixed tickets | no Some documentation for pre authenticated firewalls, and added remote_user configuration reference for this new firewall. Commits ------- f36c45e uppercase title e6aa733 swapped comment and opening in xml configuration example b8a0eb2 fixes missing backtick be0d866 fix missing backtick, rephrased bottom note 86ba188 rebased using x509 pr, added remote_user pre authenticated part 8465d46 [Reference][Configuration] Removed version added for remote_user 34ad1b5 [Security] Added remote_user firewall info and documentation for pre authenticated firewalls
2 parents 10e6f05 + f36c45e commit 5b65654

File tree

2 files changed

+71
-4
lines changed

2 files changed

+71
-4
lines changed

cookbook/security/pre_authenticated.rst

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ Enable the x509 authentication for a particular firewall in the security configu
3434
3535
.. code-block:: xml
3636
37-
<?xml version="1.0" ?>
3837
<!-- app/config/security.xml -->
38+
<?xml version="1.0" ?>
3939
<srv:container xmlns="http://symfony.com/schema/dic/security"
4040
xmlns:srv="http://symfony.com/schema/dic/services">
4141
@@ -66,14 +66,79 @@ the user provider, and sets the ``SSL_CLIENT_S_DN`` as credentials in the
6666
You can override these by setting the ``user`` and the ``credentials`` keys
6767
in the x509 firewall configuration respectively.
6868

69+
.. _cookbook-security-pre-authenticated-user-provider-note:
70+
6971
.. note::
7072

7173
An authentication provider will only inform the user provider of the username
7274
that made the request. You will need to create (or use) a "user provider" that
7375
is referenced by the ``provider`` configuration parameter (``your_user_provider``
74-
in the configuration example). This provider will turn the username into a User
75-
object of your choice. For more information on creating or configuring a user
76+
in the configuration example). This provider will turn the username into a User
77+
object of your choice. For more information on creating or configuring a user
7678
provider, see:
7779

7880
* :doc:`/cookbook/security/custom_provider`
79-
* :doc:`/cookbook/security/entity_provider`
81+
* :doc:`/cookbook/security/entity_provider`
82+
83+
REMOTE_USER Based Authentication
84+
--------------------------------
85+
86+
.. versionadded:: 2.6
87+
REMOTE_USER pre authenticated firewall was introduced in Symfony 2.6.
88+
89+
A lot of authentication modules, like ``auth_kerb`` for Apache provide the username
90+
using the ``REMOTE_USER`` environment variable. This variable can be trusted by
91+
the application since the authentication happened before the request reached it.
92+
93+
To configure Symfony using the ``REMOTE_USER`` environment variable, simply enable the
94+
corresponding firewall in your security configuration:
95+
96+
.. configuration-block::
97+
98+
.. code-block:: yaml
99+
100+
# app/config/security.yml
101+
security:
102+
firewalls:
103+
secured_area:
104+
pattern: ^/
105+
remote_user:
106+
provider: your_user_provider
107+
108+
.. code-block:: xml
109+
110+
<!-- app/config/security.xml -->
111+
<?xml version="1.0" ?>
112+
<srv:container xmlns="http://symfony.com/schema/dic/security"
113+
xmlns:srv="http://symfony.com/schema/dic/services">
114+
115+
<config>
116+
<firewall name="secured_area" pattern="^/">
117+
<remote-user provider="your_user_provider"/>
118+
</firewall>
119+
</config>
120+
</srv:container>
121+
122+
.. code-block:: php
123+
124+
// app/config/security.php
125+
$container->loadFromExtension('security', array(
126+
'firewalls' => array(
127+
'secured_area' => array(
128+
'pattern' => '^/'
129+
'remote_user' => array(
130+
'provider' => 'your_user_provider',
131+
),
132+
),
133+
),
134+
));
135+
136+
The firewall will then provide the ``REMOTE_USER`` environment variable to
137+
your user provider. You can change the variable name used by setting the ``user``
138+
key in the ``remote_user`` firewall configuration.
139+
140+
.. note::
141+
142+
Just like for X509 authentication, you will need to configure a "user provider".
143+
See :ref:`the note previous note <cookbook-security-pre-authenticated-user-provider-note>`
144+
for more information.

reference/configuration/security.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ Each part will be explained in the next section.
121121
stateless: false
122122
x509:
123123
provider: some_key_from_above
124+
remote_user:
125+
provider: some_key_from_above
124126
http_basic:
125127
provider: some_key_from_above
126128
http_digest:

0 commit comments

Comments
 (0)