Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb602b9c

Browse files
committed
Merge branch '2.7' into 2.8
2 parentsbe32e96 +f4c88fd commitb602b9c

File tree

4 files changed

+99
-39
lines changed

4 files changed

+99
-39
lines changed

‎book/controller.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ Just like when creating a controller for a route, the order of the arguments of
806806
order of the arguments, Symfony will still pass the correct value to each
807807
variable.
808808

809+
.._checking-the-validity-of-a-csrf-token::
810+
809811
Validating a CSRF Token
810812
-----------------------
811813

‎book/routing.rst

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,10 @@ Adding HTTP Method Requirements
812812
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
813813

814814
In addition to the URL, you can also match on the *method* of the incoming
815-
request (i.e. GET, HEAD, POST, PUT, DELETE). Suppose youhave a contact form
816-
with two controllers - onefor displayingthe form (on a GETrequest) and one
817-
for processing the form when it's submitted (on aPOST request). This can
818-
beaccomplished with the following route configuration:
815+
request (i.e. GET, HEAD, POST, PUT, DELETE). Suppose youcreate an API for
816+
your blog and you have 2 routes: Onefor displayinga post (on a GETor HEAD
817+
request) and one for updating a post (on aPUT request). This can be
818+
accomplished with the following route configuration:
819819

820820
..configuration-block::
821821

@@ -827,39 +827,39 @@ be accomplished with the following route configuration:
827827
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
828828
// ...
829829
830-
classMainController extends Controller
830+
classBlogApiController extends Controller
831831
{
832832
/**
833-
* @Route("/news")
834-
* @Method("GET")
833+
* @Route("/api/posts/{id}")
834+
* @Method({"GET","HEAD"})
835835
*/
836-
public functionnewsAction()
836+
public functionshowAction($id)
837837
{
838-
// ...display your news
838+
// ...return a JSON response with the post
839839
}
840840
841841
/**
842-
* @Route("/contact")
843-
* @Method({"GET", "POST"})
842+
* @Route("/api/posts/{id}")
843+
* @Method("PUT")
844844
*/
845-
public functioncontactFormAction()
845+
public functioneditAction($id)
846846
{
847-
// ...display and process a contact form
847+
// ...edit a post
848848
}
849849
}
850850
851851
..code-block::yaml
852852
853853
# app/config/routing.yml
854-
news:
855-
path:/news
856-
defaults:{ _controller: AppBundle:Main:news }
857-
methods:[GET]
854+
api_post_show:
855+
path:/api/posts/{id}
856+
defaults:{ _controller: AppBundle:BlogApi:show }
857+
methods:[GET, HEAD]
858858
859-
contact_form:
860-
path:/contact
861-
defaults:{ _controller: AppBundle:Main:contactForm }
862-
methods:[GET, POST]
859+
api_post_edit:
860+
path:/api/posts/{id}
861+
defaults:{ _controller: AppBundle:BlogApi:edit }
862+
methods:[PUT]
863863
864864
..code-block::xml
865865
@@ -870,12 +870,12 @@ be accomplished with the following route configuration:
870870
xsi:schemaLocation="http://symfony.com/schema/routing
871871
http://symfony.com/schema/routing/routing-1.0.xsd">
872872
873-
<routeid="news"path="/news"methods="GET">
874-
<defaultkey="_controller">AppBundle:Main:news</default>
873+
<routeid="api_post_show"path="/api/posts/{id}"methods="GET|HEAD">
874+
<defaultkey="_controller">AppBundle:BlogApi:show</default>
875875
</route>
876876
877-
<routeid="contact_form"path="/contact"methods="GET|POST">
878-
<defaultkey="_controller">AppBundle:Main:contactForm</default>
877+
<routeid="api_post_edit"path="/api/posts/{id}"methods="PUT">
878+
<defaultkey="_controller">AppBundle:BlogApi:edit</default>
879879
</route>
880880
</routes>
881881
@@ -886,20 +886,21 @@ be accomplished with the following route configuration:
886886
use Symfony\Component\Routing\Route;
887887
888888
$collection = new RouteCollection();
889-
$collection->add('news', new Route('/news', array(
890-
'_controller' => 'AppBundle:Main:contact',
891-
), array(), array(), '', array(), array('GET')));
889+
$collection->add('api_post_show', new Route('/api/posts/{id}', array(
890+
'_controller' => 'AppBundle:BlogApi:show',
891+
), array(), array(), '', array(), array('GET', 'HEAD')));
892892
893-
$collection->add('contact_form', new Route('/contact', array(
894-
'_controller' => 'AppBundle:Main:contactForm',
895-
), array(), array(), '', array(), array('GET', 'POST')));
893+
$collection->add('api_post_edit', new Route('/api/posts/{id}', array(
894+
'_controller' => 'AppBundle:BlogApi:edit',
895+
), array(), array(), '', array(), array('PUT')));
896896
897897
return $collection;
898898
899-
Despite the fact that these two routes have identical paths (``/contact``),
900-
the first route will match only GET requests and the second route will match
901-
only POST requests. This means that you can display the form and submit the
902-
form via the same URL, while using distinct controllers for the two actions.
899+
Despite the fact that these two routes have identical paths
900+
(``/api/posts/{id}``), the first route will match only GET or HEAD requests and
901+
the second route will match only PUT requests. This means that you can display
902+
and edit the post with the same URL, while using distinct controllers for the
903+
two actions.
903904

