Closed spalax closed 10 years ago
Hi,
This is something I will need to update. Actually (I think @danizord experienced the same feeling iirc), protecting the service layer is "conceptually beautiful", but in real life it is very hard to do correctly, and protecting services is actually not convenient.
After using ZfcRbac extensively, I found that the best combination is using guards to protect a hierarchy of routes (for instance, blocking all the admin routes...). To that extent, the next to come "RoutePermissionsGuard" will allow to have guards based on permissions. Then, I protect my controllers using the "isGranted" controller plugin.
This is pretty convenient.
Hope it helps.
I've updated the doc a bit.
Cool. Thanks. And i absolutely agree with this definition.
If your application is architectured correctly, it is often simpler to protect your controllers.
While this update is a good start, i'm not really satisfied.
Documentation start like this :
One mistake most beginners do is protecting their applications using guards only.
And no one want's to be called a beginner ! :wink:
I would rather rephrase it like this :
Ideally, you should not protect your applications using only guards (Route or Controller guards). This leaves...
Thougts ?
Note : i'm working on the doc for #245
Yeah I agree. This part of the doc should be rewritten anyway. I'll wait for ZfcRbac 3.0 to make a full review of the doc =).
Please correct me if i have wrong understanding, or miss something. But I have read the part of "Best practice", and a little bit confused. Does somebody can explain me why you should check permission (like "deletePost") in Service Layer?
My point is, if it is called "Best practice and Real world application" Maybe PostService should be named as RestrictedPostService or other more narrow name.