Skip to content

Commit bb1a9b7

Browse files
committed
feature #5921 [2.8] Document some Security changes (WouterJ)
This PR was merged into the 2.8 branch. Discussion ---------- [2.8] Document some Security changes | Q | A | --- | --- | Doc fix? | no | New docs? | yes (symfony/symfony#15131, symfony/symfony#16493, symfony/symfony#15151 | Applies to | 2.8+ | Fixed tickets | - Commits ------- 0526ca0 Document deprecation of supports{Attribute,Class}() methods 22026ee Document Security key to secret renamings 4036d26 Use new Simple{Form,Pre}AuthenticatorInterface namespaces
2 parents 4799a7c + 0526ca0 commit bb1a9b7

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

components/security/authorization.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@ of :class:`Symfony\\Component\\Security\\Core\\Authorization\\Voter\\VoterInterf
9090
which means they have to implement a few methods which allows the decision
9191
manager to use them:
9292

93-
``supportsAttribute($attribute)``
93+
``supportsAttribute($attribute)`` (deprecated as of 2.8)
9494
will be used to check if the voter knows how to handle the given attribute;
9595

96-
``supportsClass($class)``
96+
``supportsClass($class)`` (deprecated as of 2.8)
9797
will be used to check if the voter is able to grant or deny access for
9898
an object of the given class;
9999

@@ -103,6 +103,12 @@ manager to use them:
103103
i.e. ``VoterInterface::ACCESS_GRANTED``, ``VoterInterface::ACCESS_DENIED``
104104
or ``VoterInterface::ACCESS_ABSTAIN``;
105105

106+
.. note::
107+
108+
The ``supportsAttribute()`` and ``supportsClass()`` methods are deprecated
109+
as of Symfony 2.8 and no longer required in 3.0. These methods should not
110+
be called outside the voter class.
111+
106112
The Security component contains some standard voters which cover many use
107113
cases:
108114

cookbook/security/api_key_authentication.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ passed as a query string parameter or via an HTTP header.
1616
The API Key Authenticator
1717
-------------------------
1818

19+
.. versionadded:: 2.8
20+
The ``SimplePreAuthenticatorInterface`` interface was moved to the
21+
``Symfony\Component\Security\Http\Authentication`` namespace in Symfony
22+
2.8. Prior to 2.8, it was located in the
23+
``Symfony\Component\Security\Core\Authentication`` namespace.
24+
1925
Authenticating a user based on the Request information should be done via a
20-
pre-authentication mechanism. The :class:`Symfony\\Component\\Security\\Core\\Authentication\\SimplePreAuthenticatorInterface`
26+
pre-authentication mechanism. The :class:`Symfony\\Component\\Security\\Http\\Authentication\\SimplePreAuthenticatorInterface`
2127
allows you to implement such a scheme really easily.
2228

2329
Your exact situation may differ, but in this example, a token is read
@@ -27,13 +33,13 @@ value and then a User object is created::
2733
// src/AppBundle/Security/ApiKeyAuthenticator.php
2834
namespace AppBundle\Security;
2935

30-
use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
36+
use Symfony\Component\HttpFoundation\Request;
37+
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
3138
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
3239
use Symfony\Component\Security\Core\Exception\AuthenticationException;
33-
use Symfony\Component\Security\Core\Authentication\Token\PreAuthenticatedToken;
34-
use Symfony\Component\HttpFoundation\Request;
35-
use Symfony\Component\Security\Core\User\UserProviderInterface;
3640
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
41+
use Symfony\Component\Security\Core\User\UserProviderInterface;
42+
use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
3743

3844
class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface
3945
{
@@ -273,9 +279,9 @@ you can use to create an error ``Response``.
273279
// src/AppBundle/Security/ApiKeyAuthenticator.php
274280
namespace AppBundle\Security;
275281
276-
use Symfony\Component\Security\Core\Authentication\SimplePreAuthenticatorInterface;
277282
use Symfony\Component\Security\Core\Exception\AuthenticationException;
278283
use Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface;
284+
use Symfony\Component\Security\Http\Authentication\SimplePreAuthenticatorInterface;
279285
use Symfony\Component\HttpFoundation\Response;
280286
use Symfony\Component\HttpFoundation\Request;
281287
@@ -506,8 +512,8 @@ for security reasons. To take advantage of the session, update ``ApiKeyAuthentic
506512
to see if the stored token has a valid User object that can be used::
507513

508514
// src/AppBundle/Security/ApiKeyAuthenticator.php
509-
// ...
510515

516+
// ...
511517
class ApiKeyAuthenticator implements SimplePreAuthenticatorInterface
512518
{
513519
// ...

cookbook/security/custom_password_authenticator.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,28 @@ The Password Authenticator
2121
.. versionadded:: 2.6
2222
The ``UserPasswordEncoderInterface`` interface was introduced in Symfony 2.6.
2323

24+
.. versionadded:: 2.8
25+
The ``SimpleFormAuthenticatorInterface`` interface was moved to the
26+
``Symfony\Component\Security\Http\Authentication`` namespace in Symfony
27+
2.8. Prior to 2.8, it was located in the
28+
``Symfony\Component\Security\Core\Authentication`` namespace.
29+
2430
First, create a new class that implements
25-
:class:`Symfony\\Component\\Security\\Core\\Authentication\\SimpleFormAuthenticatorInterface`.
31+
:class:`Symfony\\Component\\Security\\Http\\Authentication\\SimpleFormAuthenticatorInterface`.
2632
Eventually, this will allow you to create custom logic for authenticating
2733
the user::
2834

2935
// src/Acme/HelloBundle/Security/TimeAuthenticator.php
3036
namespace Acme\HelloBundle\Security;
3137

3238
use Symfony\Component\HttpFoundation\Request;
33-
use Symfony\Component\Security\Core\Authentication\SimpleFormAuthenticatorInterface;
3439
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
3540
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
3641
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
3742
use Symfony\Component\Security\Core\Exception\AuthenticationException;
3843
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
3944
use Symfony\Component\Security\Core\User\UserProviderInterface;
45+
use Symfony\Component\Security\Http\Authentication\SimpleFormAuthenticatorInterface;
4046

4147
class TimeAuthenticator implements SimpleFormAuthenticatorInterface
4248
{

cookbook/security/remember_me.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ The ``remember_me`` firewall defines the following configuration options:
8484

8585
``secret`` (**required**)
8686
.. versionadded:: 2.8
87-
Prior to Symfony 2.8, the ``secret`` option was named ``key``.
87+
The ``secret`` option was introduced in Symfony 2.8. Prior to 2.8, it
88+
was named ``key``.
8889

8990
The value used to encrypt the cookie's content. It's common to use the
9091
``secret`` value defined in the ``app/config/parameters.yml`` file.

reference/configuration/security.rst

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ Each part will be explained in the next section.
180180
181181
remember_me:
182182
token_provider: name
183-
secret: someS3cretKey
183+
secret: "%secret%"
184184
name: NameOfTheCookie
185185
lifetime: 3600 # in seconds
186186
path: /foo
@@ -227,7 +227,7 @@ Each part will be explained in the next section.
227227
domain: ~
228228
handlers: []
229229
anonymous:
230-
secret: 4f954a0667e01
230+
secret: "%secret%"
231231
switch_user:
232232
provider: ~
233233
parameter: _switch_user
@@ -246,6 +246,10 @@ Each part will be explained in the next section.
246246
ROLE_ADMIN: [ROLE_ORGANIZER, ROLE_USER]
247247
ROLE_SUPERADMIN: [ROLE_ADMIN]
248248
249+
.. versionadded:: 2.8
250+
The ``secret`` option of ``anonymous`` and ``remember_me`` was introduced
251+
in Symfony 2.8. Prior to 2.8, it was called ``key``.
252+
249253
.. _reference-security-firewall-form-login:
250254

251255
Form Login Configuration
@@ -479,7 +483,7 @@ multiple firewalls, the "context" could actually be shared:
479483
HTTP-Digest Authentication
480484
--------------------------
481485

482-
To use HTTP-Digest authentication you need to provide a realm and a key:
486+
To use HTTP-Digest authentication you need to provide a realm and a secret:
483487

484488
.. configuration-block::
485489

@@ -490,15 +494,15 @@ To use HTTP-Digest authentication you need to provide a realm and a key:
490494
firewalls:
491495
somename:
492496
http_digest:
493-
key: "a_random_string"
497+
secret: "%secret%"
494498
realm: "secure-api"
495499
496500
.. code-block:: xml
497501
498502
<!-- app/config/security.xml -->
499503
<security:config>
500504
<firewall name="somename">
501-
<http-digest key="a_random_string" realm="secure-api" />
505+
<http-digest secret="%secret%" realm="secure-api" />
502506
</firewall>
503507
</security:config>
504508
@@ -509,12 +513,16 @@ To use HTTP-Digest authentication you need to provide a realm and a key:
509513
'firewalls' => array(
510514
'somename' => array(
511515
'http_digest' => array(
512-
'key' => 'a_random_string',
513-
'realm' => 'secure-api',
516+
'secret' => '%secret%',
517+
'realm' => 'secure-api',
514518
),
515519
),
516520
),
517521
));
518522
523+
.. versionadded:: 2.8
524+
The ``secret`` option was introduced in Symfony 2.8. Prior to 2.8, it was
525+
called ``key``.
526+
519527
.. _`PBKDF2`: https://en.wikipedia.org/wiki/PBKDF2
520528
.. _`ircmaxell/password-compat`: https://packagist.org/packages/ircmaxell/password-compat

0 commit comments

Comments
 (0)