Changeset 4874
- Timestamp:
- 09/02/08 18:35:47 (18 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/1.0/docs/cookbook/en/record-based-retrieval-security-template.txt
r4873 r4874 1 1 ++ Introduction 2 2 3 This is a tutorial & how-to on using a security template and listener to restrict a user to specific records, or a range of 4 specific records based on credentials and a user table association. Basically fine grained user access control. 5 6 This template was created for a project which had a few credentials, division_manager, district_manager, branch_manager, and salesperson. 7 We have a list of accounts, their related sales and all sorts of sensitive information for each account. Each logged in user should be allowed 8 to only view the accounts and related information based off their credentials + either the division, district, branch or salesperson they are allowed to view. 3 This is a tutorial & how-to on using a security template and listener to restrict a user to specific records, or a range of specific records based on credentials and a user table association. Basically fine grained user access control. 4 5 This template was created for a project which had a few credentials, division_manager, district_manager, branch_manager, and salesperson. We have a list of accounts, their related sales and all sorts of sensitive information for each account. Each logged in user should be allowed to only view the accounts and related information based off their credentials + either the division, district, branch or salesperson they are allowed to view. 9 6 10 7 So a division manager can view all info for all accounts within his division. A salesperson can only view the accounts they are assign. 11 8 12 The template has been a work in progress so the code below may not actually be the final code I'm using today. But since it is now working for all situations 13 I'm asking of it, I thought I would post it as is. 9 The template has been a work in progress so the code below may not actually be the final code I'm using today. But since it is now working for all situations I'm asking of it, I thought I would post it as is. 14 10 15 11 ++ Template … … 143 139 ++ YAML schema syntax 144 140 145 Here is the schema I used this template with. I've removed lots of extra options, other templates I was using, indexes and table names. It may not work out of 146 the box without the indexes - YMMV. 141 Here is the schema I used this template with. I've removed lots of extra options, other templates I was using, indexes and table names. It may not work out of the box without the indexes - YMMV. 147 142 148 143 <code type="yaml"> … … 322 317 ++ User setup 323 318 324 In my case, I create users and provide a checkbox for their credentials, one for each type I have. Lets take Division Manager as an example. 325 In my case we have 3 divisions, East, Central, West. When I create a user I assign it the West division, and check off that they are a division manager. 326 I can then proceed to login, and my account listing page will restrict the accounts I see automatically to my division. 319 In my case, I create users and provide a checkbox for their credentials, one for each type I have. Lets take Division Manager as an example. In my case we have 3 divisions, East, Central, West. When I create a user I assign it the West division, and check off that they are a division manager. I can then proceed to login, and my account listing page will restrict the accounts I see automatically to my division. 327 320 328 321 ++ Querying … … 342 335 </code> 343 336 344 The results you get back will always be restricted to the division you have been assigned. Since in our schema we've defined restrictions on the Branch and Districts as well 345 if I were to want to provide a user with a drop down of potential branches, I can simply query the branches as I normally would, and only the ones in my division would be 346 returned to choose from. 337 The results you get back will always be restricted to the division you have been assigned. Since in our schema we've defined restrictions on the Branch and Districts as well if I were to want to provide a user with a drop down of potential branches, I can simply query the branches as I normally would, and only the ones in my division would be returned to choose from. 347 338 348 339 ++ Restrictions 349 340 350 For the time being, this module only protects tables in the FROM clause, since doctrine currently runs the query listener for the new tables added to the query by the template, 351 and thus we get a pretty nasty query in the end that doesn't work. If I can figure out how to detect such situations reliably I'll update the article. 341 For the time being, this module only protects tables in the FROM clause, since doctrine currently runs the query listener for the new tables added to the query by the template, and thus we get a pretty nasty query in the end that doesn't work. If I can figure out how to detect such situations reliably I'll update the article.