Sonata - 缺少用户安全状态标签

时间:2015-05-26 09:53:15

标签: symfony sonata-admin symfony-sonata sonata-user-bundle sonata

我不知道为什么,但从今天Status标签刚刚消失...... enter image description here

我可以更改Status,但没有标签,所以我不知道我在做什么; - )

enter image description here

app\config\config.yml

imports:
    - { resource: @MyProductBundle/Resources/config/parameters.yml }
    - { resource: security.yml }
    - { resource: services.yml }
    - { resource: @MyProductBundle/Resources/config/admin.yml }
    - { resource: ../../vendor/knplabs/doctrine-behaviors/config/orm-services.yml }

#-------------------------------------------------------------------------------------------------------------------------------------------------------------
framework:
    #esi:             ~
    translator:      { fallbacks: ["%locale%"] }
    secret:          "%secret%"
    router:
        resource: "%kernel.root_dir%/config/routing.yml"
        strict_requirements: ~
    form:            ~
    csrf_protection: ~
    validation:      { enable_annotations: true }
    templating:
        engines: ['twig']
        #assets_version: SomeVersionScheme
    default_locale:  "%locale%"
    trusted_hosts:   ~
    trusted_proxies: ~
    session:
        # handler_id set to null will use default session handler from php.ini
        handler_id:  ~
    fragments:       ~
    http_method_override: true

#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Twig Configuration
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form:
        resources: ['bootstrap_3_layout.html.twig']
#        resources: ['bootstrap_3_horizontal_layout.html.twig]

#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Assetic Configuration
assetic:
    debug:          "%kernel.debug%"
    use_controller: false
    bundles:        [ ]
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        #closure:
        #    jar: "%kernel.root_dir%/Resources/java/compiler.jar"
        #yui_css:
        #    jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"

#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
        types:
            json: Sonata\Doctrine\Types\JsonType
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        entity_managers:
            default:
                auto_mapping: true
                mappings:
                    gedmo_translatable:
                        type: annotation
                        prefix: Gedmo\Translatable\Entity
                        dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
                        alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
                        is_bundle: false
                    gedmo_translator:
                        type: annotation
                        prefix: Gedmo\Translator\Entity
                        dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
                        alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
                        is_bundle: false

#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Swiftmailer Configuration
swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# FOSUserBundle Configuration
fos_user:
    db_driver: orm
    firewall_name:  main
    user_class:     Application\Sonata\UserBundle\Entity\User
    group:
        group_class:   Application\Sonata\UserBundle\Entity\Group
        group_manager: sonata.user.orm.group_manager
    service:
        user_manager: sonata.user.orm.user_manager
#-------------------------------------------------------------------------------------------------------------------------------------------------------------
# Sonata Configuration
sonata_user:
    security_acl: true
    table:
        user_group:           fos_user_user_group

    manager_type:             orm

    profile:
        form:
            type:                 sonata_user_profile
            handler:              sonata.user.profile.form.handler.default
            name:                 sonata_user_profile_form
            validation_groups:
                # Defaults:
                - Profile
                - Default
        dashboard:
            blocks:
                - { position: left, type: sonata.block.service.text, settings: { content: "<h2>Welcome!</h2> This is a sample user profile dashboard, feel free to override it in the configuration! Want to make this text dynamic? For instance display the user's name? Create a dedicated block and edit the configuration!"} }
#                - { position: right, type: sonata.news.block.recent_comments, settings: { title: Recent Comments, number: 5, mode: public }}
        # Customize user portal menu by setting links
        menu:
            - { route: 'sonata_user_profile_show', label: 'sonata_profile_title', domain: 'SonataUserBundle'}
            - { route: 'sonata_user_profile_edit', label: 'link_edit_profile', domain: 'SonataUserBundle'}
            - { route: 'sonata_user_profile_edit_authentication', label: 'link_edit_authentication', domain: 'SonataUserBundle'}

