@@ -28,7 +28,9 @@ allows you to implement such a scheme really easily.
28
28
29
29
Your exact situation may differ, but in this example, a token is read
30
30
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
32
34
33
35
// src/AppBundle/Security/ApiKeyAuthenticator.php
34
36
namespace AppBundle\Security;
@@ -163,7 +165,9 @@ the user. This work is done in a ``getUsernameForApiKey()`` method, which
163
165
is created entirely custom for this use-case (i.e. this isn't a method that's
164
166
used by Symfony's core user provider system).
165
167
166
- The ``$userProvider `` might look something like this::
168
+ The ``$userProvider `` might look something like this:
169
+
170
+ .. code-block :: php
167
171
168
172
// src/AppBundle/Security/ApiKeyUserProvider.php
169
173
namespace AppBundle\Security;
@@ -521,7 +525,9 @@ configuration or set it to ``false``:
521
525
Even though the token is being stored in the session, the credentials - in this
522
526
case the API key (i.e. ``$token->getCredentials() ``) - are not stored in the session
523
527
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
525
531
526
532
// src/AppBundle/Security/ApiKeyAuthenticator.php
527
533
@@ -585,7 +591,9 @@ The second step is the important one: Symfony calls ``refreshUser()`` and passes
585
591
you the user object that was serialized in the session. If your users are
586
592
stored in the database, then you may want to re-query for a fresh version
587
593
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
589
597
590
598
// src/AppBundle/Security/ApiKeyUserProvider.php
591
599
@@ -625,7 +633,9 @@ really need to look for authentication information once the user has reached
625
633
a certain URL (e.g. the redirect URL in OAuth).
626
634
627
635
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
629
639
630
640
// src/AppBundle/Security/ApiKeyAuthenticator.php
631
641
0 commit comments