Skip to content

Latest commit

 

History

History
104 lines (81 loc) · 2.48 KB

chapter-1.md

File metadata and controls

104 lines (81 loc) · 2.48 KB

Authentication

EasyAdminPlus is packaged with an authentication layer which allows you to restrict access to the admin area.

Configuration

Update your security settings.

security:
    encoders:
        Jacquesndl\EasyAdminPlusBundle\Entity\User: auto
        # ...

    providers:
        jacquesndl_easy_admin_plus:
            entity: { class: 'Jacquesndl\EasyAdminPlusBundle\Entity\User' } 
        # ...

    firewalls:
        jacquesndl_easy_admin_plus:
            pattern: ^/admin
            anonymous: ~
            logout:
                path: jacquesndl_easy_admin_plus_logout
                target: easyadmin
            guard:
                authenticators:
                    - Jacquesndl\EasyAdminPlusBundle\Security\LoginFormAuthenticator
        # ...

    access_control:
        - { path: '^/admin/login', role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: '^/admin/', role: ROLE_EASY_ADMIN }
        # ...

❗ Make sure that no conflicting firewall is declared before ours.

Update schema

The bundle uses its own User entity. So you need to update the database schema.

php bin/console doctrine:schema:update -f

or

php bin/console doctrine:migration:diff
php bin/console doctrine:migration:migrate

Commands

  • Create an admin
php bin/console jacquesndl:easy-admin-plus:user:create admin password
php bin/console jacquesndl:easy-admin-plus:user:create admin password ROLE_EASY_ADMIN_1 ROLE_EASY_ADMIN_2
  • Remove an admin
php bin/console jacquesndl:easy-admin-plus:user:remove admin
  • Add roles to an admin
php bin/console jacquesndl:easy-admin-plus:user:add-roles admin ROLE_EASY_ADMIN_1 ROLE_EASY_ADMIN_2
  • Remove roles from an admin
php bin/console jacquesndl:easy-admin-plus:user:remove-roles admin ROLE_EASY_ADMIN_1 ROLE_EASY_ADMIN_2
  • Set roles of an admin
php bin/console jacquesndl:easy-admin-plus:user:set-roles admin ROLE_EASY_ADMIN_1 ROLE_EASY_ADMIN_2
  • Change admin password
php bin/console jacquesndl:easy-admin-plus:user:change-password admin password2
  • Enable an admin
php bin/console jacquesndl:easy-admin-plus:user:enable admin
  • Disable an admin
php bin/console jacquesndl:easy-admin-plus:user:disable admin

Login Screen

Page login

Next chapter: Chapter 2 - Additional templates