m6web / domain-user-bundle
User authentication by domain
Installs: 115 525
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 61
Forks: 4
Open Issues: 0
Requires
- m6web/firewall-bundle: 0.3.*|~1.0.0|^2.0.2
Requires (Dev)
- atoum/atoum: ^2.8|^3.0
- symfony/symfony: ~2.7|~3.0|~4.0
README
DomainUserBundle provides user authentication by subdomain. It allows firewalling, cache customization, route filtering and data filtering by subdomain.
Dependency
DomainUserBundle requires FirewallBundle.
Installation
Add this line in your composer.json:
{ "require": { "m6web/domain-user-bundle": "~1.0" } }
Update your vendors:
$ composer update m6web/domain-user-bundle
Add to your AppKernel.php
:
new M6Web\Bundle\DomainUserBundle\M6WebDomainUserBundle(), new M6Web\Bundle\FirewallBundle\M6WebFirewallBundle(),
Configuration
Modify your routes to add a parameter in your host requirement:
routes: resource: api_routing.yml host: {client}api.example.com requirements: client: ([a-z0-9]+\.)? defaults: client ""
Add in your app/config.yml
:
m6_web_domain_user: default_cache: 300 # Default cache duration router_parameter: client # Parameter in the host requirement default_user: public # User when the parameter is not found users_dir: %kernel.root_dir%/config/users # Directory containing the user configs firewall: allow_debug_route: false # Allows or not (default) web debug toolbar routes for the concerned environment
Add a user app/config/users/public.yml
:
firewall: user_access: # Configure IP restrictions with FirewallBundle default_state: false lists: internal: true allow: # Filter routes alllowed to this user default: true methods: delete: false # Override by method resources: article: false # Override by routes configured with "defaults: {resource: article}" route: post_comment: false # Override by route name allow_debug_route: false # Allows or not (default) web debug toolbar routes for this user cache: defaults: 60 # Override the default cache duration routes: hello: 86400 # Override by route name entities: article: active: true # Arbitrary flag you can use to filter your entities in your repositories parameters: param_name: param_value # Arbitrary parameters
Edit your app/config/security.yml
:
security: firewalls: secured_area: pattern: ^/ anonymous: false m6_web_domain_user: true providers: m6_web_domain_user: id: m6_web_domain_user.user_provider
Tests
$ ./vendor/bin/atoum
Credits
Developped by the Cytron Team of M6 Web. Tested with atoum.
License
DomainUserBundle is licensed under the MIT license.