yaml
# app/config/security.yml
- security:
# ...
- role_hierarchy:
ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
Global roles are translated using the "roles" domain.
yaml
# app/config/config.yml
# Imatic user imatic_user: # ... security: role: model: namespaces: includes: - App excludes: - AppExampleBundleEntityExample # exclude single entity - AppFooBundleEntity # exclude all entities
Generate and enable a local bundle called AppUserBundle.
This bundle will contain user-related entities and fixtures.
yaml
- "require": {
# ... "imatic/user-bundle": "^3.0"
}
php
<?php // app/AppKernel.php
public function registerBundles() { $bundles = array( // ... new FOSUserBundleFOSUserBundle(), new ImaticBundleUserBundleImaticUserBundle(), ); }
yaml
# app/config/config.yml
- imports:
# ... - { resource: "@ImaticUserBundle/Resources/config/config.yml" } - { resource: "@AppUserBundle/Resources/config/config.yml" }
- doctrine:
# ... orm: #... resolve_target_entities: # UserBundle ImaticBundleUserBundleModelUserInterface: ApUserBundleEntityUser ImaticBundleUserBundleModelGroupInterface: AppUserBundleEntityGroup
# Imatic user imatic_user: entities: user: AppUserBundleEntityUser group: AppUserBundleEntityGroup security: role: model: namespaces: includes: ~ excludes: ~ hierarchy: ~
yaml
# app/config/security.yml
- security:
- encoders:
SymfonyComponentSecurityCoreUserUserInterface: bcrypt
- role_hierarchy:
ROLE_ADMIN: ROLE_USER ROLE_SUPER_ADMIN: [ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH]
- providers:
- imatic_user_provider:
id: imatic_user.user_provider.username
- firewalls:
- dev:
pattern: ^/(_(profilercssjs)/ security: false
- main:
pattern: ^/ form_login: provider: imatic_user_provider csrf_token_generator: security.csrf.token_manager logout: true anonymous: true switch_user: true
- access_control:
- { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/, role: IS_AUTHENTICATED_FULLY }
yaml
# app/config/routing.yml
- imatic_user:
resource: "@ImaticUserBundle/Resources/config/routing.yml"