Skip to content

Caution that roles should start with ROLE_ #4218

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 16, 2014
Merged
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions cookbook/security/entity_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,11 @@ about in this section.
If you fail to return any roles, it may appear as if your user isn't
authenticated at all.

.. caution::

The default role voter requires that all of the roles returned should be prefaced by ROLE_.
Example ROLE_ADMIN, ROLE_USER; not just ADMIN or USER.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would reword this a bit and also link to the "Roles" section in the security chapter of the book:

.. caution::

    The default role voter requires to prefix all roles with ``ROLE_`` (see
    the :ref:`section about roles <book-security-roles>` in the book). For
    example, your roles will be ``ROLE_ADMIN`` or ``ROLE_USER`` instead of
    ``ADMIN`` or ``USER``.

In /book/security.rst you would then have to change it to something like this (add the label before the headline):

.. _book-security-roles:

Roles
-----

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not say The default role voter. the main confusion actually comes from a wrong usage of the term role in the documentation. See #4158

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof Well, I thought that at least http://symfony.com/doc/current/book/security.html#roles and its note are correct.


In this example, the ``AcmeUserBundle:User`` entity class defines a
many-to-many relationship with a ``AcmeUserBundle:Role`` entity class.
A user can be related to several roles and a role can be composed of
Expand Down