1

我想要:

  1. 从 prod env 中的 Gentelella 登录过程中删除公共凭据 admin/password 和

  2. 能够在 prod env 中使用创建的用户登录

我使用这里提供的 symfony 的骨架

现在它看起来像这样:

  1. 尽管在我的 fosUserBundle 数据库表中没有用户“admin”,但我仍然可以登录 prod env。

  2. 登录后为用户提供有效凭据,我得到一个 403 - Access Denied 页面。此用户是使用命令行工具添加的,并被提升为 ROLE_ADMIN。

我想我在这里遗漏了一些简单但至关重要的东西。

我试过的:

  • 在 dev env ( /app_dev.php/login) 中一切正常:我无法使用管理员/密码登录,但我可以使用新创建的用户登录。

  • 数据库中没有用户“admin”

  • 刷新缓存,用于 prod 和 env

  • 我在项目文件夹中的所有文件中搜索“admin”和“password”,但找不到任何硬编码的登录数据,仅在模板/树枝中提及

  • 我找不到任何关于此的文档 - 当然我可能正在寻找错误的东西

编辑2:security.yml

# http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
providers:
    in_memory:
        memory: ~
    fos_userbundle:
        id: fos_user.user_provider.username

firewalls:
    # disables authentication for assets and the profiler, adapt it according to your needs

    dev:
        pattern: ^/(_(profiler|wdt)|css|images|js)/
        security: false

    main:
        anonymous: ~

        pattern: ^/
        form_login:
            provider: fos_userbundle
            csrf_token_generator: security.csrf.token_manager
            # if you are using Symfony < 2.8, use the following config instead:
            # csrf_provider: form.csrf_provider

        logout:       true
        anonymous:    true

        # activate different ways to authenticate

        # http_basic: ~
        # http://symfony.com/doc/current/book/security.html#a-configuring-how-your-users-will-authenticate

        # form_login: ~
        # http://symfony.com/doc/current/cookbook/security/form_login_setup.html

encoders:
    FOS\UserBundle\Model\UserInterface: bcrypt

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

access_control:
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/, role: ROLE_ADMIN }
4

0 回答 0