Skip to content

Commit 86ba188

Browse files
author
Maxime Douailin
committed
rebased using x509 pr, added remote_user pre authenticated part
1 parent 8465d46 commit 86ba188

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

cookbook/security/pre_authenticated.rst

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ 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
@@ -76,4 +78,66 @@ in the x509 firewall configuration respectively.
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+
<?xml version="1.0" ?>
111+
<!-- app/config/security.xml -->
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 about it <cookbook-security-pre-authenticated-user-provider-note>`.

0 commit comments

Comments
 (0)