Answer the question
In order to leave comments, you need to log in
How to make dynamic subdomains (multiple dynamic firewalls, routing, etc.) in symfony2?
I am doing a service.
In addition to the frontend and backend parts, there is also a dashboard (each company has its own) with its own authorization and other goodies.
Now the dashboard opens at site.com/dashboard/..., the firewall is the same for all, the data in the controllers is displayed depending on $company_id = $this->getUser()->getCompany()->getId()
I want to transfer the dashboard to subdomains like companyname.site.com/...
I configured nginx so that all requests like companyname.site.com/ go to site.com/.
Now the questions:
1) Now for the tests, 1 firewall is manually registered for the test company, which has slug = democompany. How to create dynamic firewalls for all hosts like companyname.site.com?
security:
...
providers:
dashboard_user_provider:
id: acme.dashboard.user_provider
firewalls:
...
dashboard:
host: democompany.%domain%
pattern: ^/
form_login:
login_path: /login
check_path: /login_check
provider: dashboard_user_provider
csrf_provider: form.csrf_provider
default_target_path: /
logout:
path: /logout
target: /
anonymous: true
remember_me:
key: "%secret%"
lifetime: 31536000 # 365 days in seconds
path: /
domain: ~
access_control:
...
- { host: democompany.%domain%, path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
- { host: democompany.%domain%, path: ^/, role: [ROLE_DASHBOARD_USER] }
public function listAction($company_slug) {
if ($company_slug !== $this->getUser()->getCompany()->getSlug()) {
throw $this->createNotFoundException(sprintf("No data found"));
}
...
...
}
Answer the question
In order to leave comments, you need to log in
Take a look here knpuniversity.com/screencast/question-answer-day/s... - it seems to be what you need.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question