DomainUserBundle provides user authentication by subdomain.
It allows firewalling, cache customization, route filtering and data filtering by subdomain.
DomainUserBundle requires FirewallBundle.
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(),
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
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
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
$ ./vendor/bin/atoum
Developped by the Cytron Team of M6 Web.
Tested with atoum.
DomainUserBundle is licensed under the MIT license.