Skip to content

Commit 1bd187f

Browse files
xabbuhweaverryan
authored andcommitted
fixes thanks to @wouterj
1 parent 37deaa7 commit 1bd187f

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

cookbook/security/custom_authenticator.rst

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
.. index::
22
single: Security; Custom Authenticator
33

4-
How to create a custom Authenticator
4+
How to create a Custom Authenticator
55
====================================
66

7-
Introduction
8-
------------
9-
107
Imagine you want to allow access to your website only between 2pm and 4pm (for
118
the UTC timezone). Before Symfony 2.4, you had to create a custom token, factory,
129
listener and provider.
1310

1411
The Authenticator
1512
-----------------
1613

17-
Thanks to new simplified authentication customization options in Symfony 2.4,
18-
you don't need to create a whole bunch of new classes, but use the
14+
But now, thanks to new simplified authentication customization options in
15+
Symfony 2.4, you don't need to create a whole bunch of new classes, but use the
1916
:class:`Symfony\\Component\\Security\\Core\\Authentication\\SimpleFormAuthenticatorInterface`
2017
interface instead::
2118

@@ -90,7 +87,7 @@ interface instead::
9087
.. versionadded:: 2.4
9188
The ``SimpleFormAuthenticatorInterface`` interface was added in Symfony 2.4.
9289

93-
How it works
90+
How it Works
9491
------------
9592

9693
There are a lot of things going on:
@@ -131,18 +128,26 @@ Now, configure your ``TimeAuthenticator`` as a service:
131128
.. code-block:: xml
132129
133130
<!-- app/config/config.xml -->
134-
<services>
135-
<service id="time_authenticator"
136-
class="Acme\HelloBundle\Security\TimeAuthenticator">
137-
<argument type="service" id="security.encoder_factory"/>
138-
</service>
139-
</services>
131+
<?xml version="1.0" ?>
132+
<container xmlns="http://symfony.com/schema/dic/services"
133+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
134+
xsi:schemaLocation="http://symfony.com/schema/dic/services
135+
http://symfony.com/schema/dic/services/services-1.0.xsd">
136+
<services>
137+
<service id="time_authenticator"
138+
class="Acme\HelloBundle\Security\TimeAuthenticator">
139+
<argument type="service" id="security.encoder_factory"/>
140+
</service>
141+
</services>
142+
</container>
140143
141144
.. code-block:: php
142145
143146
// app/config/config.php
144147
use Symfony\Component\DependencyInjection\Definition;
145148
use Symfony\Component\DependencyInjection\Reference;
149+
150+
// ...
146151
147152
$container->setDefinition('time_authenticator', new Definition(
148153
'Acme\HelloBundle\Security\TimeAuthenticator',
@@ -180,11 +185,12 @@ like this:
180185
xsi:schemaLocation="http://symfony.com/schema/dic/services
181186
http://symfony.com/schema/dic/services/services-1.0.xsd">
182187
<config>
183-
<firewall name="secured_area" pattern="^/admin">
184-
<provider name="authenticator" />
188+
<firewall name="secured_area"
189+
pattern="^/admin"
190+
provider="authenticator">
185191
<simple-form authenticator="time_authenticator"
186-
check_path="login_check"
187-
login_path="login" />
192+
check-path="login_check"
193+
login-path="login" />
188194
</firewall>
189195
</config>
190196
</srv:container>

0 commit comments

Comments
 (0)