Skip to content

Commit bb1c807

Browse files
Jeroen SeegersJeroen Seegers
Jeroen Seegers
authored and
Jeroen Seegers
committed
Make use of php code-blocks
1 parent 340ec5f commit bb1c807

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

cookbook/security/api_key_authentication.rst

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ allows you to implement such a scheme really easily.
2828

2929
Your exact situation may differ, but in this example, a token is read
3030
from an ``apikey`` query parameter, the proper username is loaded from that
31-
value and then a User object is created::
31+
value and then a User object is created:
32+
33+
.. code-block:: php
3234
3335
// src/AppBundle/Security/ApiKeyAuthenticator.php
3436
namespace AppBundle\Security;
@@ -163,7 +165,9 @@ the user. This work is done in a ``getUsernameForApiKey()`` method, which
163165
is created entirely custom for this use-case (i.e. this isn't a method that's
164166
used by Symfony's core user provider system).
165167

166-
The ``$userProvider`` might look something like this::
168+
The ``$userProvider`` might look something like this:
169+
170+
.. code-block:: php
167171
168172
// src/AppBundle/Security/ApiKeyUserProvider.php
169173
namespace AppBundle\Security;
@@ -521,7 +525,9 @@ configuration or set it to ``false``:
521525
Even though the token is being stored in the session, the credentials - in this
522526
case the API key (i.e. ``$token->getCredentials()``) - are not stored in the session
523527
for security reasons. To take advantage of the session, update ``ApiKeyAuthenticator``
524-
to see if the stored token has a valid User object that can be used::
528+
to see if the stored token has a valid User object that can be used:
529+
530+
.. code-block:: php
525531
526532
// src/AppBundle/Security/ApiKeyAuthenticator.php
527533
@@ -585,7 +591,9 @@ The second step is the important one: Symfony calls ``refreshUser()`` and passes
585591
you the user object that was serialized in the session. If your users are
586592
stored in the database, then you may want to re-query for a fresh version
587593
of the user to make sure it's not out-of-date. But regardless of your requirements,
588-
``refreshUser()`` should now return the User object::
594+
``refreshUser()`` should now return the User object:
595+
596+
.. code-block:: php
589597
590598
// src/AppBundle/Security/ApiKeyUserProvider.php
591599
@@ -625,7 +633,9 @@ really need to look for authentication information once the user has reached
625633
a certain URL (e.g. the redirect URL in OAuth).
626634

627635
Fortunately, handling this situation is easy: just check to see what the
628-
current URL is before creating the token in ``createToken()``::
636+
current URL is before creating the token in ``createToken()``:
637+
638+
.. code-block:: php
629639
630640
// src/AppBundle/Security/ApiKeyAuthenticator.php
631641

0 commit comments

Comments
 (0)