(Using: LLBLGen 2.5 April 23rd, Oracle 10g r2 - odp.net driver, .Net framework 3.5, Adapter based templates)
Hi,
We're desiging a new infrastracture for our data access security, with the main goal is to prevent access to shared data of a user which does not "own" the data (row).
We're using LLBLGen for most of our data access, and most of it using entities (currently mapped to tables).
I'll demonstrate what we're trying to achiveve by example:
We have an "Orders" table containing:
OrderID (PK)
Amount
ShopID (FK Shops)
We want to prevent on the lowest possible level (i.e. the database) access from a user of ShopID=X to rows with ShopID=Y.
Now, to make the transition as transparent as possible, we thought of "wrapping" each table with a view, that will filter according to the current session context (we already have code that sets the sessions's ShopID when a connection is retrieved from the connection pool):
[pseudo sql code]
CREATE VIEW Orders_View
AS
SELECT *
FROM Orders
WHERE ShopID = GetCurrentContextShopID()
We then create a user with access only to the wrapping views, and replace all direct tables access with views access.
The problem is, when we use entities mapped on views to replace those mapped on tables, we lost a very important part: All the Primary keys are missing (affecting the generated code entity constructors for example), and all the Foreign keys are missing (causing all the relations, sub collections, etc to be missing from generated code).
I can think of a few solutions, but i can see serious disadvantages to them:
1) Creating customs Relations, primary keys as , by hand - tedious work, hard to maintain, misses lots of the generator abilities. Also, i'm not sure i can set a custom PK.
2) Changing the actual mapped object on the generated code, to use the views instead of the tables. for example, changing
base.AddElementMapping( "OrderEntity", "MyUser", @"MySchema", "Orders", 14 );
to
base.AddElementMapping( "OrderEntity", "MyUser", @"MySchema", "Orders_View", 14 );
This can cause some runtime errors, some hard to maintain code, breaking compatability and "it doesn't feel right" effect.
It seems oracle 10g supports creating FK, PK and Unique constraints on views, but LLBLGen doesn't seem to use them.
Does anyone have any ideas as to a possible solution?
By the way, we're also looking the oracle's RLS (row level security) to achieve this data security, anyone had any expirience with it?
Thanks!
Amitay