sonata_admin:
    security:
        handler: sonata.admin.security.handler.noop
    title:      JustShop (-;
    title_logo: img/logo.png


    dashboard:
        blocks:
            # display a dashboard block
            -
                position: left
                type: sonata.admin.block.admin_list

            # Customize this part to add new block configuration
            -
                position: right,
                type: sonata.block.service.text,
                settings:
                    content: "<h2>Welcome to the Sonata Admin</h2> <p>This is a <code>sonata.block.service.text</code> from the Block Bundle, you can create and add new block in these area by configuring the <code>sonata_admin</code> section.</p> <br /> For instance, here a RSS feed parser (<code>sonata.block.service.rss</code>):"
            -
                position: right
                type: sonata.block.service.rss
                settings:
                    title: Sonata Projects Feeds
                    url: http://sonata-project.org/blog/archive.rss

    persist_filters: true

sonata_block:
    default_contexts: [cms]
    blocks:
        # Enable the SonataAdminBundle block
        sonata.admin.block.admin_list:
            contexts:   [admin]
        sonata.admin.block.search_result:
            contexts: [admin]
        sonata.user.block.menu:    # used to display the menu in profile pages
        sonata.user.block.account: # used to display menu option (login option)
        sonata.block.service.text: # used to if you plan to use Sonata user routes
        sonata.block.service.rss:

#-------------------------------------------------------------------------------------------------------------------------------------------------------------
stof_doctrine_extensions:
    default_locale: en_US
    translation_fallback: true
    orm:
        default: 
            sluggable:      true
            timestampable:  true
            translatable:   true

#-------------------------------------------------------------------------------------------------------------------------------------------------------------
a2lix_translation_form:
    locale_provider: default
    locales: [en, pl]
    default_locale: en
    required_locales: [en]
    manager_registry: doctrine
    templating: "A2lixTranslationFormBundle::default.html.twig"

app\config\security.yml

# you can read more about security in the related section of the documentation
# http://symfony.com/doc/current/book/security.html
security:
    # http://symfony.com/doc/current/book/security.html#encoding-the-user-s-password
    encoders:
        FOS\UserBundle\Model\UserInterface: sha512

    # http://symfony.com/doc/current/book/security.html#hierarchical-roles
    role_hierarchy:
        ROLE_ADMIN:       [ROLE_USER, ROLE_SONATA_ADMIN]
        ROLE_SUPER_ADMIN: [ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
        SONATA:
            - ROLE_SONATA_PAGE_ADMIN_PAGE_EDIT  # if you are using acl then this line must be commented

    providers:
    # http://symfony.com/doc/current/book/security.html#where-do-users-come-from-user-providers
    providers:
        fos_userbundle:
            id: fos_user.user_manager

    # the main part of the security, where you can set up firewalls
    # for specific sections of your app
    firewalls:
        # disables authentication for assets and the profiler, adapt it according to your needs
        dev:
            pattern:  ^/(_(profiler|wdt)|css|images|js)/
            security: false

        # -> custom firewall for the admin area of the URL
        admin:
            switch_user:        true
            context:            user
            pattern:            /admin(.*)
            form_login:
                provider:       fos_userbundle
                login_path:     /login
                use_forward:    false
                check_path:     /admin/login_check
                failure_path:   null
                use_referer:    true
            logout:
                path:           /logout
                target:         /login
            anonymous:    true
            remember_me:
                key:      9034895c8e6816cad3f8fc4d3171bce10
                lifetime: 3600
                path:     /
                domain:   ~

        # -> end custom configuration
        # defaut login area for standard users
        main:
            switch_user:        true
            context:            user
            pattern:            .*
            form_login:
                provider:       fos_userbundle
                login_path:     /login
                use_forward:    false
                check_path:     /login_check
                failure_path:   null
            logout:             true
            anonymous:          true
            remember_me:
                key:      9034895c8e6816cad3f8fc4d3171bce10
                lifetime: 3600
                path:     /
                domain:   ~
    acl:
        connection: default

    # with these settings you can restrict or allow access for different parts
    # of your application based on roles, ip, host or methods
    # http://symfony.com/doc/current/cookbook/security/access_control.html
    access_control:
        # URL of FOSUserBundle which need to be available to anonymous users
        - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # Admin login page needs to be access without credential
        - { path: ^/admin/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/logout$, role: IS_AUTHENTICATED_ANONYMOUSLY }
        - { path: ^/admin/login_check$, role: IS_AUTHENTICATED_ANONYMOUSLY }

        # Secured part of the site
        # This config requires being logged for the whole site and having the admin role for the admin part.
        # Change these rules to adapt them to your needs
        - { path: ^/admin/, role: [ROLE_ADMIN, ROLE_SONATA_ADMIN] }
        - { path: ^/product/, role: IS_AUTHENTICATED_FULLY }
        - { path: ^/.*, role: IS_AUTHENTICATED_ANONYMOUSLY }

1 个答案:

答案 0 :(得分:0)

这是symfony(?)bootstrap默认配置

中的错误

更改
twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form:
        resources: ['bootstrap_3_layout.html.twig']
#        resources: ['bootstrap_3_horizontal_layout.html.twig]

twig:
    debug:            "%kernel.debug%"
    strict_variables: "%kernel.debug%"
    form:
#        resources: ['bootstrap_3_layout.html.twig']
#        resources: ['bootstrap_3_horizontal_layout.html.twig]