# HOWTO? security based on data values

**URL:** <https://www.ruby-forum.com/t/howto-security-based-on-data-values/100906>\
**Category:** Rails\
**Created:** [August 1, 2006, 10:16pm UTC](https://www.ruby-forum.com/t/howto-security-based-on-data-values/100906 "2006-08-01T22:16:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ashish\_Bansal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@Ashish\_Bansal](https://www.ruby-forum.com/u/Ashish_Bansal)\
**Post date:** [August 1, 2006, 10:16pm UTC](https://www.ruby-forum.com/t/howto-security-based-on-data-values/100906/1 "2006-08-01T22:16:36Z")

</div>

Hi!  
I recently started with RoR and this may be a newbie question.  
I have a company table, employee table and transactions table.  
1 company has many employees. Each employee performs many transactions.  
Employees from different companies LOGIN to the system to record their  
transactions. Employees can search on all transactions associated to  
their companies (indirect relationship via employee), and edit only the  
transactions entered by them.  
(of course my actual application has several objects like transactions  
which employees do, and I am trying to implement the same thing for  
each).

So basically, I am trying to implement a ‘view’ of the data once an  
employee logs in, which shows only those transactions, which correspond  
to the employee’s companies.  
The simple (and tedious way) is to modify all controllers options and  
change all find\_\* methods to take an appropriate ID to restrict the  
records it returns.  
Given that there are several entities, this is a tedious approach.

Is there some other way to configure this ‘data based security’ ? A  
simple way which causes the model to restrict the records it throws out  
in all cases to an appropriate subset?  
I looked at security frameworks like acts\_as\_authenticated (which  
handles only authentication and hence not relevant), and acl\_system2  
(which is RBAC, and not neccessarily data based).

Looking forward to some help!  
-Ashish

---

<div class="post-metadata">

**Author:** ![Ashish\_Bansal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@Ashish\_Bansal](https://www.ruby-forum.com/u/Ashish_Bansal)\
**Post date:** [August 1, 2006, 10:34pm UTC](https://www.ruby-forum.com/t/howto-security-based-on-data-values/100906/2 "2006-08-01T22:34:32Z")

</div>

On Tuesday, August 01, 2006, at 10:16 PM, Ashish Bansal wrote:

> each).  
> simple way which causes the model to restrict the records it throws out
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

I think a plugin was recently released called ‘acts\_as\_view’ that does  
this.

\_Kevin  
[www.sciwerks.com](http://www.sciwerks.com)

---

<div class="post-metadata">

**Author:** ![Ashish\_Bansal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a698b9/32.png) [@Ashish\_Bansal](https://www.ruby-forum.com/u/Ashish_Bansal)\
**Post date:** [August 1, 2006, 10:53pm UTC](https://www.ruby-forum.com/t/howto-security-based-on-data-values/100906/3 "2006-08-01T22:53:04Z")

</div>

Ashish Bansal wrote:

> each).  
> simple way which causes the model to restrict the records it throws out  
> in all cases to an appropriate subset?  
> I looked at security frameworks like acts\_as\_authenticated (which  
> handles only authentication and hence not relevant), and acl\_system2  
> (which is RBAC, and not neccessarily data based).
> 
> Looking forward to some help!  
> -Ashish

Wouldn’t accessing those records through employee associations do the  
trick?

Example:

@employee.transactions.find :all

instead of

Transaction.find :all

–  
Jack C.  
removed\_email\_address@domain.invalid