904905
..note::
905906

‎components/routing/introduction.rst

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,15 @@ URL path and some array of custom variables in its constructor. This array
6262
of custom variables can be *anything* that's significant to your application,
6363
and is returned when that route is matched.
6464

65-
If no matching route can be found a
66-
:class:`Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException` will be thrown.
65+
The:method:`UrlMatcher::match() <Symfony\\Component\\Routing\\UrlMatcher::match>`
66+
returns the variables you set on the route as well as the wildcard placeholders
67+
(see below). Your application can now use this information to continue
68+
processing the request. In addition to the configured variables, a ``_route``
69+
key is added, which holds the name of the matched route.
6770

68-
In addition to your array of custom variables, a ``_route`` key is added,
69-
which holds the name of the matched route.
71+
If no matching route can be found, a
72+
:class:`Symfony\\Component\\Routing\\Exception\\ResourceNotFoundException` will
73+
be thrown.
7074

7175
Defining Routes
7276
~~~~~~~~~~~~~~~
@@ -123,6 +127,10 @@ In this case, the route is matched by ``/archive/2012-01``, because the ``{month
123127
wildcard matches the regular expression wildcard given. However, ``/archive/foo``
124128
does *not* match, because "foo" fails the month wildcard.
125129

130+
When using wildcards, these are returned in the array result when calling
131+
``match``. The part of the path that the wildcard matched (e.g. ``2012-01``) is used
132+
as value.
133+
126134
..tip::
127135

128136
If you want to match all URLs which start with a certain path and end in an

‎components/security/authentication.rst

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,5 +269,54 @@ in) is correct, you can use::
269269
$user->getSalt()
270270
);
271271

272+
Authentication Events
273+
---------------------
274+
275+
The security component provides 4 related authentication events:
276+
277+
=============================== ================================================ =========================================================================
278+
Name Event Constant Argument Passed to the Listener
279+
=============================== ================================================ =========================================================================
280+
security.authentication.success ``AuthenticationEvents::AUTHENTICATION_SUCCESS``:class:`Symfony\Component\Security\Core\Event\AuthenticationEvent`
281+
security.authentication.failure ``AuthenticationEvents::AUTHENTICATION_FAILURE``:class:`Symfony\Component\Security\Core\Event\AuthenticationFailureEvent`
282+
security.interactive_login ``SecurityEvents::INTERACTIVE_LOGIN``:class:`Symfony\Component\Security\Http\Event\InteractiveLoginEvent`
283+
security.switch_user ``SecurityEvents::SWITCH_USER``:class:`Symfony\Component\Security\Http\Event\SwitchUserEvent`
284+
=============================== ================================================ =========================================================================
285+
286+
Authentication Success and Failure Events
287+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
288+
289+
When a provider authenticates the user, a ``security.authentication.success``
290+
event is dispatched. But beware - this event will fire, for example, on *every*
291+
request if you have session-based authentication. See ``security.interactive_login``
292+
below if you need to do something when a user *actually* logs in.
293+
294+
When a provider attempts authentication but fails (i.e. throws an ``AuthenticationException``),
295+
a ``security.authentication.failure`` event is dispatched. You could listen on
296+
the ``security.authentication.failure`` event, for example, in order to log
297+
failed login attempts.
298+
299+
Security Events
300+
~~~~~~~~~~~~~~~
301+
302+
The ``security.interactive_login`` event is triggered after a user has actively
303+
logged into your website. It is important to distinguish this action from
304+
non-interactive authentication methods, such as:
305+
306+
* authentication based on a "remember me" cookie.
307+
* authentication based on your session.
308+
* authentication using a HTTP basic or HTTP digest header.
309+
310+
You could listen on the ``security.interactive_login`` event, for example, in
311+
order to give your user a welcome flash message every time they log in.
312+
313+
The ``security.switch_user`` event is triggered every time you activate
314+
the ``switch_user`` firewall listener.
315+
316+
..seealso::
317+
318+
For more information on switching users, see
319+
:doc:`/cookbook/security/impersonating_user`.
320+
272321
.. _`CVE-2013-5750`:https://symfony.com/blog/cve-2013-5750-security-issue-in-fosuserbundle-login-form
273322
.. _`BasePasswordEncoder::checkPasswordLength`:https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Security/Core/Encoder/BasePasswordEncoder.php

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp