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

[Book][Security] add missing versionadded directive#4737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
wouterj merged 1 commit intosymfony:2.6fromxabbuh:password-encoder-versionadded
Jan 2, 2015
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletionsbook/security.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -209,7 +209,7 @@ user to be logged in to access this URL:
# ...
firewalls:
# ...

access_control:
# require ROLE_ADMIN for /admin*
- { path: ^/admin, roles: ROLE_ADMIN }
Expand DownExpand Up@@ -676,7 +676,7 @@ URL pattern. You saw this earlier, where anything matching the regular expressio
# ...
firewalls:
# ...

access_control:
# require ROLE_ADMIN for /admin*
- { path: ^/admin, roles: ROLE_ADMIN }
Expand DownExpand Up@@ -870,9 +870,9 @@ in this chapter).
Be careful with this in your layout or on your error pages! Because of
some internal Symfony details, to avoid broken error pages in the ``prod``
environment, wrap calls in these templates with a check for ``app.user``:

.. code-block:: html+jinja

{% if app.user and is_granted('ROLE_ADMIN') %}

Securing other Services
Expand DownExpand Up@@ -1036,7 +1036,7 @@ the User object, and use the ``isGranted`` method (or

// boo :(. Never check for the User object to see if they're logged in
if ($this->getUser()) {

}

Retrieving the User in a Template
Expand All@@ -1055,7 +1055,7 @@ key:

.. code-block:: html+php

<?php if ($view['security']->isGranted('IS_AUTHENTICATED_FULLY')): ?>
<?php if ($view['security']->isGranted('IS_AUTHENTICATED_FULLY')): ?>
<p>Username: <?php echo $app->getUser()->getUsername() ?></p>
<?php endif; ?>

Expand DownExpand Up@@ -1148,7 +1148,7 @@ Next, you'll need to create a route for this URL (but not a controller):
return $collection;

And that's it! By sending a user to ``/logout`` (or whatever you configure
the ``path`` to be), Symfony will un-authenticate the current user. and
the ``path`` to be), Symfony will un-authenticate the current user. and
redirect them the homepage (the value defined by ``target``).

Once the user has been logged out, they will be redirected to whatever path
Expand DownExpand Up@@ -1180,6 +1180,9 @@ in the following way from a controller::

$user->setPassword($encoded);

.. versionadded:: 2.6
The ``security.password_encoder`` service was introduced in Symfony 2.6.

In order for this to work, just make sure that you have the encoder for your
user class (e.g. ``AppBundle\Entity\User``) configured under the ``encoders``
key in ``app/config/security.yml``.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp