Chapters
36 Chapters
|
1:50:44
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.3.3
Subscribe to download the code!Compatible PHP versions: >=5.3.3
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
03.
Authorization with Access Control
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.3.3",
"symfony/symfony": "~2.4", // v2.4.2
"doctrine/orm": "~2.2,>=2.2.3", // v2.4.2
"doctrine/doctrine-bundle": "~1.2", // v1.2.0
"twig/extensions": "~1.0", // v1.0.1
"symfony/assetic-bundle": "~2.3", // v2.3.0
"symfony/swiftmailer-bundle": "~2.3", // v2.3.5
"symfony/monolog-bundle": "~2.4", // v2.5.0
"sensio/distribution-bundle": "~2.3", // v2.3.4
"sensio/framework-extra-bundle": "~3.0", // v3.0.0
"sensio/generator-bundle": "~2.3", // v2.3.4
"incenteev/composer-parameter-handler": "~2.0", // v2.1.0
"doctrine/doctrine-fixtures-bundle": "~2.2.0", // v2.2.0
"ircmaxell/password-compat": "~1.0.3", // 1.0.3
"phpunit/phpunit": "~4.1" // 4.1.0
}
}
3 Comments
Hello Ryan,
how could I achieve an authorization based on sub-domain ?
each sub-domain has it's own configuration and a user is linked to one or more sub-domains.
so when a user is logged in (switch sub-domain), I should check if he has authorization on that sub-domain. What event should I use to make the decision?
- I think kernel.request is not the good one, but neither security.interactive_login
just can't figure out an elegant solution for this.
any idea?
many thanks in advance,
Richard
Hi Richard!
Hmm. I would add a kernel.request listener for this. There, IF the user is logged in and they are not linked to the sub-domain, you can take some action - like redirecting them to the main domain or rendering a special response/template that says they don't have access (you could also simply throw an AccessDeniedException, which will render the standard 403 error template).
Your setup might have some edge-cases I don't know about, which would make this messier than I'm describing - but this is definitely where I'd start. So, I think you and I were thinking fairly closely on this :).
Cheers!
Hello Ryan,
thank you so much for your answer! yeap, finally I solved like this (using a kernel.request) and works like a charm...
many thanks once again,
Richard
"Houston: no signs of life"
Start the conversation!